Files
harfbuzz/test/fuzzing
Behdad EsfahbodandClaude Opus 4.8 8f93b6d21b [layout] Charge GSUB/GPOS sanitize-time arrays to max_ops (#6631)
* [sanitize] Charge ChainRule backtrack/input/lookahead arrays to max_ops

ChainRule::sanitize() checks the length of each of its three arrays but
only sanitizes the trailing LookupRecord array, so it never charges
max_ops for the bytes it skipped over.  A table with many ChainRuleSet
offsets all pointing at one large ChainRule could therefore be
sanitized in time proportional to offsets x rule size, escaping the
sanitizer's work bound (restoring the accounting removed by 385896ff6).

Charge the skipped span (from this to the LookupRecord array) to
check_ops before sanitizing the records.  Adds a fuzzer regression
font.

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

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* [GPOS] Charge zero-size ValueRecord arrays to the sanitizer op budget

When a ValueFormat is empty its records take no bytes, so
ValueFormat::sanitize_values() and PairPosFormat2::sanitize() pass
check_range() without charging max_ops for the records, while later
code (the subsetter, variation-index collection) still walks count
records.  A tiny table can thus declare a huge valueCount / class
matrix and cost the subsetter CPU out of proportion to its size.

Charge count ops when the record size / stride is zero, following the
918193ebf precedent.  Adds two fuzzer regression fonts.

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

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-11-11 12:43:06 -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.