当前位置:WooYun >> 漏洞信息

漏洞概要 关注数(24) 关注此漏洞

缺陷编号:wooyun-2014-063872

漏洞标题:Youyax 任意文件删除。

相关厂商:youyax.com

漏洞作者: ′雨。

提交时间:2014-06-07 11:41

修复时间:2014-09-05 11:42

公开时间:2014-09-05 11:42

漏洞类型:SQL注射漏洞

危害等级:高

自评Rank:20

漏洞状态:厂商已经修复

漏洞来源: http://www.wooyun.org,如有疑问或需要帮助请联系 [email protected]

Tags标签:

4人收藏 收藏
分享漏洞:


漏洞详情

披露状态:

2014-06-07: 细节已通知厂商并且等待厂商处理中
2014-06-07: 厂商已经确认,细节仅向厂商公开
2014-08-01: 细节向核心白帽子及相关领域专家公开
2014-08-11: 细节向普通白帽子公开
2014-08-21: 细节向实习白帽子公开
2014-09-05: 厂商已经修复漏洞并主动公开,细节向公众公开

简要描述:

最新版 这程序更新得真块 任意文件删除。删除status.txt 可以直接重装系统。

详细说明:

WooYun: Youyax V5.4.1 注入 (可修改其他用户的密码)#4
下个最新的程序来看看官方是怎么修补的。

public function saveself()
{
$user = $_SESSION['youyax_user'];
if ($user == "" || $user == null)
$this->redirect("Index" . C('default_url') . "index" . C('static_url'));
$face = addslashes($_POST['face']);
mysql_query("update " . C('db_prefix') . "user set face='" . $face . "' where user='" . $user . "'");
mysql_query("update " . C('db_prefix') . "talk set face='" . $face . "' where zuozhe='" . $user . "'");
mysql_query("update " . C('db_prefix') . "reply set face1='" . $face . "' where zuozhe1='" . $user . "'");
mysql_query("update " . C('db_prefix') . "mark2 set pic='" . $face . "' where marker='" . $user . "'");
mysql_query("update " . C('db_prefix') . "mark1 set pic='" . $face . "' where marker='" . $user . "'");


可以看到是把$face进行了addslashes一次 转义后这里就不能注入了。
然后入库。

| status     | tinyint(1)    | NO   |     | NULL    |                |
| email | varchar(50) | NO | | NULL | |
| complete | int(4) | NO | | NULL | |
| face | varchar(50) | NO | | NULL | |


50个字符 足够了。
出库导致的任意文件删除。
在lib/indexaction.php中

public function resize($filename)
{
$user = $_SESSION['youyax_user'];
if ($user == "" || $user == null)
$this->redirect("Index" . C('default_url') . "index" . C('static_url'));
$album = "./Public/pic/upload";
$filenameall = $album . "/" . $filename;
// File and new size
// Content type
// header('Content-type: image/jpeg');
// Get new sizes
list($width, $height) = getimagesize($filenameall);
list($font, $back) = explode(".", $filename); //获取扩展名
if ($width >= $height && $width > 120) {
$newwidth = 120;
$newheight = $newwidth * $height / $width;
} else if ($height >= $width && $height > 120) {
$newheight = 120;
$newwidth = $newheight * $width / $height;
} else {
$newwidth = $width;
$newheight = $height;
}
// Load
$thumb = imagecreatetruecolor($newwidth, $newheight);
switch (strtolower($back)) {
case 'gif':
$source = imagecreatefromgif($filenameall);
imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
$name = time() . ".gif";
imagegif($thumb, $album . "/" . $name);
break;
case 'jpg':
case 'jpeg':
$source = imagecreatefromjpeg($filenameall);
imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
$name = time() . ".jpg";
imagejpeg($thumb, $album . "/" . $name);
break;
case 'png':
$source = imagecreatefrompng($filenameall);
imagesavealpha($source, true);
imagealphablending($thumb, false);
imagesavealpha($thumb,true);
imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
$name = time() . ".png";
imagepng($thumb, $album . "/" . $name);
break;
default:
break;
}
$oldface = mysql_fetch_array(mysql_query("select * from " . C('db_prefix') . "user where user='" . $user . "'"));//这里出库
$oldface2 = $oldface['face'];//这里点。
mysql_query("update " . C('db_prefix') . "user set face='upload/" . $name . "' where user='" . $user . "'");
mysql_query("update " . C('db_prefix') . "talk set face='upload/" . $name . "' where zuozhe='" . $user . "'");
mysql_query("update " . C('db_prefix') . "reply set face1='upload/" . $name . "' where zuozhe1='" . $user . "'");
mysql_query("update " . C('db_prefix') . "mark2 set pic='upload/" . $name . "' where marker='" . $user . "'");
mysql_query("update " . C('db_prefix') . "mark1 set pic='upload/" . $name . "' where marker='" . $user . "'");
if (preg_match_all("/upload/", $oldface2, $tmp)) {
@unlink("./Public/pic/$oldface2");
}
@unlink("./Public/pic/upload/$filename");
}


if (preg_match_all("/upload/", $oldface2, $tmp)) {
@unlink("./Public/pic/$oldface2");
}
@unlink("./Public/pic/upload/$filename");


这里$filename 是不可控的, $oldface2 出库来的 可控。
所以

if (preg_match_all("/upload/", $oldface2, $tmp)) {
@unlink("./Public/pic/$oldface2");

要进这里
所以来让$oldface2 能匹配出/upload/ 就能进这个unlink。
构造一下/../../upload/../install/status.txt

漏洞证明:

y1.jpg


入库 然后访问

y2.jpg


y3.jpg


删除后就能直接重装了。

修复方案:

check in or check out

版权声明:转载请注明来源 ′雨。@乌云


漏洞回应

厂商回应:

危害等级:高

漏洞Rank:20

确认时间:2014-06-07 12:41

厂商回复:

看来要加正则了,PS:官网都挂了

最新状态:

2014-06-07:公开