closure_glyphs(), depend() and varc_subset_plan_t::collect_glyphs()
each decode the full glyph record of every glyph id they reach,
assuming every glyph has its own record. Nothing enforces that:
CFFIndex::sanitize() accepts overlapping glyphRecords offsets, and a
Coverage table may map many glyph ids to the same INDEX entry, so N
glyph ids can resolve to one large record and the walk does N times
that record's work -- quadratic in the font size (44 s for a 245 KB
font), charged to no budget.
In a well-formed table the records are disjoint and each glyph is
visited once, so the bytes of all records walked cannot exceed the
glyphRecords INDEX. Enforce exactly that invariant where the records
are fetched, in all three walks, failing through each site's existing
idiom. The remaining work is linear: a component decodes only if its
record holds at least one byte per 64 counted axis values.
In collect_glyphs() this also replaces the saturating sum and the
post-loop data_size != UINT_MAX test, which a 64-bit build bypasses
because hb_unsigned_add_saturate() returns size_t and the sum truncates
into the unsigned data_size (a near-4 GiB total stored as a small
value); the running total is now checked after every addition.
Overlapping VARC records, already malformed per the CFF INDEX spec, now
fail subsetting instead of being accepted; shaping and drawing are
unaffected and valid VARC fonts subset to byte-identical output.
Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-71PGEDL2.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>