x-content-type
它能做什么
这个技能检查 Web 服务器是否发送 nosniff 安全响应头。它面向为网站加固、防范常见攻击的开发者和 IT 人员。
适用场景
- ✓服务器的响应中没有 X-Content-Type-Options 响应头的时候。
- ✓安全检查清单要求加固响应头的时候。
- ✓文件被上传后又提供给访客的时候。
技能链接
https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/x-content-type/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“我们的安全扫描说缺少 X-Content-Type-Options 响应头。请帮我添加吗?”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会在服务器或框架配置中为所有响应添加该响应头。然后它会检查响应头,确认该响应头已经存在。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Set X-Content-Type-Options: nosniff
Browsers that MIME-sniff can be tricked into executing malicious JavaScript uploaded as an image — even if the server sends Content-Type: image/png. nosniff forces the browser to honor the declared type.
Quick Reference
- Set
X-Content-Type-Options: nosniffon all responses — the only valid value isnosniff - Without this header, browsers may execute a JavaScript file disguised as an image if the server serves it with the wrong MIME type
- This header is required by OWASP's security hardening checklist and the Fetch specification
- Pair with correct
Content-Typeheaders on all responses for defense in depth - Takes 5 minutes to configure and has no compatibility issues
Check
Check whether the server sends an X-Content-Type-Options: nosniff header on responses. Verify the header is present on HTML pages, scripts, stylesheets, and API responses.
Fix
Add X-Content-Type-Options: nosniff to all HTTP responses. Configure it at the web server level (Nginx, Apache) or in your application framework, and verify with curl -I https://example.com.
Explain
Explain what MIME type sniffing is, how it can be exploited to execute malicious files, and how X-Content-Type-Options: nosniff prevents this attack.
Code Review
Review server config, headers, forms, and integration points related to Set X-Content-Type-Options: nosniff. 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-content-type
常见问题
nosniff 有什么作用?
它告诉浏览器信任声明的文件类型,而不是去猜测,从而避免运行有害文件。
会有兼容性问题吗?
这个技能说,该响应头没有已知的兼容性问题,几分钟即可设置完成。
如何检查它是否生效?
这个技能建议用 curl 请求检查响应头。
详情
作者的原始描述
Use when auditing HTTP response headers on any web server or CDN for security hardening.
热度
- GitHub 星标
- 75k
- 排名
- #3090
- 许可证
- MIT
- 更新时间
- 2026/10/31
评论
- …
同一仓库的更多技能
frontendchecklist
75k使用命令行工具,依据 380 多条关于无障碍、速度、SEO 和安全的规则,检查前端代码和线上页面。
frontend-checklist-global
75k依据全部 386 条 Front-End Checklist 规则审查前端项目,并为发现的每个问题给出具体修复方法。
404-page
75k检查你的页面缺失提示是否提供有用的链接,并返回真正的 404 状态,帮助迷路的访客找到方向。
about-page
75k审查你的网站是否有清晰的关于页面,说明由谁运营,以建立访客和搜索引擎的信任。