X-Frame-Options 标头在防止恶意框架方面有多有用?

发布于 2024-09-25 16:25:43 字数 149 浏览 0 评论 0 原文

X-Frame-Options DENY 添加到响应标头有助于防止网页的恶意框架,作为一种解决方案,它肯定比客户端 JavaScript 解决方案更好。

但它到底有多有用呢?所有(现代)浏览器都支持它,意图劫持您网站的黑客是否可以绕过它?

Adding the X-Frame-Options DENY to the response header helps protect against malicious framing of the web page and as a solution it's certainly better that client-side JavaScript solutions.

But just how useful is it? Is is supported by all (modern) browsers and can it be bypassed by hackers intent on hijacking your site?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

红颜悴 2024-10-02 16:25:43

EricLaw 的页面 维护支持浏览器的列表。

目前主流桌面浏览器版本均支持;旧版本和利基市场,而某些移动浏览器则没有。因此,您可能还想包含一个反框架

当您想要有选择地允许框架时,您可能更喜欢使用脚本方法而不是 X-Frame-Options。 X-Frame-Options 不允许“白名单”,因此您不能允许 Google 图片流量但不允许其他流量。

无论哪种方式,IE6-7 仍然允许攻击者构建您的页面并禁用框架破坏程序。不幸的是,有问题的

EricLaw's page maintains a list of supporting browsers.

Current verions of the major desktop browsers all support it; older versions and niche and some mobile browsers don't. So you will probably want to include an anti-framing <script> as well, to set top.location (and remove the page content first in case of anti-frame-busting; see this question for why).

You might prefer the script approach to X-Frame-Options when you want to selectively allow framing. X-Frame-Options does not permit ‘whitelisting’, so you can't eg allow Google Images traffic but not others.

Either way, IE6-7 will still allow attackers to frame your page and disable the frame-buster. Unfortunately the questionable <iframe security> attribute existed before X-Frame-Options. You could try adding <base target="_top"> to try to make any navigation break out traditional framing (or just not work, in the presence of anti-frame-busters), but this can't help you against invisible-iframe-overlay attacks.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文