Content Type Sniffing Vulnerability

Detects missing X-Content-Type-Options header and incorrect Content-Type that allows MIME sniffing attacks.

zakirkun Updated

File contents

Content Type Sniffing

Overview

Browsers that MIME-sniff responses can interpret uploaded files differently from the declared content type. An attacker uploads an HTML file disguised as an image, and the browser sniffs it as HTML and executes the embedded JavaScript.

X-Content-Type-Options: nosniff prevents this sniffing behavior.

Remediation

  • Set X-Content-Type-Options: nosniff on all responses
  • Always declare the correct Content-Type for served files
  • Do not serve user-uploaded content from the same origin as the application

zakirkun/ice-tea/tree/main/skills/web/content-type-sniffing commit 5746169c44

Frequently asked questions

npx skillmds@latest add zakirkun/content-type-sniffing-vulnerability