查看文章
 
IE 8 对ClickJacking 的防御
2009-02-01 11:27
Clickjacking 还不明白的可以先google

最近IE 8 RC1 发布了,也多了一个新特性,对ClickJacking的防御。

具体可以参考:
http://blogs.msdn.com/ie/archive/2009/01/27/ie8-security-part-vii-clickjacking-defenses.aspx

由于IE是个浏览器,所以微软就大方的发挥了浏览器的先天优势,造了一个 HTTP 头来防御ClickJacking

X-FRAME-OPTIONS

具体用法摘录原文如下:

Web developers can send a HTTP response header named X-FRAME-OPTIONS with HTML pages to restrict how the page may be framed. If the X-FRAME-OPTIONS value contains the token DENY, IE8 will prevent the page from rendering if it will be contained within a frame. If the value contains the token SAMEORIGIN, IE will block rendering only if the origin of the top level-browsing-context is different than the origin of the content containing the X-FRAME-OPTIONS directive. For instance, if http://shop.example.com/confirm.asp contains a DENY directive, that page will not render in a subframe, no matter where the parent frame is located. In contrast, if the X-FRAME-OPTIONS directive contains the SAMEORIGIN token, the page may be framed by any page from the exact http://shop.example.com origin.


不喜欢看鸟语的,可以看我的小结:
1. 返回的HTTP 头中,如果是 X-Frame-OPTIONS: DENY ,那么这个页面就不能被嵌入在iframe里面,IE会报告个错误提示

2. 返回的HTTP 头中,如果是 X-Frame-OPTIONS: SAMEORIGIN ,那么这个页面只能被嵌入在 ”与TOP 页面同源“ 的页面中。(熟悉同源策略的应该很好理解)



对于程序员来说:就是要在重要的页面,加上这个HTTP返回头。

能够起到同样效果的,有frame busting 的技巧
我们经常可以看到这样一段JS:
<script type="text/javascript">if (top!=self) top.location.href=self.location.href;</script>

目的是为了防止页面被iframe引用,比如baidu的很多页面就都包含了这段js,这个技巧就是frame busting

但是由于这段代码是JS写的,所以有很多方法可以绕过去,或者是可能被绕过去。


如果用HTTP头,则更可靠了,所以总的来说,微软还是做了一件好事。

不过还是有一些指出缺陷的声音:
http://ha.ckers.org/blog/20090128/ie80-and-clickjacking/

noscript的作者也在叫嚷着说他那个才是最好的
http://hackademix.net/2009/01/28/ie8s-clickjacking-protection-exposed/


在我看来,IE8普及虽然需要些时间,但是值得期待。中肯的希望MS能在推广上走的更好。

此外还比较担忧的就是这种防御方案还是依赖于程序员的技能,无法做到 secure by default

Bless!

类别:象牙塔||添加到搜藏 |分享到i贴吧|浏览(1285)|评论 (0)
 
最近读者:
 
网友评论:
发表评论:
姓 名:
网址或邮箱: (选填)
内 容:
     

   
帮助中心 | 空间客服 | 投诉中心 | 空间协议
©2012 Baidu