x-frame-options
它能做什么
这个技能检查网站是否阻止其他网站把它的页面嵌入框架。它面向保护用户登录或执行操作的网站的开发者和安全人员。
适用场景
- ✓有登录或支付功能的网站没有框架保护响应头的时候。
- ✓安全扫描报告存在点击劫持风险的时候。
- ✓网站只应在自己的域名下被嵌入的时候。
技能链接
https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/x-frame-options/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 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: DENYto prevent all framing, orSAMEORIGINto allow framing only from your own domain ALLOWFROMis obsolete and unsupported in modern browsers — use CSPframe-ancestorsinstead- 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.
热度
- GitHub 星标
- 75k
- 排名
- #3091
- 许可证
- MIT
- 更新时间
- 2026/10/31
评论
- …
同一仓库的更多技能
frontendchecklist
75k使用命令行工具,依据 380 多条关于无障碍、速度、SEO 和安全的规则,检查前端代码和线上页面。
frontend-checklist-global
75k依据全部 386 条 Front-End Checklist 规则审查前端项目,并为发现的每个问题给出具体修复方法。
404-page
75k检查你的页面缺失提示是否提供有用的链接,并返回真正的 404 状态,帮助迷路的访客找到方向。
about-page
75k审查你的网站是否有清晰的关于页面,说明由谁运营,以建立访客和搜索引擎的信任。