MIME Types and Browser Security

Browsers enforce MIME types as part of their security model. MIME sniffing risks, X-Content-Type-Options: nosniff, CSP script-src, and cross-origin font CORS rules.

ZERO UPLOAD · ALL LOCAL
  1. Type a MIME string (e.g. application/json), file extension (e.g. .wasm), or keyword (e.g. "protobuf") to search the database.
  2. Use the category pills (Application, Audio, Font, Image, Model, Text, Video, Multipart) to browse all types in a category.
  3. Click Details on any card to expand the description, spec link, and server configuration snippets in a full-width panel.
  4. Click Copy next to any snippet block to copy the Nginx, Apache, .htaccess, or Caddy directive to your clipboard.

Browser MIME enforcement mechanisms

  • MIME sniffing browser inspects response bytes to guess the real type when Content-Type is missing or generic
  • X-Content-Type-Options: nosniff tells the browser to trust the declared Content-Type exactly
  • Cross-origin fonts require Access-Control-Allow-Origin regardless of MIME type — failures are silent
  • Subresource Integrity checks a content hash after the MIME type check passes, not instead of it

APPLICATION (100 types)

application/json
.json
application/xml
.xml .xsl .xslt
application/pdf
.pdf
application/wasm
.wasm
application/javascript
.js .mjs .cjs
application/zip
.zip
application/gzip
.gz .tgz
application/x-tar
.tar
application/x-7z-compressed
.7z
application/vnd.rar
.rar
application/x-bzip2
.bz2
application/vnd.openxmlformats-officedocument.wordprocessingml.document
.docx
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
.xlsx
application/vnd.openxmlformats-officedocument.presentationml.presentation
.pptx
application/msword
.doc
application/vnd.ms-excel
.xls
application/vnd.ms-powerpoint
.ppt
application/octet-stream
.bin .exe .dll
application/x-www-form-urlencoded
application/cbor
.cbor
application/x-protobuf
.proto .pb
application/grpc
application/graphql-response+json
application/vnd.api+json
application/ld+json
.jsonld
application/hal+json
application/jwt
application/manifest+json
.webmanifest
application/rtf
.rtf
application/problem+json
application/json-patch+json
application/merge-patch+json
application/vnd.geo+json
.geojson
application/yaml
.yaml .yml
application/sql
.sql
application/epub+zip
.epub
application/java-archive
.jar
application/vnd.oasis.opendocument.text
.odt
application/vnd.oasis.opendocument.spreadsheet
.ods
application/vnd.oasis.opendocument.presentation
.odp
application/x-ndjson
.ndjson .jsonl
application/vnd.apple.mpegurl
.m3u8
application/dash+xml
.mpd
application/rss+xml
.rss
application/atom+xml
.atom
application/x-apple-diskimage
.dmg
application/x-debian-package
.deb
application/x-rpm
.rpm
application/x-sh
.sh
application/ecmascript
application/toml
.toml
application/zstd
.zst
application/x-xz
.xz
application/x-bzip
.bz
application/x-lzma
.lzma
application/x-iso9660-image
.iso
application/vnd.ms-cab-compressed
.cab
application/vnd.android.package-archive
.apk
application/x-msdownload
.msi
application/vnd.apple.installer+xml
.mpkg
application/x-httpd-cgi
.cgi
application/vnd.google-earth.kml+xml
.kml
application/vnd.google-earth.kmz
.kmz
application/vnd.sqlite3
.sqlite .sqlite3 .db
application/msgpack
.msgpack
application/schema+json
application/wsdl+xml
.wsdl
application/jose+json
application/x-pkcs12
.p12 .pfx
application/pkix-cert
.cer .der
application/x-pem-file
.pem .crt .key
application/pkcs8
.p8
application/pkcs10
.p10 .csr
application/postscript
.ps .eps .ai
application/x-latex
.latex .ltx
application/x-tex
.tex
application/x-dvi
.dvi
application/fits
.fits .fit .fts
application/vnd.oasis.opendocument.graphics
.odg
application/vnd.oasis.opendocument.chart
.odc
application/vnd.oasis.opendocument.formula
.odf
application/vnd.ms-project
.mpp .mpt
application/vnd.visio
.vsd .vst .vss .vsw
application/vnd.ms-access
.mdb
application/vnd.openxmlformats-officedocument.wordprocessingml.template
.dotx
application/vnd.ms-word.document.macroenabled.12
.docm
application/vnd.ms-excel.sheet.macroenabled.12
.xlsm
application/vnd.apple.pages
.pages
application/vnd.apple.numbers
.numbers
application/vnd.apple.keynote
.key
application/typescript
.ts
application/x-perl
.pl .pm
application/x-python-code
.pyc .pyo
application/x-csh
.csh
application/x-troff
.tr .roff .man
application/trig
.trig
application/n-triples
.nt
application/smil+xml
.smil .smi
application/vnd.mozilla.xul+xml
.xul
application/vnd.lotus-1-2-3
.123 .wks

