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

hsts

它能做什么

这项技能检查网站是否告诉浏览器始终使用其安全的 HTTPS 连接。适用于希望为访客提供更强保护的网站所有者和开发者。

适用场景

  • ✓当你的网站提供 HTTPS,但浏览器仍可能先尝试普通 HTTP 的时候。
  • ✓当你运营处理登录或个人数据的网站的时候。
  • ✓当你配置新的服务器、CDN 或托管环境的时候。

技能链接

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

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

使用方法

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

可直接粘贴的消息

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

可以这样问 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; includeSubDomains on all HTTPS responses
  • Use max-age=31536000 (1 year) minimum; HSTS preloading requires at least 1 year
  • Add includeSubDomains to protect all subdomains from downgrade attacks
  • Add preload only 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.

Rule page: https://frontendchecklist.io/rules/security/hsts

常见问题

HSTS 有什么作用?

它告诉浏览器自动对该网站使用 HTTPS,从而阻止在第一次普通请求时发生的降级攻击。

includeSubDomains 有什么作用?

它将同样的保护应用到该网站的所有子域名。

为什么对 preload 要小心?

这项技能指出,preload 很难撤销,并且需要数周才会生效,因此应先进行测试。

详情

作者的原始描述

Use when reviewing HTTP response headers on any site that serves content over HTTPS.

repo: thedaviddias/Front-End-Checklist

热度

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

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能