| 关键词: FRAME http Clickjacking OPTIONS 页面 contains 防御 page SAMEORIGIN directive |
对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 defaultBless! |
|
声明:文章版权归原作者所有 部分文章转自互联网 如有侵权请联系
[邮箱地址] 删除
|