X-Content-Type-Options Header Missing

Responses do not carry the X-Content-Type-Options: nosniff header, so browsers may guess a response's content type instead of relying on the declared one.

SeverityInformational
CVSS 3.10 CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:N/I:N/A:N Open in the calculator
CVSS 4.00 CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:P/VC:N/VI:N/VA:N/SC:N/SI:N/SA:N Open in the calculator
CWECWE-693: Protection Mechanism Failure
OWASP Top 10A06:2025 Insecure Design
CategorySecurity Misconfiguration

Description

The application does not send the X-Content-Type-Options: nosniff response header. Without it, browsers may examine a response's content to decide how to handle it, known as MIME sniffing, where the Content-Type header is missing, generic or inconsistent with the content, and may then treat the response as a different type from the one the server intended, for example rendering an uploaded text file that contains markup as HTML.

With nosniff, the browser uses the declared type without examining the content, refuses to run a response as script or apply it as a stylesheet unless it has a JavaScript or CSS media type, and does not treat a non-HTML response as a page. Current browsers sniff in fewer circumstances than older ones did, so the header mainly closes remaining edge cases and protects users of older browsers.

The missing header has no direct impact, but it can contribute to an attack where the application serves content an attacker controls with a missing or imprecise content type: a browser that sniffs that content as HTML or script could run the attacker's script in the application's origin, resulting in cross-site scripting. The issue is therefore most relevant where the application serves files uploaded by users or returns user-controlled data with an imprecise content type, and the header adds little where every response carries an accurate Content-Type and uploaded files are served from a separate domain or as downloads.

The issue is identified by inspecting response headers, and scanners report it as a missing security header.

Remediation

Send X-Content-Type-Options: nosniff on every response, and make sure each response declares the correct Content-Type, with a charset for text types, because once sniffing is disabled a wrongly labelled resource will stop working.

nginx: add_header X-Content-Type-Options "nosniff" always; Apache (mod_headers): Header always set X-Content-Type-Options "nosniff" IIS (web.config, within system.webServer): <httpProtocol> <customHeaders> <add name="X-Content-Type-Options" value="nosniff" /> </customHeaders> </httpProtocol>

Serve files uploaded by users with an explicit, safe content type and, where they need not be displayed in the browser, with Content-Disposition: attachment, ideally from a separate domain. Confirm the fix by checking that the header is present on HTML, script, stylesheet and file download responses.

References


Add This Finding to Your Library

In Pental this write-up is in Settings, Library. Add to my library copies it into your own, rated in your firm's CVSS version, ready to put in your own words.

Free trial  ·  No card required

Only need the reporting? Our reporting tool is free and open source, with the same library.


More Web Applications Findings

Every Web Applications finding