Skip to content
Vol. 1 · Ed. 2026
CyberGlossary
Entry № 681

MIME Sniffing

What is MIME Sniffing?

MIME SniffingBrowser behaviour of guessing a response's content type from its bytes, which can be exploited to execute uploaded files as scripts.


MIME sniffing is a legacy browser feature in which the browser inspects the first bytes of a response and overrides the server-declared Content-Type header to render the resource more usefully. Attackers abuse this when an application serves user-uploaded files with an incorrect type: a file containing HTML or JavaScript may be sniffed as text/html and executed in the victim's origin, enabling stored XSS. The standard mitigation is to send the response header X-Content-Type-Options: nosniff, which forces the browser to respect the declared type. Combine with strict Content-Type values, CSP, and serving user content from a separate origin.

Examples

  1. 01

    X-Content-Type-Options: nosniff

  2. 02

    An avatar upload endpoint that returns image/png but the file is HTML; without nosniff, browsers execute it as a page.

Frequently asked questions

What is MIME Sniffing?

Browser behaviour of guessing a response's content type from its bytes, which can be exploited to execute uploaded files as scripts. It belongs to the Application Security category of cybersecurity.

What does MIME Sniffing mean?

Browser behaviour of guessing a response's content type from its bytes, which can be exploited to execute uploaded files as scripts.

How does MIME Sniffing work?

MIME sniffing is a legacy browser feature in which the browser inspects the first bytes of a response and overrides the server-declared Content-Type header to render the resource more usefully. Attackers abuse this when an application serves user-uploaded files with an incorrect type: a file containing HTML or JavaScript may be sniffed as text/html and executed in the victim's origin, enabling stored XSS. The standard mitigation is to send the response header X-Content-Type-Options: nosniff, which forces the browser to respect the declared type. Combine with strict Content-Type values, CSP, and serving user content from a separate origin.

How do you defend against MIME Sniffing?

Defences for MIME Sniffing typically combine technical controls and operational practices, as detailed in the full definition above.

Related terms