SMTP認証へ辞書攻撃されるのでメールサーバをSMTPS-AUTH のみ利用にする

スポンサーリンク
スポンサーリンク

メール送信時に認証を要求する SMTP-AUTH が利用できるメールサーバの場合、SMTP-AUTH のポートに対して、ユーザ名/パスワードを試行する辞書攻撃を受けることがあります。

SMTP-AUTH で辞書攻撃を受けている場合、ログ /var/log/secure に以下のような行が残ります。

Jan 19 16:44:21 pcvogel auth: pam_unix(dovecot:auth): authentication failure; logname= uid=0 euid=0 tty=dovecot ruser=root rhost=xxx.xxx.xxx.xxx  user=root
Jan 19 16:44:23 pcvogel auth: pam_unix(dovecot:auth): authentication failure; logname= uid=0 euid=0 tty=dovecot ruser=root rhost=xxx.xxx.xxx.xxx  user=root
Jan 19 16:44:23 pcvogel auth: pam_unix(dovecot:auth): authentication failure; logname= uid=0 euid=0 tty=dovecot ruser=root rhost=xxx.xxx.xxx.xxx  user=root
          :

SMTP-AUTH なのに、受信サーバである dovecot の文字が見えますが、これは、/etc/postfix/main.cf で smtpd_sasl_type = dovecot と指定して、メール送信時の認証に Dovecot を利用するように設定している為です。

ファイアウォールで接続元を制限したいところですが、そうもいきません。

SMTP-AUTH は25番ポートを使用しますが、25番ポートは外部から、あなたのサーバ宛てのメール配信にも利用されます。
従って 25番ポートをブロックしてしまうと、あなた宛てのメールが届かなくなるので、ブロックできません。

こちら で紹介したiptablesサンプルでも、25番ポートは制限しないようになっています。

このようにSMTP-AUTH で使用する25番ポートは制限出来ないため、辞書攻撃され放題になります。

そこで、25番ポートでメール送信時の認証を行う SMTP-AUTH をやめて、パスワードのやり取り時に暗号化通信を行う SMTPS-AUTH で行いましょう。
SMTPS-AUTH では 25番ポート以外を使用するため、ファイアウォールでメール送信元の制限をかけることも出来ます。

以降ではその設定を説明します。
なお、前提として下記でメールサーバが構築されているものとします。

CentOS6でのメールサーバの設定(postfixその1)
CentOS6でのメールサーバの設定(postfixその2)

root で以降の作業をします。

/etc/postfix/main.cf の修正

変更前

# SMTP-Auth用
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
smtpd_sasl_local_domain = $myhostname

変更後

# SMTP-Auth用
#smtpd_sasl_type = dovecot
#smtpd_sasl_path = private/auth
#smtpd_sasl_auth_enable = yes
#smtpd_sasl_security_options = noanonymous
#smtpd_sasl_local_domain = $myhostname

/etc/postfix/master.cf の修正

変更前

smtps     inet  n       -       n       -       -       smtpd
  -o smtpd_tls_wrappermode=yes
  -o smtpd_sasl_auth_enable=yes
  -o smtpd_client_restrictions=permit_sasl_authenticated,reject

変更後

smtps     inet  n       -       n       -       -       smtpd
  -o smtpd_sasl_type = dovecot
  -o smtpd_sasl_path = private/auth
  -o smtpd_sasl_security_options = noanonymous
  -o smtpd_sasl_local_domain = $myhostname
  -o smtpd_tls_wrappermode=yes
  -o smtpd_sasl_auth_enable=yes
  -o smtpd_client_restrictions=permit_sasl_authenticated,reject

上記で行った修正を、postfix に反映させます。

/etc/init.d/postfix reload

これで、SMTP-AUTH の代わりに、SMTPS-AUTH が利用できるようになります。

メールサーバ構築時に、下記手順で行っている場合は、SMTPS-AUTH は587番ポートで利用できます。

CentOS6でのメールサーバの設定(postfixその1)
CentOS6でのメールサーバの設定(postfixその2)

コメント

タイトルとURLをコピーしました