Files
harfbuzz/test/fuzzing
Behdad EsfahbodandClaude Opus 4.8 220ef2ca34 [glyf] Restore scratch length when gvar fails in get_points; clear comp_points at entry
Glyph::get_points() uses scratch.comp_points as a stack shared by all
recursion levels: it appends one point per component plus four phantoms, and
every exit restores points.length to old_length -- except the exit taken when
gvar->apply_deltas_to_points() returns false (for example on a tuple whose
variationDataSize overruns its data).  Because the hb_glyf_scratch_t is cached
on the glyf (and VARC) accelerator for the life of the face, every failed
depth-0 load grows the vector permanently, until it reaches its allocation
ceiling; a VARC font can drive hundreds of thousands of such failing leaf
loads within one glyph budget, leaving tens of megabytes behind per extents or
draw call.

Balance the missing exit the way every sibling exit (and #6410) already does.
Also clear comp_points next to the existing all_points.clear() at the depth-0
entry in glyf_accelerator_t::get_points(), the only entry into the cached
scratch (the subsetter's call uses a local scratch), so the cached vector can
never carry stale points across loads even if a future exit forgets the
discipline.  No behaviour change for well-formed fonts: the resize only runs on
the failure path and comp_points is empty at entry when exits are balanced.

Adds a minimized VARC+gvar font to test/fuzzing/fonts exercising the failing
path through the shape/draw/raster/vector/subset fuzzers.

Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-NM4GCMBX.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-10-31 21:59:50 -06:00
..
2023-05-27 01:16:46 +02:00
2025-04-06 02:34:48 -06:00

Security Fuzzers

To build the fuzzers with libFuzzer to perform actual fuzzing, build with:

CXX=clang++ CXXFLAGS="-fsanitize=address,fuzzer-no-link" meson fuzzbuild --default-library=static -Dfuzzer_ldflags="-fsanitize=address,fuzzer"

ninja -Cfuzzbuild

Then, run the fuzzer like this:

fuzzbuild/test/fuzzing/hb-{shape,raster,vector,subset,repacker,depend}-fuzzer [-max_len=2048] [CORPUS_DIR]

Where max_len specifies the maximal length of font files to handle. The smaller the faster.

Note: The depend fuzzer requires -Ddepend_api=true meson option.

For more details consult the following locations:

Depend Closure Parity Test

The hb-depend-closure-parity test is distinct from the security fuzzers. While security fuzzers test robustness against malformed input, the closure parity test validates correctness by emulating the glyph closure calculation used for subsetting with one generated from the dependency graph to avoid implementation divergence. It should only be run on valid fonts.