Skip to content
Path traversal Write-up Advanced

The tragedy of low-level exploitation

The mutool extract command used the /FontName entry from a PDF without sanitisation to build an output file path, allowing path traversal. An attacker could write a file with attacker-controlled content to an arbitrary location, potentially leading to DLL spoofing and deferred RCE.

gynvael.coldwind.pl

Published on gynvael.coldwind.pl

Null Byte Poison is a neat little attack that usually can be applied when "length+data"-type strings get converted into "zero-terminated"-type strings. It's a well known problem though that haunted PHP scripts for several years, and even visited the browser world.

The author, on gynvael.coldwind.pl

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 /FontName value from the PDF was used directly in a file path without sanitisation, and a Unicode truncation bug on Windows allowed a null byte to cut off the appended suffix.

Impact

An attacker could write a file with attacker-controlled content to an arbitrary location, which could lead to DLL spoofing and deferred remote code execution; the author tested on Windows and suspected it might work on Linux but was not sure.

What the attacker needed

Victim runs mutool extract on a malicious PDF; Windows target (tested)

The fix

The bug was fixed by a patch committed on 2020-06-26.

How it was found

  1. Create a PDF with a crafted /FontName entry containing path traversal sequences.
  2. Run mutool extract on the PDF.
  3. The tool writes a file to the attacker-chosen path, with the suffix removed via a null byte.

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.

When you run a program that extracts files from a document, it should not let the document choose where files are saved. Here, a field inside the PDF controlled the output filename, so a malicious PDF could write a file outside the intended folder. That could let an attacker place a harmful library file where another program might load it.

What is Path traversal?

Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.

Similar reports

View all

Same bug class and techniques, clearest first.

Path traversal and file inclusion

The lesson behind this report.

Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.