LoginSignup
21
8

More than 5 years have passed since last update.

PHPMailerの脆弱性CVE-2016-10033はWordPressにどの程度影響するのだろうか

Last updated at Posted at 2016-12-28

まず前提として、PHPMailerの脆弱性は
https://github.com/opsxcq/exploit-CVE-2016-10033/blob/master/www/index.php#L33
この箇所のコード、外部からの入力$emailを送信者アドレスとして$phpmailer->setFrom($email, $name)と設定することで発生する。
または直接$phpmailer->Sender = $emailとしても同じ。

それ以外ではPHPMailerSenderプロパティが書き換わることは無く脆弱性も発生しないという認識なんだけれども。合ってるだろうか。

WordPressのメール送信はwp_mailという関数で実行されていて、そこには

       /**
         * Filters the email address to send from.
         *
         * @since 2.2.0
         *
         * @param string $from_email Email address to send from.
         */
        $from_email = apply_filters( 'wp_mail_from', $from_email );

        /**
         * Filters the name to associate with the "from" email address.
         *
         * @since 2.3.0
         *
         * @param string $from_name Name associated with the "from" email address.
         */
        $from_name = apply_filters( 'wp_mail_from_name', $from_name );

        $phpmailer->setFrom( $from_email, $from_name, false );

とある。基本的に送信者は全体で共通になっている。かつ第三引数がfalseなのでSenderが書き換わらない。

WordPressの他のメール送信機能では、例えばプラグインのContact Form 7がある。
が、デフォルトの送信者アドレスは固定になっている。

http://ryus.co.jp/blog/contactform7-error/
こちらに書かれているように[your-name] <[your-email]>という設定になっているとフォームの入力値が設定される。
しかし、そもそもContact Form 7はPHPMailersetFromを呼び出しておらず、Senderが設定されない。
なので、Senderを書き換えるには上記設定に加えて
http://2inc.org/blog/2013/08/05/3459/
ここに書かれているようなカスタマイズをしないといけない。(ここでは固定値なのでもうひと手間かかる)

ここまでやって得られるのはReturn-Path書き換えによるSPFレコード不一致によるスパム判定なので、WordPressで該当する人は多くないんじゃないだろうか。
SPFレコードが使われるようになってから、送信者アドレス(FromでなくReturn-Path)をフォームの入力値で書き換えること自体がおかしいとも言える。

まあでもContact Form 7はたまたま該当機能を使っていなかっただけで、PHPMailerの

    /**
     * Set the From and FromName properties.
     * @param string $address
     * @param string $name
     * @param boolean $auto Whether to also set the Sender address, defaults to true
     * @throws phpmailerException
     * @return boolean
     */
    public function setFrom($address, $name = '', $auto = true)

$auto = true が初期値になっているので、Fromを変えたいだけなのにReturn-Pathも変わってしまってSPFでエラーになるし脆弱性も発生するしという状況もあるのかもしれない。

21
8
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
21
8