Skip to content

Kompile Learn

X-Content-Type-Options: nosniff

Stop browsers from guessing file types, so an uploaded file is never run as a script.

What it is

Browsers sometimes ignore the declared content type and guess ("sniff") what a file is. nosniff turns that off.

Why it matters

If a user can upload a file that the browser decides is JavaScript, it may run on your site with your visitors' sessions.

How to fix it

nginx

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

Apache

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

Express

app.use(helmet.noSniff());

Does your site have this problem?

Kompile Scan checks for this and the other problems in these guides in under a minute. Free for one site.

Check my site