Skip to content

Security headers

MIME sniffing protection

X-Content-Type-Options: nosniff stops browsers guessing a file's type, so an uploaded or served file can't be run as a script by mistake.

Scanetra rating: LowCheck HDR-03

Why it matters

Without it, a browser may decide that a file labelled as text or an image is really a script and run it. That turns file uploads and user content into a way to inject code.

What Scanetra looks for

  • An X-Content-Type-Options header with the value nosniff.

It reads only your homepage's public response. How a scan works

How to fix it

nginx

In the server block that serves HTTPS. The always flag also adds it to error pages.

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

Apache

Needs mod_headers. In the VirtualHost or .htaccess.

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

Cloudflare

Rules › Transform Rules › Modify Response Header: create a rule for all incoming requests that sets the static header X-Content-Type-Options to the value below.

nosniff

Vercel

In vercel.json at the root of the project.

{
  "headers": [
    {
      "source": "/(.*)",
      "headers": [{ "key": "X-Content-Type-Options", "value": "nosniff" }]
    }
  ]
}

Netlify

In a file named _headers in the publish directory.

/*
  X-Content-Type-Options: nosniff

Replace example.com with your own domain, and test changes on a staging copy first where you can.

Check that it worked

The response headers include X-Content-Type-Options with nosniff. Then scan again.

Check your own site

A free scan tells you whether your site passes this check, and the 24 others.

Scan a website