Cybersecurity glossary

What is X-Content-Type-Options?

Learn what the X-Content-Type-Options header does, why nosniff prevents MIME sniffing attacks, how it reduces XSS risk from mislabeled files, and how to deploy it.

Web platform securityUpdated July 20, 2026
Also known asnosniff headerX-Content-Type-Options nosniffMIME sniffing protection

Definition

X-Content-Type-Options is an HTTP response header whose nosniff value tells browsers to respect the declared Content-Type and not MIME-sniff responses into a different type—reducing certain XSS and content confusion attacks.

Why MIME sniffing was a problem

Servers sometimes mislabel responses. Browsers tried to be helpful by sniffing content. Attackers abused that help: upload a file the server calls text/plain, and a sniffing browser might treat it as HTML or JavaScript.

X-Content-Type-Options: nosniff turns off that guesswork for relevant contexts.

How nosniff helps

1

Server sends a response

Includes Content-Type and X-Content-Type-Options: nosniff.

2

Browser skips MIME guessing

It trusts the declared type for script/style execution decisions.

3

Mislabeled scripts fail safely

Non-script types are less likely to execute as script via sniffing.

Practical deployment

ItemGuidance
Header valueX-Content-Type-Options: nosniff
ScopeSite-wide via reverse proxy or app middleware
Pair withCorrect Content-Type, CSP, download disposition for uploads
TestingSecurity header scanners and browser behavior checks

User uploads

Especially important when serving user files from your origin.

APIs returning text

Avoid accidental HTML interpretation of API payloads in browsers.

Legacy apps

Easy win while larger XSS remediations proceed.

Baseline hygiene

Part of the standard secure-headers bundle.

  • Send X-Content-Type-Options: nosniff on all relevant responses.
  • Set accurate Content-Type values for every content class.
  • Serve untrusted uploads with safe types and Content-Disposition when appropriate.
  • Combine with CSP for stronger XSS containment.
  • Verify via header scanners in CI or staging.
  • Do not rely on nosniff alone for upload security.
  • Document header ownership in platform/reverse-proxy config.
  • Re-check after CDN or gateway changes that might strip headers.

The practical takeaway

X-Content-Type-Options: nosniff tells browsers to stop MIME-guessing and respect your Content-Type. It is a simple, high-value header that reduces a classic class of content-confusion bugs.

Enable it everywhere, then keep fixing the root XSS and upload issues it cannot solve alone.

Related security terms

Frequently asked questions

What does X-Content-Type-Options: nosniff do?

It tells the browser not to guess a different MIME type than the server declared, which helps block some script execution via mislabeled responses.

What is MIME sniffing?

Browsers historically inspected response bytes to “fix” incorrect Content-Type headers, sometimes treating non-script responses as executable script.

Should every site send nosniff?

Yes for modern sites. It is a low-risk, widely recommended baseline security header.

Does nosniff replace correct Content-Type headers?

No. Always set accurate Content-Type values; nosniff enforces them more strictly.

Is nosniff enough to stop XSS?

No. It closes specific confusion bugs. You still need encoding, CSP, and safe frameworks.

Where should the header be set?

On HTML documents and especially on user-controlled or downloadable content responses served from your origin.

References

Explore authoritative guidance and frameworks related to x-content-type-options.

Explore every security definition

Return to the glossary to search by term, alias, starting letter, or security category.

Browse glossary