AUDIO (23 types)

audio/mpeg
.mp3 .mpga
audio/ogg
.ogg .oga
audio/wav
.wav
audio/flac
.flac
audio/aac
.aac
audio/opus
.opus
audio/webm
.weba
audio/midi
.mid .midi
audio/mp4
.m4a .m4b .mp4a
audio/3gpp
.3gp .3gpp
audio/aiff
.aif .aiff
audio/x-ms-wma
.wma
audio/amr
.amr
audio/speex
.spx
audio/ac3
.ac3
audio/vorbis
audio/basic
.au .snd
audio/x-caf
.caf
audio/mpegurl
.m3u
audio/vnd.dts
.dts
audio/mp2
.mp2
audio/3gpp2
.3g2
audio/x-realaudio
.ra .ram

FONT (10 types)

font/woff
.woff
font/woff2
.woff2
font/ttf
.ttf
font/otf
.otf
application/vnd.ms-fontobject
.eot
font/collection
.ttc
font/sfnt
.sfnt
application/x-font-truetype
.ttf
application/x-font-opentype
.otf
application/x-font-woff
.woff

IMAGE (35 types)

image/jpeg
.jpg .jpeg .jfif
image/png
.png
image/gif
.gif
image/webp
.webp
image/avif
.avif
image/svg+xml
.svg .svgz
image/vnd.microsoft.icon
.ico
image/x-icon
.ico
image/bmp
.bmp
image/tiff
.tiff .tif
image/heic
.heic
image/heif
.heif
image/apng
.apng
image/jxl
.jxl
image/jp2
.jp2 .j2k .jpf
image/jpx
.jpx
image/vnd.djvu
.djvu .djv
image/vnd.adobe.photoshop
.psd
image/x-portable-bitmap
.pbm
image/x-portable-graymap
.pgm
image/x-portable-pixmap
.ppm
image/x-xcf
.xcf
image/ktx
.ktx
image/ktx2
.ktx2
image/x-exr
.exr
image/x-rgb
.rgb .rgba .sgi
image/x-xbitmap
.xbm
image/x-pcx
.pcx
image/vnd.wap.wbmp
.wbmp
image/x-tga
.tga .tpic
image/vnd.ms-photo
.jxr .hdp .wdp
image/x-win-bitmap
.cur
image/x-emf
.emf
image/wmf
.wmf
image/vnd.radiance
.hdr .rgbe

MODEL (19 types)

model/gltf+json
.gltf
model/gltf-binary
.glb
model/obj
.obj
model/stl
.stl
model/usd
.usd .usda .usdc
model/vnd.collada+xml
.dae
model/vnd.usdz+zip
.usdz
model/mtl
.mtl
model/vnd.dwf
.dwf
model/iges
.igs .iges
model/step
.stp .step .p21
model/step+xml
.stpx .stpxz
model/x3d+xml
.x3d
model/x3d+binary
.x3db .x3dbz
model/x3d-vrml
.x3dv .x3dvz
model/vnd.3mf
.3mf
model/vnd.fbx
.fbx
model/vnd.opengex
.ogex
model/JT
.jt

TEXT (33 types)

text/html
.html .htm
text/css
.css
text/csv
.csv
text/plain
.txt .text .conf .log
text/markdown
.md .markdown
text/calendar
.ics .ical .ifb
text/vcard
.vcf .vcard
text/javascript
.js
text/event-stream
text/tab-separated-values
.tsv
text/xml
.xml
text/x-python
.py .pyw
text/x-java-source
.java
text/x-c
.c .h
text/x-ruby
.rb
text/x-go
.go
text/x-rust
.rs
text/x-kotlin
.kt .kts
text/x-swift
.swift
text/x-scala
.scala .sc
text/x-php
.php .php3 .php4 .php5 .phtml
text/x-diff
.diff .patch
text/uri-list
.uri .urls .uris
text/x-rst
.rst
text/x-asciidoc
.adoc .asciidoc
text/x-nfo
.nfo
text/x-asm
.asm .s
text/troff
.roff .me .ms .mm
text/x-ini
.ini .cfg .inf
text/x-tcl
.tcl .tk
text/x-fortran
.f .f90 .for .f95
text/x-yaml
.yaml .yml
text/cache-manifest
.appcache .manifest

