跳到正文
Skillpedia
安全75k · #3091

x-frame-options

它能做什么

这个技能检查网站是否阻止其他网站把它的页面嵌入框架。它面向保护用户登录或执行操作的网站的开发者和安全人员。

适用场景

  • ✓有登录或支付功能的网站没有框架保护响应头的时候。
  • ✓安全扫描报告存在点击劫持风险的时候。
  • ✓网站只应在自己的域名下被嵌入的时候。

技能链接

https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/x-frame-options/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/x-frame-options/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“安全扫描说我的登录页面可能被放进别的网站的框架里。请帮我阻止这种情况吗?”

每周 5 个新技能,1 分钟读完。

工作原理

智能体会添加一个阻止其他网站嵌入页面的响应头,或将嵌入限制在同一域名内。它还可以建议使用较新的 CSP frame-ancestors 设置。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Set an X-Frame-Options header

Without framing protection, an attacker can embed your banking login page in a transparent iframe on a malicious site and trick users into clicking buttons they cannot see — transferring money, changing settings, or leaking credentials.

Quick Reference

  • Use X-Frame-Options: DENY to prevent all framing, or SAMEORIGIN to allow framing only from your own domain
  • ALLOWFROM is obsolete and unsupported in modern browsers — use CSP frame-ancestors instead
  • The modern equivalent is Content-Security-Policy: frame-ancestors 'none' — prefer CSP for new sites
  • Both headers can coexist: X-Frame-Options for older browsers, frame-ancestors for modern ones
  • Clickjacking attacks trick users into clicking invisible iframe buttons — DENY eliminates this entirely

Check

Check whether the server sends an X-Frame-Options header (DENY or SAMEORIGIN) or a Content-Security-Policy header with frame-ancestors directive to prevent clickjacking.

Fix

Add X-Frame-Options: DENY to all responses if the site does not need to be embedded anywhere. If legitimate framing is needed on the same origin, use SAMEORIGIN. For fine-grained control, use CSP frame-ancestors instead.

Explain

Explain what a clickjacking attack is, how X-Frame-Options and CSP frame-ancestors prevent it, and the difference between DENY and SAMEORIGIN values.

Code Review

Review server config, headers, forms, and integration points related to Set an X-Frame-Options header. Flag exact responses, cookies, or browser behaviors that violate the rule, and verify them against the effective production-like response.


For full implementation details, code examples, and framework-specific guidance, see references/rule.md.

Rule page: https://frontendchecklist.io/rules/security/x-frame-options

常见问题

什么是点击劫持?

这是一种攻击,恶意网站通过隐藏的框架诱骗用户点击他们看不见的按钮。

DENY 和 SAMEORIGIN 有什么区别?

DENY 阻止所有嵌入,而 SAMEORIGIN 只允许来自你自己域名的嵌入。

ALLOWFROM 还受支持吗?

不再支持。这个技能说,它已过时,现代浏览器不再支持。

详情

作者的原始描述

Use when reviewing HTTP response headers for clickjacking protection on any web application with authenticated user actions.

repo: thedaviddias/Front-End-Checklist

热度

GitHub 星标
75k
排名
#3091
许可证
MIT
更新时间
2026/10/31

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能