SecurityResponse Header

X-Content-Type-Options

Prevents the browser from MIME-sniffing a response away from the declared Content-Type header, mitigating drive-by malware and MIME confusion attacks.

Recommended Production Value
Essential (A+)
nosniff

Production Server Implementation

NGINX Configuration Snippet
add_header X-Content-Type-Options "nosniff" always;

Directives & Syntax Breakdown

nosniff

Tells the browser to strictly trust the declared Content-Type header and reject executable files with mismatched MIME types.

Common Security Hazards & Pitfalls

  • β€’Ensure server configurations set accurate Content-Type headers for .js (text/javascript) and .css (text/css), or browsers will block them.
Frequently Asked Questions

X-Content-Type-Options - Questions & Answers

Common implementation questions, browser enforcement rules, and debugging.

If an attacker uploads a malicious script with an image extension (.jpg), a sniffing browser might execute it as HTML/JavaScript, leading to account takeover.