
A python tool to detect PDF files exploiting CVE-2026-86950
For more context about this project and CVE-2026-86950, see https://decalage.info/CVE-2026-86950/
Disclaimer: most of this readme and the detection code have been written with the help of AI coding agents. The tool has been tested with success on thousands of legitimate PDF files and on the available proof-of-concept published here. However, this tool is new and the detection algorithm is rather complex so use it with caution.
detect_cve_2026_86950.py statically scans PDF files for embedded fonts
crafted to exploit CVE-2026-86950 ("The Great Glyph Grift"), an
out-of-bounds write in Apple CoreGraphics' anti-aliased glyph rasterizer
(fixed in iOS / macOS 26.7.1).
It never renders the font or executes any exploit code — it parses the PDF and the embedded font program and looks for the structural signature of the attack.
CoreGraphics turns a floating-point device coordinate into a 16.12 fixed-point integer with roughly:
int32_t aa_double_to_fixed(double px) { return (int32_t)(0.5 + 4096.0 * px); }
When 4096 * px exceeds the range of int32, the cast is undefined behaviour,
and two call sites (aa_moveto vs. aa_lineto) disagree — one saturates, one
truncates. That disagreement corrupts the glyph bounding-box calculation in
aa_add_edges, so the coverage buffer in aa_cache_render is allocated too
small and the rasterizer writes out of bounds. The 26.7.1 patch adds explicit
clamping to ±0x3FFFF001.
The public proof-of-concept builds a malicious TrueType font that forces such an oversized coordinate:
/Tf 1024), 4096 × device_coord overflows int32./FontFile2) and CFF / OpenType (/FontFile3)./Tf, Tm) and checks whether 4096 × device_coord
actually exceeds INT32_MAX — i.e. whether the fixed-point overflow is
reachable.Verdicts: exploit (overflow reachable), suspicious (oversized geometry but not overflowing at the observed size), clean.
# with uv (recommended)
uv venv
uv pip install -r requirements.txt
# or any environment with pikepdf + fonttools
python3 detect_cve_2026_86950.py suspicious.pdf
python3 detect_cve_2026_86950.py -v *.pdf # per-font details
python3 detect_cve_2026_86950.py --json f.pdf # machine-readable
Exit code: 0 clean, 1 exploit/suspicious found, 2 error.
aa_* path rasterizer, which renders both TrueType glyf and CFF/Type2
outlines. The public PoC amplifies coordinates with TrueType composite
glyphs; a CFF font can reach oversized coordinates directly (e.g. by
accumulating relative operators), so both /FontFile2 and /FontFile3 are
analyzed. The composite-chain heuristic is TrueType-specific; for CFF the
signal is the oversized-coordinate / bounding-box-lie check./Tf, Tm) scan of content streams is best-effort; it does
not fully evaluate the PDF graphics state / CTM. When no size is found, a
conservative default of 1024 is assumed for the overflow check. The
font-intrinsic oversized-geometry signals do not depend on this.