Re-encoding Uploads, Not Just EXIF Removal, Blocks Image Polyglot Attacks
Image polyglots are files that appear as valid JPEGs to browsers but contain hidden payloads in a second format, such as ZIP or HTML, appended after the JPEG end marker. Simply stripping EXIF metadata does not eliminate this threat, as downstream scanners or content sniffers may still interpret the trailing bytes. Security best practice calls for a multi-layer upload pipeline: quarantining originals, enforcing size and dimension limits, decoding with a trusted library, and re-encoding pixels into a fresh file. Re-encoding is considered the strongest defence because it constructs an entirely new file from raw pixel data, discarding all metadata and trailing content. The OWASP File Upload Cheat Sheet reinforces this approach, recommending allowlisted types, server-generated filenames, storage separation, and full content validation rather than relying on any single check.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)
Log in to join the discussion and vote.
Log in