Set X-Content-Type-Options: nosniff
Updated 1 Dec 2026
What it means
Browsers may guess ("sniff") the type of files you serve. An uploaded file that looks like a script can then be executed as one.
Why it matters
Increases the chance that user uploads or third-party files become a cross-site scripting vector.
How to fix it
- Add the header X-Content-Type-Options: nosniff to all responses.
- Make sure every response sends a correct Content-Type.
Configuration examples
nginx
add_header X-Content-Type-Options "nosniff" always;
Apache
Header always set X-Content-Type-Options "nosniff"
IIS (web.config)
<add name="X-Content-Type-Options" value="nosniff" />
Cloudflare
Rules -> Transform Rules -> Modify Response Header -> Set static: X-Content-Type-Options = nosniff
Node.js / Express
app.use(helmet.noSniff());
Django (settings.py)
SECURE_CONTENT_TYPE_NOSNIFF = True
Laravel / PHP
$response->headers->set('X-Content-Type-Options', 'nosniff');
Any platform
X-Content-Type-Options: nosniff
Check your fix
curl -sI https://YOUR_DOMAIN | grep -i x-content-type-options
References
- https://developer.mozilla.org/docs/Web/HTTP/Headers/X-Content-Type-Options