X-Content-Type-Options

X-Content-Type-Options

X-Content-Type-Options HTTP 消息头相当于一个提示标志,被服务器用来提示客户端一定要遵循在 Content-Type 首部中对 MIME 类型 的设定,而不能对其进行修改。这就禁用了客户端的 MIME 类型嗅探 行为,换句话说,也就是意味着网站管理员确定自己的设置没有问题。

该消息头最初是由微软在 IE 8 浏览器中引入的,提供给网站管理员用作禁用内容嗅探的手段,内容嗅探技术可能会把不可执行的 MIME 类型转变为可执行的 MIME 类型。在此之后,其他浏览器也相继引入了这个消息头,尽管它们的 MIME 嗅探算法没有那么有侵略性。

安全测试人员通常期望站点设置了该消息头。

注意:nosniff 只应用于 "script" 和 "style" 两种类型。事实证明,将其应用于图片类型的文件会导致与现有的站点冲突

Header type Response header
Forbidden header name no

语法

X-Content-Type-Options: nosniff Copy to Clipboard

指令

nosniff

下面两种情况的请求将被阻止:

  • 请求类型是"style" 但是 MIME 类型不是 "text/css",
  • 请求类型是"script" 但是 MIME 类型不是 JavaScript MIME 类型

规范

Specification
Fetch Standard
# x-content-type-options-header

浏览器兼容性

Report problems with this compatibility data on GitHub

  desktop mobile
  Chrome Edge Firefox Opera Safari Chrome Android Firefox for Android Opera Android Safari on iOS Samsung Internet WebView Android
X-Content-Type-Options

 

64

more

Toggle history

 

12

Toggle history

 

50

Toggle history

 

Yes

Toggle history

 

11

Toggle history

 

64

more

Toggle history

 

50

Toggle history

 

Yes

Toggle history

 

11

Toggle history

 

9.0

more

Toggle history

 

64

more

Toggle history

Legend

Tip: you can click/tap on a cell for more information.

Full support

Full support

Partial support

Partial support

 

Has more compatibility info.