Understanding the code
A vulnerability in ExifTool's DjVu reader allowed code execution through a crafted DjVu annotation, and the author reverse-engineered the patch to create a working exploit that could be embedded in a JPEG image.
amalmurali47.medium.com
Published on amalmurali47.medium.com
A tweet showing an RCE in ExifTool popped up on my feed; it looked interesting — maybe a little scary. But what good is an RCE on a demo video?
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
The DjVu annotation parser used Perl's eval on a string after an incomplete escaping routine, allowing an attacker to break out of the string context and execute arbitrary Perl code.
Impact
An attacker could execute arbitrary commands on a system that processes a malicious image with ExifTool, as demonstrated by launching a calculator.
What the attacker needed
ExifTool processes a malicious image; Image contains a crafted DjVu annotation
The fix
The vulnerability was fixed by removing the eval and improving the escaping of special characters in the DjVu annotation parser.
How it was found
- Create a PBM image file.
- Use cjb2 to convert the PBM to a JB2 mask file.
- Use djvumake to create a DjVu file with the mask.
- Create an annotation input file containing the payload.
- Use djvumake with the ANTa argument to embed the annotation into the DjVu file.
- Embed the DjVu file into a JPEG using ExifTool's GeoTiffAsciiParams tag.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
ExifTool is a tool that reads metadata from image files. A bug in how it handled DjVu files (a document format) let an attacker run commands on the computer when ExifTool processed a malicious image. The author figured out how to trigger this by studying the fix and building a test file.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.