VIDEO (21 types)

video/mp4
.mp4 .m4v
video/webm
.webm
video/ogg
.ogv
video/x-msvideo
.avi
video/quicktime
.mov .qt
video/x-matroska
.mkv .mk3d
video/mp2t
.ts .mts .m2ts
video/mpeg
.mpeg .mpg
video/3gpp
.3gp .3gpp
video/3gpp2
.3g2 .3gp2
video/x-ms-wmv
.wmv
video/x-ms-asf
.asf .asx
video/vnd.avi
.avi
video/iso.segment
.m4s
video/x-dv
.dv .dif
video/x-ms-vob
.vob
video/H264
video/H265
video/AV1
video/x-flv
.flv
video/x-f4v
.f4v

MULTIPART (9 types)

multipart/form-data
multipart/byteranges
multipart/mixed
multipart/alternative
multipart/digest
multipart/related
multipart/signed
multipart/encrypted
multipart/report
No MIME types match your search.

MIME Types and Browser Security: Sniffing, nosniff, CSP, and CORS

Browsers enforce MIME types as part of their security model. Content-Type headers are not just metadata about file format; they control how browsers parse, execute, and sandbox content. When a server sends the wrong MIME type, browsers make security-relevant decisions about whether to execute scripts, render markup, or apply cross-origin restrictions. MIME sniffing, where the browser detects the actual content type from the file's bytes rather than the declared header, was introduced to handle misconfigured servers but creates attack vectors.1 X-Content-Type-Options: nosniff closes this gap by instructing browsers to trust the declared type exactly.2 Strict CSP configurations check MIME type before executing scripts, adding a second enforcement layer beyond the URL allowlist. Cross-origin resources like fonts and images loaded by canvas require CORS headers that interact with MIME type expectations. Understanding these interactions is fundamental to hardening a web application against content-type confusion attacks.

What MIME sniffing is and when browsers activate it

MIME sniffing is the process by which a browser inspects the first bytes of a response body to determine the actual content type, overriding or supplementing the declared Content-Type header. The WHATWG MIME Sniffing Standard defines the exact sniffing algorithm.3 Browsers activate sniffing primarily when the server sends no Content-Type header, when the Content-Type is text/plain for a resource loaded in a context that expects a specific type, or when the browser detects executable content in a response declared as a safe type.

Content-type confusion attacks

The security risk is a content-type confusion attack: an attacker uploads a file that appears to be an image (and passes server-side format validation) but contains an HTML or script payload that the browser detects and executes when sniffing is active.4 Furthermore, older Internet Explorer versions were particularly aggressive sniffers, treating any response as HTML if the content began with HTML-like bytes.

X-Content-Type-Options: nosniff mechanics

The X-Content-Type-Options: nosniff response header instructs the browser to use the declared Content-Type value exactly and not perform sniffing. When nosniff is present, the browser refuses to execute a script served as text/plain, refuses to render a stylesheet served as application/octet-stream, and refuses to treat any response as HTML unless the Content-Type declares it as such. Modern browsers apply nosniff to all resource types; older browsers applied it only to scripts and stylesheets.5

Why nosniff requires correct MIME types first

Consequently, setting nosniff on every response is best practice rather than applying it selectively. Building on this, nosniff works correctly only when combined with accurate MIME types. Setting nosniff on a server that sends wrong types for images or scripts will cause browsers to reject those resources outright instead of attempting to sniff the correct format from the response body. Fix MIME types first, then enable nosniff globally so that the browser's strict trust in your declared types actually helps rather than hurts your users.

Cross-origin resource MIME rules for fonts and images

Browsers apply CORS enforcement to certain resource types loaded cross-origin. Fonts are the most important example: any font loaded from a different origin requires an Access-Control-Allow-Origin header from the font server, regardless of the MIME type.6 The failure is silent and there is no console error. For images, CORS enforcement applies specifically to canvas operations: drawing a cross-origin image onto a canvas taints it unless the image server sends Access-Control-Allow-Origin and the img element carries crossorigin="anonymous". MIME type plays a secondary role in this: an incorrectly typed cross-origin font still fails even if CORS is configured, because the browser must also recognise the MIME type as a font format. Furthermore, CSP's font-src directive controls from which origins fonts may be loaded, adding a third layer of restriction on top of CORS and MIME type validation.

