new-tab
它能做什么
这项技能检查在新标签页中打开的链接,确保它们带有能阻止常见标签页劫持攻击的安全属性。适用于检查 HTML 或 JSX 代码的开发者。
适用场景
- ✓当你请智能体为安全性检查在新标签页中打开的链接的时候。
- ✓当你在检查会在新标签页中打开外部链接的代码的时候。
- ✓当你添加 lint 规则,使每个在新标签页中打开的链接都能被自动检查的时候。
技能链接
https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/new-tab/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请帮我检查网站上每个在新标签页中打开的链接,是否都有正确的安全属性。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会找到在新标签页中打开的 a 元素,并检查每个元素是否带有 rel noopener noreferrer,至少要有 noopener。它会补上缺少的属性,并可以建议添加 lint 规则,防止以后出现遗漏。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
External Link Security
A malicious site opened via target='_blank' can use window.opener.location to silently redirect your original tab to a phishing page — the user switches back and sees a fake login screen on what appears to be your domain.
Quick Reference
- Always add
rel="noopener noreferrer"to any<a target="_blank">link noopenerprevents the new tab from accessingwindow.openerand redirecting your pagenoreferreradditionally suppresses theRefererheader sent to the destination site- Modern browsers (Chrome 88+, Firefox 79+) implicitly add
noopenerfor cross-origin_blanklinks, but explicit markup is required for older browsers and same-origin links - ESLint rule
jsx-a11y/anchor-is-validandeslint-plugin-securitycan enforce this automatically
Check
Find all anchor elements with target='_blank' in the HTML and JSX source. Verify each one includes rel='noopener noreferrer' (or at minimum rel='noopener'). Flag any external links opening in a new tab that are missing this attribute.
Fix
Add rel='noopener noreferrer' to all <a target='_blank'> elements. In React/JSX this is rel="noopener noreferrer". Configure an ESLint rule to prevent this from recurring.
Explain
Explain the reverse tabnapping attack enabled by window.opener, how rel='noopener' and rel='noreferrer' prevent it, and the difference between the two values.
Code Review
Review server config, headers, forms, and integration points related to External Link Security. 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/new-tab
常见问题
什么是反向标签页劫持?
这是一种攻击方式:新标签页利用 window.opener 悄悄把你原来的标签页导向一个假页面。
noreferrer 有什么作用?
它会阻止浏览器把 Referer 标头发送给目标网站。
现代浏览器不是已经能保护我吗?
有些浏览器对跨域链接已有保护,但这项技能指出,对于旧浏览器和同源链接,仍需要明确的标记。
详情
作者的原始描述
Use when reviewing HTML or JSX for anchor elements with target='_blank' to verify rel='noopener noreferrer' is present.
热度
- GitHub 星标
- 75k
- 排名
- #2949
- 许可证
- MIT
- 更新时间
- 2026/10/31
评论
- …
同一仓库的更多技能
frontendchecklist
75k使用命令行工具,依据 380 多条关于无障碍、速度、SEO 和安全的规则,检查前端代码和线上页面。
frontend-checklist-global
75k依据全部 386 条 Front-End Checklist 规则审查前端项目,并为发现的每个问题给出具体修复方法。
404-page
75k检查你的页面缺失提示是否提供有用的链接,并返回真正的 404 状态,帮助迷路的访客找到方向。
about-page
75k审查你的网站是否有清晰的关于页面,说明由谁运营,以建立访客和搜索引擎的信任。