wordpress /wp-includes/http.php文件中的wp_http_validate_url函数对输入IP验证不当,导致黑客可构造类似于012.10.10.10这样的畸形IP绕过验证,进行SSRF。
解决方案:
在网站目录中找到这个wp-includes/http.php文件,编辑http.php
查找
$same_host = strtolower( $parsed_home['host'] ) === strtolower( $parsed_url['host'] );
|---|--------------------------------------------------------------------------------------------| | 1 | $same_host = strtolower( $parsed_home['host'] ) === strtolower( $parsed_url['host'] ); |
替换成
if ( isset( $parsed_home['host'] ) ) { $same_host = ( strtolower( $parsed_home['host'] ) === strtolower( $parsed_url['host'] ) || 'localhost' === strtolower( $parsed_url['host'] ) ); } else { $same_host = false; };
|---|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | 1 | 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 ( 127 === $parts[0] || 10 === $parts[0] || 0 === $parts[0]
|---|-------------------------------------------------------------------------| | 1 | if ( 127 === $parts[0] || 10 === $parts[0] || 0 === $parts[0] |
改成
if ( 127 === $parts[0] || 10 === $parts[0] || 0 === $parts[0] || 0 === $parts[0]
|---|------------------------------------------------------------------------------------------------| | 1 | if ( 127 === $parts[0] || 10 === $parts[0] || 0 === $parts[0] || 0 === $parts[0] |