Skip to main content
HeadersMedium PriorityFree

X-Content-Type-Options header

Updated November 2026·SecScanner Team

This header prevents browsers from MIME-sniffing a response away from the declared content-type, stopping certain attack vectors.

41% of the 101 most-visited sites we scan fail this check. See the full data.

Results in 1–3 minutes · Free · No signup required

Want the result for your own site? Free Security Headers Checker — paste your domain, get the report.

Why It Matters

Without nosniff, browsers might interpret files differently than intended, potentially executing malicious content. This is especially dangerous for user-uploaded files.

How We Check

We verify the presence of `X-Content-Type-Options: nosniff` header on your responses.

Good vs Bad Values

Good and bad values for X-Content-Type-Options header
ValueVerdictWhy
X-Content-Type-Options: nosniffGoodThe only defined value. The browser trusts the declared Content-Type and refuses to run a response as script or style when the type does not match.
X-Content-Type-Options: NOSNIFFGoodThe value is case-insensitive, so this works the same. Keep it lowercase to avoid confusion in audits.
nosniff on every response, including static files and error pagesGoodConsistent coverage matters: uploaded files, JSON endpoints and 404 pages are the responses most likely to be abused.
X-Content-Type-Options: nosniff, nosniffWeakTwo layers (app and proxy) each added the header and they were merged. Browsers cope with it, but the scanner needs the exact value, so deduplicate the header.
X-Content-Type-Options: sniffBadThere is no such value. The header is ignored and the browser sniffs as usual.
X-Content-Type-Options: no-sniffBadA common typo. Only `nosniff` is recognized, so protection is silently off.
X-Content-Type-Options: 1BadCopied from the X-XSS-Protection pattern. It is not a valid value and has no effect.
Header missingBadBrowsers may guess the type of a response, so a file served as an image or text can still execute as script or be applied as a stylesheet.

How to Fix

Add the header: X-Content-Type-Options: nosniff. This should be set on all responses and has no drawbacks.

Nginx — in the server block, repeating it in any location that defines its own add_header:

add_header X-Content-Type-Options "nosniff" always;

Apache (requires mod_headers):

Header always set X-Content-Type-Options "nosniff"

Next.js — next.config.js:

module.exports = {
  async headers() {
    return [{
      source: "/(.*)",
      headers: [{ key: "X-Content-Type-Options", value: "nosniff" }],
    }];
  },
};

Caddy: header X-Content-Type-Options nosniff. IIS (web.config): add <add name="X-Content-Type-Options" value="nosniff" /> under <system.webServer><httpProtocol><customHeaders>. Cloudflare: Rules → Transform Rules → Modify Response Header → set a static header on all requests.

Before you enable it, audit MIME types. Run curl -sI https://example.com/app.js | grep -i content-type for your main script, stylesheet and font files. Scripts should be text/javascript (or application/javascript), CSS text/css, JSON application/json. Fix the server's mime.types or the framework's static handler first, otherwise nosniff will expose the mismatch as broken pages.

Verify with curl -sI https://example.com | grep -i x-content-type-options and repeat for a static asset, an API route and a 404 URL.

Common Mistakes

  • Adding the header at the proxy but not at the application, so cached or directly reachable endpoints return without it. Check the response a visitor actually receives.
  • Enabling `nosniff` while serving JavaScript as `text/plain` or `application/octet-stream`. With nosniff the browser blocks those scripts, so correct MIME types come first.
  • Serving user uploads from the main origin with a guessed or generic type. Serve uploads from a separate cookieless domain, send `Content-Disposition: attachment` for downloads, and keep nosniff on.
  • Using `add_header` inside a `location` block in Nginx and losing the server-level header. Any `add_header` in a block cancels inherited ones.
  • Believing nosniff stops XSS by itself. It closes the MIME-confusion route only; it does not replace output escaping or a Content-Security-Policy.
  • Forgetting stylesheets: with nosniff, a `<link rel=stylesheet>` whose response is not `text/css` is rejected, so a misconfigured static server can suddenly unstyle a site.

Frequently Asked Questions

What is X-Content-Type-Options header?

This header prevents browsers from MIME-sniffing a response away from the declared content-type, stopping certain attack vectors.

Why does X-Content-Type-Options header matter for website security?

Without nosniff, browsers might interpret files differently than intended, potentially executing malicious content. This is especially dangerous for user-uploaded files.

How do I fix X-Content-Type-Options header issues?

Add the header: X-Content-Type-Options: nosniff. This should be set on all responses and has no drawbacks.

Related Security Checks

Related Tool

Security Headers Checker

Run all 10 related checks with our free security headers checker

Check Your Website Now

Run a free security scan to check for X-Content-Type-Options header issues and 61 other security checks.

Scan Your Website Free