Subresource Integrity and its relationship with MIME type enforcement

Subresource Integrity (SRI) adds a cryptographic hash check to external script and stylesheet elements. When an element carries an integrity attribute containing a base64-encoded hash, the browser downloads the resource, computes the hash against the received bytes, and compares it to the declared value before executing or applying the resource. A mismatch causes the browser to block the resource entirely. SRI requires CORS on the resource server: the response must include Access-Control-Allow-Origin for the browser to share the response body with the integrity checking algorithm.7

MIME type enforcement and SRI operate as independent checks applied in sequence. A script must carry a valid JavaScript MIME type and pass the integrity hash check before the browser executes it. Serving an SRI-protected script with text/plain fails the MIME type check first, and the browser blocks the resource before computing the hash at all. Consequently, fixing the MIME type is a prerequisite before SRI integrity errors become meaningful.

require-sri-for and layered script security

The CSP require-sri-for directive (available in some browsers) enforces that all scripts and styles in the document carry SRI integrity attributes, blocking any script or stylesheet that lacks a valid hash regardless of its origin or MIME type. Combining require-sri-for with a script-src allowlist and X-Content-Type-Options: nosniff creates three independent enforcement layers: only approved origins, only verified content hashes, and only correct MIME types. Implementing all three layers means an attacker must compromise the origin, match the expected hash, and serve the correct MIME type simultaneously, which raises the difficulty of a successful content injection attack dramatically.

Generating SRI hashes for your build pipeline

Generating SRI hashes during the build step ensures every deployed script and stylesheet carries an integrity attribute that matches the exact bytes the browser will receive. The openssl dgst command computes a SHA-384 hash of a file and the base64 utility encodes it for the integrity attribute value.7 Build tools like webpack-subresource-integrity automate this process by computing hashes at bundle time and injecting the integrity and crossorigin attributes into the generated HTML, removing the manual step entirely.8

Hashing at build time also means the integrity value stays in sync with the exact bytes the browser receives, so a minification change that alters the file automatically produces a new hash without manual intervention. This prevents the stale-hash problem where a code update ships new script bytes but an old integrity attribute blocks them. pair the script Content-Type with SRI so the MIME check and the hash check pass together.

When to use this

Use this guide when hardening a web application against content-type confusion attacks, auditing response headers for security posture, or diagnosing silent resource failures caused by CORS or MIME type mismatches.

Examples

Add X-Content-Type-Options: nosniff globally in Nginx

Place in the http {} block to apply to all responses. Combined with correct MIME types, this prevents content-type confusion attacks.

Verify nosniff and Content-Type with curl

Check both the Content-Type and X-Content-Type-Options headers together to confirm both are correct.

CSP script-src with MIME type enforcement

Strict CSP rejects scripts served with incorrect MIME types. Setting the correct type and CSP together prevents both sniffing and unlisted script execution.

Sources
  1. 1.

    Mozilla Developer Network, "MIME type verification," developer.mozilla.org, accessed June 2026. https://developer.mozilla.org/en-US/docs/Web/Security/Practical_implementation_guides/MIME_types

  2. 2.

    OWASP Foundation, "HTTP Headers Cheat Sheet," owasp.org, 2024. https://cheatsheetseries.owasp.org/cheatsheets/HTTP_Headers_Cheat_Sheet.html

  3. 3.

    Adam Barth and Ian Hickson, "Media Type Sniffing," draft-ietf-websec-mime-sniff-03, IETF, May 2011. https://datatracker.ietf.org/doc/html/draft-ietf-websec-mime-sniff-03

  4. 4.

    MITRE, "CAPEC-209: XSS Using MIME Type Mismatch," capec.mitre.org, accessed June 2026. https://capec.mitre.org/data/definitions/209.html

  5. 5.

    Mozilla Developer Network, "X-Content-Type-Options header," developer.mozilla.org, accessed June 2026. https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/X-Content-Type-Options

  6. 6.

    W3C, "CSS Fonts Module Level 3," w3.org, 2018. https://www.w3.org/TR/2018/REC-css-fonts-3-20180920/

  7. 7.

    W3C, "Subresource Integrity," w3.org, 2016. https://www.w3.org/TR/2016/REC-SRI-20160623/

  8. 8.

    "webpack-subresource-integrity," GitHub, github.com, accessed June 2026. https://github.com/waysact/webpack-subresource-integrity

FAQ