mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-24 08:21:32 +01:00
The paint encoder memoizes a clip glyph's sub-blob, so layers painted under the same clip stack cost it only a cached index and 24 bytes of op stream each. The fragment shader, however, walks every curve of every clip outline again for every layer in every fragment. Ops, clips per layer and outline size each had a cap, but nothing bounded their product: a small COLRv1 font nesting a few PaintGlyph clips of a dense outline under tens of thousands of PaintSolid layers made the shader do hundreds of millions of curve-loop iterations per fragment, a denial of service on the GPU (or the CPU under a software rasterizer). Charge each layer's reference to each clip sub-blob -- cached or freshly encoded, glyph or path clip -- to the existing session work budget, in encoded RGBA16I texels, which is what the shader's band walk scales with. This lives in emit_all_clip_sub_blobs(), the one path all four layer emitters go through; exhausting the budget marks the paint unsupported like the other encoder limits, so hb_gpu_paint_encode() returns NULL. It adds no new tunable: the budget defaults to HB_BUDGET_GLYPH and hb_paint_set_budget(), including HB_BUDGET_UNLIMITED, governs it as it does the outline work. Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-FUCZJR1Y. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>