json xss 防范
好像最近大家对 json xss 不是太热,Google有过一次:http://ha.ckers.org/blog/20060704/cross-site-scripting-vulnerability-in-google/
好像大牛们早就知道这种了。
那么防范这样的XSS也是很容易的,比如有XSS漏洞的页面是这样的:
<?PHP $woyigui = $_GET["xss"]; echo $woyigui; ?>
当然了,具体应用时更为复杂,修补方法很简单,开发人员可以改成如下这样:
<?PHP header("Content-type: application/json"); $woyigui = $_GET["xss"]; echo $woyigui; ?>
更改MIME文档类型来防范。测试的时候发现 text/plain 、application/x-zip-compressed 是会被 IE解析了。其他应该还是会有的,没有一个一个测试。
更多文档:
http://www.rfc-editor.org/rfc/rfc4627.txt http://www.dev411.com/blog/2006/07/24/json-xss-exploit-dont-use-text-html http://ha.ckers.org/blog/20060704/cross-site-scripting-vulnerability-in-google/ http://www.souzz.net/html/Security/3/38128.html http://hi.baidu.com/momoca/blog/item/91317bf451b322d9f2d385f8.html Content-type表
转载请注明:woyigui's blog [http://www.woyigui.cn/]
本文标题:json xss 防范
本文地址:http://www.woyigui.cn/2009/04/28/json-xss/
最新评论