reset_recurse_cache() runs once per top-level lookup and cleared completed_recursions and recurse_path_to_index with hb_hashmap_t::clear(), which walks the whole table and keeps its allocated capacity. A single lookup that grew these maps large therefore made every later top-level lookup pay to walk that full capacity, however little it recursed, giving a font with one busy lookup followed by many trivial ones a CPU DoS in hb_subset_depend_from_face_or_fail(). Add clear_or_release(): when a map is large but was left mostly empty by the lookup that just finished, swap in fresh storage before clearing, so later lookups start from a small table. Adds a fuzzer regression font. Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-PNJPHF76. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.