Back to Blog
What is a Polyglot File? (Security Testing Guide)
Advertisement
The Dual-Natured Threat
In security, a Polyglot is a file that is valid in multiple formats simultaneously. The most dangerous variant is the GIFAR (GIF + JAR).
Anatomy of a GIFAR
This exploit leverages the file structure differences between formats:
- GIF headers are at the start of the file.
- JAR (ZIP) headers are at the end of the file.
By concatenating them, an attacker creates a file that looks like an image to the upload filter (passing the check) but executes as a Java archive when loaded by a vulnerability.
Testing Your Defenses
To verify your application is resilient against Polyglots:
- Transcoding: Does your server re-encode images? Opening and re-saving the image usually strips the malicious payload.
- Content-Type Options: Use the
X-Content-Type-Options: nosniffheader. This forces the browser to trust the server's MIME type rather than sniffing the file content and accidentally executing the code.
Security is not just about blocking bad files; it is about sanitizing every file.
Advertisement
