Content sniffing
Content sniffing is the process of using resource bytes and contextual metadata to determine a media type for processing.
Supplied versus computed: WHATWG distinguishes a supplied MIME type from the type computed for a resource. Sniffing rules depend on context, such as image loading versus browsing. The result selects an interpretation; it is not a full format-validation or integrity check. [1]
Historical evidence: Barth, Caballero and Song analyzed four browser implementations and compared their sniffers with upload filters. Their IEEE S&P 2009 paper identified interpretation disagreements and proposed avoiding privilege escalation and using prefix-disjoint signatures. Those findings concern historical implementations, not a measured vulnerability in current browsers. [2]
Storage consequence: Preserving identical object bytes does not preserve the HTTP processing contract when delivery metadata changes. Record and verify Content-Type separately from the checksum. RFC 9110 identifies Content-Type as a singleton; a comma-joined pair of types is not a valid list-valued alternative. [3]
Scope: Neither a filename extension nor a matched prefix proves the entire object is well formed. Correct type metadata, integrity verification and validation of the selected format answer different questions. Do not use a successful type guess as an archive-restore acceptance test. [3]
Relations
- related
- Media type, File signature, Object storage
Citations
- WHATWG MIME Sniffing: resource metadata, computed types and context-specific sniffing
- Barth, Caballero and Song (IEEE S&P 2009): Secure Content Sniffing for Web Browsers, sections 2-3
- RFC 9110, section 8.3: Content-Type
Further reading
Sources & caveats
- Primary-source synthesis of HTTP semantics, the WHATWG processing model and historical browser research; no new browser-security experiment or fleet measurement.