file-signature · shipping · also Magic number, Magic bytes

File signature

A file signature is a specified byte sequence at a defined position used to help identify a file format.

Scope: Media-type registrations can describe magic bytes and filename extensions separately. A format signature identifies a byte pattern; it is neither a checksum of the whole file nor a cryptographic digital signature. [2]

Example: PNG starts with hexadecimal bytes 89 50 4E 47 0D 0A 1A 0A. Those eight bytes alone match the PNG image-type pattern in the MIME Sniffing Standard, but do not form a conforming PNG datastream: required chunks, including IHDR and IEND, are absent. [3] [4]

Validation: Check the selected format's complete structural and data requirements after identification. A filename, declared media type or successful prefix comparison does not establish completeness, authenticity or application suitability. [3] [1]

Ambiguity: Binary polyglots allow multiple formats to coexist in the same bytes. Albertini et al. distinguish these from near polyglots that require byte changes. Validation for one format therefore does not establish a unique interpretation or safety in another consumer. [5]

Relations

related
Media type, Data serialization, Checksum, Byte order

Citations

  1. RFC 9110: Content-Type and media types, sections 8.3 and 8.3.1 (accessed 2026-11-22)
  2. RFC 6838: additional media-type identification information, section 4.12 (accessed 2026-11-22)
  3. W3C PNG Third Edition: file signature and datastream conformance (accessed 2026-11-22)
  4. WHATWG MIME Sniffing: matching an image type pattern (accessed 2026-11-22)
  5. Albertini et al., USENIX Security 2022: binary versus near polyglots and format characteristics, sections 4.2-4.4 (accessed 2026-11-22)

Further reading

  1. Hesela: identify the format, then validate the file (accessed 2026-11-22)
Sources & caveats
  • The signature-only PNG case is a specification-derived counterexample, not a measured decoder result.
  • The executable example tests only the eight-byte PNG prefix rule; it is not a general MIME sniffer or a PNG validator.

JSON: /data/terms/file-signature.json

Published by Hesela team · Updated

Report a correction · Editorial standards · Reuse guidance

Cite this page
Hesela team. File signature. Hesela. 2026-11-22. https://hesela.dev/terms/file-signature/