hb_depend_context_t::recurse() only refused to re-enter a lookup already on the call stack, so a chain of distinct Context lookups recursed once per lookup (stack overflow around 8600 lookups on an 8 MB stack) and lookups invoking each other in every order were walked once per ordering (a factorial number of interned paths, gigabytes of memory). recurse() is where every sibling context (closure, closure-lookups, apply) enforces HB_MAX_NESTING_LEVEL, so add the same nesting_level_left guard here; shaping never applies lookups nested deeper, so no edge the closure can reach is lost (a chain's final edge drops at exactly the depth the closure stops, 65->66). Bound the number of distinct recursion paths with a counter kept over the whole table (not cleared by reset_recurse_cache, which runs per top-level lookup) against a new HB_MAX_DEPEND_RECURSE_PATHS limit in hb-limits.hh, so it can be tuned on its own; exceeding it fails the build so hb_subset_depend_from_face_or_fail() returns nullptr instead of emitting a truncated graph. The largest whole-table path count among the test fonts is 744 (NotoNastaliqUrdu-Bold), so 35000 leaves ample headroom. Builds only with experimental_api. Adds a small permutation-font fuzz seed and a test-ot-depend test; test-ot-depend, the depend fuzzer and the depend-closure-parity tests pass. Related to PR #6185. Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-N28924W8. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Co-Authored-By: Claude Opus 5.5 <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.