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>