Dev.to
7/20/2026

The original title is: "Reject Image Polyglots After EXIF Removal, Before They Reach Your CDN"
Original: Reject Image Polyglots After EXIF Removal, Before They Reach Your CDN
Short summary
EXIF removal alone doesn't guarantee an uploaded JPEG is only a JPEG—attackers can append ZIP or HTML payloads after the image end marker. The author recommends a multi-layer upload gate: quarantine originals, enforce size and dimension limits, decode and re-encode pixels into a fresh file, then publish only the derived output. Re-encoding is stronger than boundary checks because it creates a new representation from decoded pixels, discarding all trailing bytes and metadata.
- •EXIF stripping does not prevent polyglot image attacks
- •Re-encode uploaded images to discard trailing payloads and metadata
- •Publish only server-generated derived files; keep originals quarantined
Generated with AI, which can make mistakes.
Is this a good recommendation for you?



