DELAPARRA
Index
Color
NL
Category: HTTP headers

X-Content-Type-Options

Explained by Updated

What is X-Content-Type-Options?

X-Content-Type-Options: Set to "nosniff" to prevent the browser from guessing a different content type than the server declared. X-Content-Type-Options: nosniff tells browsers to trust the Content-Type the server sends, instead of guessing the type from the content. Without it, a browser might treat an uploaded text file that contains HTML or JavaScript as a web page or script, and run it. That can turn a harmless file upload into a cross-site scripting vulnerability.

Definition source Coders Lingo, CC BY 4.0

Frequently asked questions about X-Content-Type-Options

What should you keep in mind with X-Content-Type-Options?

It is one of the simplest security headers: one fixed value, no configuration and practically no downside. Add it to every response, through your web server or framework middleware. It only works if your server sends correct content types, so make sure uploaded files and API responses have accurate Content-Type headers. Together with a Content-Security-Policy, it closes several common routes for script injection.

What does an example of X-Content-Type-Options look like?

X-Content-Type-Options: nosniff

At a glance

CategoryHTTP headers
Explained by
Updated

More HTTP headers terms

All terms starting with X

Skills

Download all skills (zip)

Manuals

Related services

Need any help?

Stuck on one of these in your own project? Tell me what you are working on and I will tell you how I would approach it.