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

referrer-policy

它能做什么

这个技能检查网站发送的响应头,并设置 Referrer-Policy,限制与其他网站共享的地址信息。它面向希望保护敏感链接和令牌的开发者。

适用场景

  • ✓你请智能体检查网站安全响应头的时候。
  • ✓你的页面网址中包含私密令牌或 ID,而你想防止它们泄露的时候。
  • ✓你在加固处理登录或会话的应用的时候。

技能链接

https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/referrer-policy/SKILL.md

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

使用方法

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

可直接粘贴的消息

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

可以这样问 AI

“我的密码重置链接中带有令牌。请帮我确保访客点击链接时,这些令牌不会泄露给其他网站吗?”

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

工作原理

智能体会检查是否已发送 Referrer-Policy 响应头,并将其设为推荐的默认值 strict-origin-when-cross-origin。对于特别敏感的地址页面,它会建议更严格的设置。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Set a Referrer-Policy header

Without a Referrer-Policy, a password reset link like https://example.com/reset?token=abc123 is included in the Referer header when the user clicks an external link on that page — leaking the token to third parties.

Quick Reference

  • Use Referrer-Policy: strict-origin-when-cross-origin — the recommended modern default
  • strict-origin-when-cross-origin sends the full URL for same-origin requests, only the origin for cross-origin HTTPS, and nothing for HTTPS→HTTP
  • Never use unsafe-url — it sends the full URL including path and query string to every external site
  • Can be set via HTTP header, <meta> tag, or the referrerpolicy attribute on individual <a> and <img> elements
  • Sensitive URLs (reset tokens, private IDs) in query strings can be exposed via the Referer header if policy is too permissive

Check

Check whether the server sends a Referrer-Policy header and verify the value is appropriate. The recommended value is strict-origin-when-cross-origin. Check for any pages with sensitive URL parameters that could be leaked via the Referer header.

Fix

Add Referrer-Policy: strict-origin-when-cross-origin to all HTTP responses. Configure it in your web server, CDN, or application framework. For pages with particularly sensitive URLs, consider no-referrer or same-origin.

Explain

Explain what the Referer header contains, how a permissive Referrer-Policy can leak sensitive URL parameters to third parties, and what the difference is between the various Referrer-Policy values.

Code Review

Review server config, headers, forms, and integration points related to Set a Referrer-Policy 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/referrer-policy

常见问题

strict-origin-when-cross-origin 有什么作用?

它会把完整地址发送给你自己的网站,对其他 HTTPS 网站只发送网站名称,而从 HTTPS 切换到 HTTP 时则不发送任何内容。

为什么应该避免 unsafe-url?

这个技能说,它会把包括路径和查询参数在内的完整地址发送给每个外部网站。

这个策略还能在哪里设置?

这个技能说,也可以通过 meta 标签设置,或针对单个链接和图片设置。

详情

作者的原始描述

Use when reviewing HTTP response headers for privacy hardening on any website that handles authentication, session state, or sensitive URL parameters.

repo: thedaviddias/Front-End-Checklist

热度

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

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能