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

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。它会读取这个技能并按说明操作。

可直接粘贴的消息

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

可以这样问 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: nosniff on all responses — the only valid value is nosniff
  • 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-Type headers 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.

repo: thedaviddias/Front-End-Checklist

热度

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

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能