WordPress 后台插件更新模块任意目录遍历导致DOS漏洞和IP验证不当漏洞

本文目录[隐藏]1漏洞1:WordPress 后台插件更新模块任意目录遍历导致DOS漏洞1.1描述1.2修复方法2漏洞2:WordPress IP验证不当漏洞2.1描述2.2修复方法3特别提示

最近频繁收到阿里云的两个漏洞提示,相信很多使用阿里云服务器的朋友也会收到:

WordPress 后台插件更新模块任意目录遍历导致DOS漏洞WordPress IP验证不当漏洞

修复这两个漏洞的最直接的办法就是马上升级到 WordPress 4.6.1 版本即可!

下面还是简单说说这两个漏洞,以及不升级4.6.1时应该如何手动修复。

漏洞1:WordPress 后台插件更新模块任意目录遍历导致DOS漏洞

描述

wordpress后台文件/wp-admin/includes/ajax-actions.php中,对代码插件路径的输入参数plugin未进行正确的规范化转义,导致黑客可传入特殊路径,造成拒绝服务。

修复方法

wordpress 4.5.4版本:

打开WordPress后台文件/wp-admin/includes/ajax-actions.php,大概在3077行左右找到以下代码:

1
$plugin = urldecode( $_POST['plugin'] );

$plugin = urldecode( $_POST[‘plugin’] );

在它的下面添加一行:

1
$plugin = plugin_basename( sanitize_text_field( wp_unslash( $_POST['plugin'] ) ) );

$plugin = plugin_basename( sanitize_text_field( wp_unslash( $_POST[‘plugin’] ) ) );

至此,修改保存上传覆盖后即可成功修复WordPress 4.5.4版本的WordPress后台插件更新模块任意目录遍历导致DOS漏洞。

wordpress 4.5.4版本以下:

WordPress 4.5.4版本以下的,除了要按照WordPress 4.5.4版本的办法修复之外,还需要继续进行以下两个步骤的操作PS:如果某版本的以下2点中的代码已经跟修复后一样的就不用修改了):

1、在/wp-admin/includes/ajax-actions.php文件中搜索找以下代码:

1
2
3
if ( $plugin_update_data === true ) {
    wp_send_json_error( $status );
}

if ( $plugin_update_data === true ) {
wp_send_json_error( $status );
}

直接修改为:

1
2
3
4
if ( $plugin_update_data === true ) {
    $status['error'] = __( 'Plugin update failed.' );
    wp_send_json_error( $status );
}

if ( $plugin_update_data === true ) {
$status[‘error’] = __( ‘Plugin update failed.’ );
wp_send_json_error( $status );
}

2、在/wp-admin/includes/ajax-actions.php文件中搜索找以下代码:

1
2
3
4
5
6
if ( is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->get_error_code() ) {
    $status['error'] = $wp_filesystem->errors->get_error_message();
    }
 wp_send_json_error( $status );
 }
}

if ( is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->get_error_code() ) {
$status[‘error’] = $wp_filesystem->errors->get_error_message();
}
wp_send_json_error( $status );
}
}

直接修改为:

1
2
3
4
5
6
7
8
9
10
if ( is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->get_error_code() ) {
     $status['error'] = $wp_filesystem->errors->get_error_message();
   }
wp_send_json_error( $status );
} else {
// An unhandled error occured
$status['error'] = __( 'Plugin update failed.' );
wp_send_json_error( $status );
}
}

if ( is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->get_error_code() ) {
$status[‘error’] = $wp_filesystem->errors->get_error_message();
}
wp_send_json_error( $status );
} else {
// An unhandled error occured
$status[‘error’] = __( ‘Plugin update failed.’ );
wp_send_json_error( $status );
}
}

至此,修改保存上传覆盖后即可成功修复WordPress 4.5.4版本以下的WordPress后台插件更新模块任意目录遍历导致DOS漏洞。

漏洞2:WordPress IP验证不当漏洞

描述

wordpress /wp-includes/http.php文件中的wp_http_validate_url函数对输入IP验证不当,导致黑客可构造类似于012.10.10.10这样的畸形IP绕过验证,进行SSRF

修复方法

找到/wp-includes/http.php这个文件,大概在文件465行:

1
$same_host = strtolower( $parsed_home['host'] ) === strtolower( $parsed_url['host'] );

$same_host = strtolower( $parsed_home[‘host’] ) === strtolower( $parsed_url[‘host’] );

修改为:

1
2
3
4
5
if ( isset( $parsed_home['host'] ) ) {
	$same_host = ( strtolower( $parsed_home['host'] ) === strtolower( $parsed_url['host'] ) || 'localhost' === strtolower( $parsed_url['host'] ) );
} else {
	$same_host = false;
}

if ( isset( $parsed_home[‘host’] ) ) {
$same_host = ( strtolower( $parsed_home[‘host’] ) === strtolower( $parsed_url[‘host’] ) || ‘localhost’ === strtolower( $parsed_url[‘host’] ) );
} else {
$same_host = false;
}

修改保存上传覆盖后即可成功修复IP验证不当漏洞。

特别提示

修复后,一定要到阿里云后台“重新验证”或“忽略”漏洞,否则还是会一直发送信息的!

 

参考:

wordpress IP验证不当漏洞与wordpress后台插件更新模块任意目录遍历导致DOS漏洞

http://boke112.com/3553.html

本人擅长Ai、Fw、Fl、Br、Ae、Pr、Id、Ps等软件的安装与卸载,精通CSS、JavaScript、PHP、ASP、C、C++、C#、Java、Ruby、Perl、Lisp、Python、Objective-C、ActionScript、Pascal等单词的拼写,熟悉Windows、Linux、OS X、Android、iOS、WP8等系统的开关机。

通过下面的方式来联系我们:

电邮:138762189@qq.com

联系QQ:点击这里给我发消息

官方站:www.tadke.com

※ ※ 联系请加我的企鹅号 ※※

※ ※技术支持请微信联系站长 ※※

Copyright © 2023 Tadke.com. 琼ICP备20000547号