hsts
它能做什么
这项技能检查网站是否告诉浏览器始终使用其安全的 HTTPS 连接。适用于希望为访客提供更强保护的网站所有者和开发者。
适用场景
- ✓当你的网站提供 HTTPS,但浏览器仍可能先尝试普通 HTTP 的时候。
- ✓当你运营处理登录或个人数据的网站的时候。
- ✓当你配置新的服务器、CDN 或托管环境的时候。
技能链接
https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/hsts/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请把 HSTS 标头添加到我网站的安全响应中。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会检查 HTTPS 响应是否包含 Strict-Transport-Security 标头,并检查其设置。它会建议设置为一年的 max-age 并包含子域名,并在任何预加载之前先进行测试。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Set an HSTS header
Without HSTS, an attacker on the same network can intercept the first HTTP request and strip TLS (SSL stripping), silently downgrading the connection before the browser ever sees a redirect.
Quick Reference
- Set
Strict-Transport-Security: max-age=31536000; includeSubDomainson all HTTPS responses - Use
max-age=31536000(1 year) minimum; HSTS preloading requires at least 1 year - Add
includeSubDomainsto protect all subdomains from downgrade attacks - Add
preloadonly after testing — it is difficult to reverse and takes weeks to propagate - Never send the HSTS header over plain HTTP — only over HTTPS
Check
Check whether the server sends a Strict-Transport-Security header on all HTTPS responses, and verify the max-age, includeSubDomains, and preload directives are appropriate.
Fix
Add a Strict-Transport-Security header with max-age=31536000 and includeSubDomains to all HTTPS responses. Configure your web server or CDN to send this header, and validate it with curl or securityheaders.com.
Explain
Explain what HTTP Strict Transport Security (HSTS) is, how it prevents SSL stripping attacks, what the max-age and includeSubDomains directives do, and why the preload directive requires caution.
Code Review
Review server config, headers, forms, and integration points related to Set an HSTS 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.
常见问题
HSTS 有什么作用?
它告诉浏览器自动对该网站使用 HTTPS,从而阻止在第一次普通请求时发生的降级攻击。
includeSubDomains 有什么作用?
它将同样的保护应用到该网站的所有子域名。
为什么对 preload 要小心?
这项技能指出,preload 很难撤销,并且需要数周才会生效,因此应先进行测试。
详情
作者的原始描述
Use when reviewing HTTP response headers on any site that serves content over HTTPS.
热度
- GitHub 星标
- 75k
- 排名
- #2870
- 许可证
- MIT
- 更新时间
- 2026/10/31
评论
- …
同一仓库的更多技能
frontendchecklist
75k使用命令行工具,依据 380 多条关于无障碍、速度、SEO 和安全的规则,检查前端代码和线上页面。
frontend-checklist-global
75k依据全部 386 条 Front-End Checklist 规则审查前端项目,并为发现的每个问题给出具体修复方法。
404-page
75k检查你的页面缺失提示是否提供有用的链接,并返回真正的 404 状态,帮助迷路的访客找到方向。
about-page
75k审查你的网站是否有清晰的关于页面,说明由谁运营,以建立访客和搜索引擎的信任。