Lucene search

K
seebugRootSSV:1927
HistoryJun 28, 2007 - 12:00 a.m.

WordPress Custom字段任意文件上传漏洞

2007-06-2800:00:00
Root
www.seebug.org
38

WordPress是一款基于WEB的网络日记程序。

WordPress custom字段处理存在任意文件上传问题,远程攻击者可以利用漏洞上传PHP脚本文件并以WEB进程权限执行。

WordPress允许上传受限制的文件附件,名字标题和其他值存储在post_type=attachment的wp_posts表中,路径和其他文件属性使用特定字段_wp_attached_file和_wp_attachment_metadata中的wp_postmeta表中。

其次,WordPress允许在普通POST或页面中增加custom字段(此字段存储在wp_postmeta表中),但是没有检查增加在普通POSTS中的附件meta-data字段数据。

在wp-app.php中,如下函数允许文件上传:

function put_file($postID) {

$type = $this->get_accepted_content_type();

// first check if user can upload
if(!current_user_can(‘upload_files’))
$this->auth_required(__(‘You do not have permission to upload files.’));

// check for not found
global $entry;
$this->set_current_entry($postID);

// then whether user can edit the specific post
if(!current_user_can(‘edit_post’, $postID)) {
$this->auth_required(__(‘Sorry, you do not have the right to edit this post.’));
}

$location = get_post_meta($entry[‘ID’], ‘_wp_attached_file’, true);

if(!isset($location))
$this->internal_error(__(‘Error ocurred while accessing post metadata for file location.’));

$fp = fopen("php://input", "rb");
$localfp = fopen($location, "w+");
while(!feof($fp)) {
fwrite($localfp,fread($fp, 4096));
}
fclose($fp);
fclose($localfp);

log_app(‘function’,"put_file($postID)");
$this->ok();
}

这个函数基本装载第一个附件的路径并写入内容传递给wp-app.php,如果攻击者使用文件名覆盖第一个附件metadata字段值,所有内容将被写入这个文件中。

WordPress WordPress MU 1.2.2
WordPress WordPress 2.1.3
WordPress WordPress 2.1.3
WordPress WordPress 2.1.2
WordPress WordPress 2.1.1
WordPress WordPress 2.0.10
WordPress WordPress 2.0.7
WordPress WordPress 2.0.6
WordPress WordPress 2.0.5
WordPress WordPress 2.0.4
WordPress WordPress 2.0.3
WordPress WordPress 2.0.2
WordPress WordPress 2.0.1
WordPress WordPress 2.0
WordPress WordPress 2.2
WordPress WordPress 2.1.3-RC2
WordPress WordPress 2.1.3-RC1
WordPress WordPress 2.1
WordPress WordPress 2.0.10-RC2
WordPress WordPress 2.0.10-RC1

可联系供应商获得补丁信息:

<a href=“http://wordpress.org/” target=“_blank”>http://wordpress.org/</a>


                                                1,建立或编辑一条POST,使用如下值增加/覆盖&nbsp;custom字段:

key&nbsp;&nbsp;:&nbsp;_wp_attached_file
value&nbsp;&nbsp;:&nbsp;/home/vulnerable.com/wp/wp-content/uploads/backdoor.php

2,发送PUT请求给wp-app.php,然后从第一步中传递post_ID: