← All Challenges
Challenge 30: Polyglot File Exploitation
Difficulty: Hard
Category: Extension Heuristic Bypass
Objective
The scanner determines file type solely by extension and never inspects content or magic bytes. A polyglot file is a single file that is simultaneously valid in multiple formats. Your goal is to create a file that:
- Has an innocuous extension (e.g.,
.pdf,.png,.jpg) that is not on the suspicious list. - Is actually valid and functional in that claimed format (opens correctly in the expected application).
- Also contains executable code that can be triggered through an alternate interpretation of the same bytes.
Scanner Behavior
- File type is determined exclusively by the file extension.
- No magic byte validation is performed (the scanner never checks
%PDF,\x89PNG,MZ, etc.). - Content scanning only looks for specific string signatures - it does not understand file format structure.
- A
.pdffile is treated as a PDF regardless of what bytes it actually contains. - The scanner will not warn on non-suspicious extensions, even if the file content is clearly executable.
Hints
- Many file formats are flexible about what data can appear in certain regions of the file (comments, metadata, padding).
- Some formats (like PDF) can contain embedded JavaScript that executes when the file is opened.
- A file can have valid image headers while containing HTML/JavaScript after the image data, exploitable in certain contexts.
- Consider formats where executable content can be embedded within valid structural elements: ZIP archives (which are also valid .jar/.docx), PDFs with JavaScript actions, or images with trailing script data.
- The key insight: the scanner trusts the extension completely and never validates that content matches the claimed type.
AMSI Raccoon Lab