Reject Image Polyglots After EXIF Removal, Before They Reach Your CDN
The article highlights the threat of image polyglots, which are files that pass as valid images (e.g., JPEG, PNG) but also contain executable code or other data. These can be used to bypass security measures like EXIF removal, which strips metadata but may leave polyglot structures intact. Once uploaded, such files can reach a CDN and potentially be served to users, enabling attacks like XSS or data exfiltration. The author recommends implementing server-side validation to reject polyglots after EXIF removal, before they reach the CDN. Code examples are provided for detecting polyglots by checking for multiple file signatures or using libraries like `file-type`. The article stresses that relying solely on EXIF stripping is insufficient and that a multi-layered approach is necessary.
Developers must validate images server-side after EXIF removal to prevent polyglot-based attacks reaching CDNs.