Glossary / X-Content-Type-Options

X-Content-Type-Options

X-Content-Type-Options is an HTTP header whose only value, nosniff, stops the browser from guessing a file's type against what the server declared. The browser trusts the Content-Type header, not the file's contents. This closes attacks where an innocent-looking file is served and then run as an executable script.

Check your site

>

By default browsers do MIME sniffing: if a file's declared type looks wrong, they try to work out the real type from its bytes. Convenient, but risky. A file a user uploaded as an image might get executed as JavaScript if it contains code.

The nosniff value turns that guessing off. If the server says a file is text/plain or image/png, the browser treats it exactly that way, even if the bytes look like a script or HTML.

The header matters most for sites that accept user uploads or serve files from shared storage. There is only one value, nosniff, and no alternatives, so configuring it is simply on or off.

Example

X-Content-Type-Options: nosniff

Common mistakes

Related terms

Found problems?

Slow hosting, SSL trouble or frequent downtime? Move to TomisHost: fast hosting with free SSL, daily backups and free migration help.

TomisHost hosting