CID-keyed CFF charsets contain CIDs, not the standard SIDs needed by seac.
Interpreting the invalid operator can therefore retain unrelated glyphs
when their CIDs collide with the component SIDs from StandardEncoding.
Reject CID-keyed fonts in get_seac_components so both subset closure and
dependency collection skip these invalid lookups. Add a synthetic CID
font with colliding CIDs and check that only .notdef and the requested
glyph enter the subset plan.
The regression fails before the fix with four retained glyphs instead of
two. All 294 Meson tests pass, including the subset and API suites.
Assisted-by: OpenAI Codex
_hb_face_builder_get_table_tags() copied every key out of the hash map
and qsort()ed it on each call, so a caller paging through the list (the
subsetter uses 32-entry pages in hb_subset_plan_execute_or_fail() and
_is_table_present()) paid N/32 sorts of N tags per enumeration. With
the 65535-table face that hb_subset_preprocess() hands back this was
~25 s of CPU per hb_subset_or_fail() call.
Keep an hb_vector_t<hb_tag_t> next to the map and maintain it in
hb_face_builder_add_table(), the only place keys are inserted: a binary
search finds the slot, the vector is pre-allocated before the map is
touched so an allocation failure leaves both structures unchanged, and
the slot is opened with the same resize+memmove idiom hb-bit-set.hh
uses. The getter becomes a sub_array() copy, so enumeration is O(page)
and the returned order is unchanged. _hb_face_builder_data_reference_blob()
keeps its own sort, which orders by blob size, not by tag.
A regression test adds tags out of order, one of them twice, and checks
that paging with a 4-entry array returns each tag once in ascending
order.
Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-VENZFNXH.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
A builder face must always be serializable into an sfnt, but
hb_face_builder_add_table() accepted any number of tables while the
table directory's numTables is 16-bit. Serializing a 65536th table hit
the assert in BinSearchHeader::operator= (or, with NDEBUG, truncated the
count and then looped forever through hb_face_reference_blob()'s retry).
The subsetter reaches this with HB_SUBSET_FLAGS_PASSTHROUGH_UNRECOGNIZED
because glyf::subset() always adds a 'loca' the source need not have.
Enforce the limit where tables are added, so the subsetter fails cleanly
at plan->add_table() and a builder face can always be written out;
replacing an existing tag is still allowed. Also stop
hb_face_reference_blob() from recursing into itself on the fallback
builder it just built (serialize it directly with reference_table()):
otherwise a builder that cannot produce a blob is retried without end.
A regression test in test/api/test-get-table-tags.c adds 65535 tags,
checks the 65536th is refused, that replacement still works, and that
the serialized blob has the expected size.
Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-7BXQZ7HS.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
name_table_overrides stores hb_malloc()ed strings as plain hb_bytes_t
values, so the invariant that every stored string is freed exactly once
in ~hb_subset_input_t broke when set() silently overwrote an existing
key: overriding the same name record more than once on one input leaked
the previous copy, and so did a NULL (remove) after a non-empty
override.
hb_subset_input_override_name_table() is the only place that allocates
these strings, so fix it there: look the record up with has(&old) and
fini() it in place before set() (fini nulls the pair, so no path frees
twice, and the lookup happens before set() can reallocate the table).
Also free the fresh copy and return false when set() cannot store it,
instead of leaking it and returning true. hb_subset_plan_t copies the
map and frees its own copies, so it is unaffected. No public API/ABI
change.
A regression line in test_subset_name_overrides overrides one record
twice; only the last string survives and the first must not leak.
Reported by Anthropic's OSS Scanner as ordinary bug ANT-2026-8SA3SRW4.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The function documents len as the length of str, but located the ':'
separators with strpbrk() and matched "drop" with strcmp(), both of
which scan to the next NUL byte. A caller passing an exact-length,
non-NUL-terminated slice therefore got an out-of-bounds read, and bytes
beyond len could change or reject the parsed range.
Bound every scan by str+len: each strpbrk() becomes memchr() bounded by
end, the strcmp() becomes a len==4 && hb_memcmp() check, and the empty
-piece test !*str becomes str == end. This is the same discipline the
sibling parsers hb_feature_from_string()/hb_variation_from_string()
already follow. For len == -1 (the only in-tree caller) len becomes
strlen() first, so behaviour is unchanged. No public API/ABI change.
A regression test in test/api/test-subset.c passes prefixes of longer
literals with an explicit len and checks the NUL-terminated cases still
parse as before.
Reported by Anthropic's OSS Scanner as ordinary bug ANT-2026-IL9ZX304.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* [cairo] Paint nested color glyphs inline to bound recursion
hb_cairo_paint_color_glyph() accepted the color_glyph paint callback
and drew the nested glyph with cairo_show_glyphs(), which re-enters
hb_font_paint_glyph() through a new cairo scaled font with a fresh
hb_paint_context_t. The glyph decycler, HB_MAX_NESTING_LEVEL and the
edge budget therefore start over at every level, so two glyphs that
paint each other with PaintColrGlyph recurse until the stack is
exhausted. The per-scaled-font hb_cairo_budget_t cannot bound this
either: the nested glyph is shown through a different scaled font, so
each level gets its own budget.
Decline the callback, returning false exactly as hb-raster's does, so
the COLR (and hb-ft-colr) walk paints the nested glyph inline under the
decycler and depth limits of the walk already in progress.
A regression test with two PaintColrGlyph glyphs that paint each other
is added to test/api/test-cairo.c; it aborts on the unpatched library
and passes with the fix.
Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-VPKA505E.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* [cairo] Don't leak the hb_font_t created per scaled font
hb_cairo_init_scaled_font() must hand exactly one reference of the
hb_font_t to the cairo_scaled_font_t. For a face-based font face
(hb_cairo_font_face_create_for_face()) it creates the font with a
reference count of 1, but then still called hb_font_reference() before
attaching it, so the creating reference was never released. Every
finalized scaled font therefore leaked an hb_font_t, pinning its
hb_face_t, the font blob and the accelerators until the process exits.
Cairo finalizes scaled fonts during normal operation once its cache
fills, so the leak accumulates as content selects distinct sizes,
transforms or font options.
Take the extra reference only in the branch where the font is the
shared one owned by the cairo font face (the font-based constructor),
and transfer the freshly created font as-is. The set_user_data result
is now checked and the font released on failure, matching the
budget/color-cache idiom a few lines below and the font-face
constructors in the same file.
A callback installed with hb_cairo_font_face_set_font_init_func() that
returns a different font keeps its historical behavior: the returned
font is referenced rather than assumed to transfer ownership, so no
in-tree contract changes and no caller can turn into a use-after-free.
hb-view uses the font-based constructor and was unaffected.
A regression test in test/api/test-cairo.c registers a face destroy
notifier, draws through a face-based font face, flushes cairo's
scaled-font cache and asserts the face was destroyed; it fails on the
unpatched library and passes with the fix.
Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-BAUN9JN4.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* [cairo] Map non-monotone buffer clusters to one cairo cluster
hb_cairo_glyphs_from_buffer() asserted that buffer clusters are monotone
in the buffer direction, but hb_shape() does not guarantee that:
HB_BUFFER_CLUSTER_LEVEL_CHARACTERS, shaping that hits the ops limit
mid-lookup, and Indic reordering corner cases can all produce
non-monotone clusters. The function runs from HarfBuzz's own cairo
text_to_glyphs callback on attacker-controlled text and fonts, so the
assertion was an input-dependent abort (and, with NDEBUG, an unchecked
backward walk off the ends of the utf8 buffer).
The cluster-counting loop that already walks the buffer now detects a
step against the buffer's direction and falls back to a single cairo
cluster mapping all of the utf8 to all of the glyphs, which cairo
accepts. The monotonicity assertions in the fill step then hold by
construction and glyph output is unchanged for monotone buffers.
A regression test in test/api/test-cairo.c feeds monotone and
non-monotone LTR/RTL buffers through both cluster modes and checks the
cluster counts and byte/glyph totals; it aborts on the pristine tree.
Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-T4PZ1H72.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* [cairo] Charge compositing operations to the glyph budget
hb-cairo's per-glyph work budget was spent only on emitted path segments,
so a COLRv1 font could pay once for a clip outline (push_clip_glyph) and
then have cairo re-rasterize it for every PaintSolid/gradient/group
composite under it, up to the COLR edge limit. That is the
multiplication of limits the shared budget in hb-limits.hh exists to
prevent: a 2 KB font kept hb-view busy for over a minute on one glyph.
Charge every composite in the cairo backend, where the cost is incurred
and where the sibling backends already charge per operation (hb-raster
charges pixel area per paint). hb_cairo_context_t now counts the
segments of the current path and keeps a stack of the clip paths in
force, maintained by the push_clip_* callbacks and pop_clip; spend_paint()
charges every fill, paint, group and gradient with (1 + segments) times a
per-source weight, squared when more than one path is in force since
cairo then intersects the paths per operation. These segment and clip
counts are inputs to the existing budget_remaining counter; they are not
a separate per-callback limit. The weights (HB_BUDGET_512 for
solid/group, 1024 for linear/radial gradients, a new HB_BUDGET_8192 for
the sweep mesh pattern) follow per-composite timings measured on
cairo 1.18.
Nested color glyphs are already painted inline by the color_glyph
callback, so their composites are charged against the clips in force at
that point; no change is needed there.
Behaviour change: a glyph whose composites exceed the budget (about 32k
segment-composites, roughly a second of cairo time at hb-view's default
size) is truncated best-effort, as outline work already is. All glyphs
of the COLRv1 glyf (static and variable) and CFF2 test fonts render
byte-identically through hb-view with and without this change.
A regression test with a generated 3 KB font is added to
test/api/test-cairo.c alongside its fontTools generator; it finishes in
about a second once the paints are charged and guards against
reintroduction through the meson test timeout rather than a
discriminating assertion.
Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-38OVH0N4.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
IndexSubtableArray::find_table() finds a glyph's bitmap by walking
the strike's whole IndexSubtableRecord array. The record count is a
32-bit field bounded only by the table length, and the walk is
charged to no work limit, so two callers run it once per glyph and
turn font size times text/glyph count into CPU time:
- hb-ot-font, on every extents/PNG/paint query, which stalls
hb_shape() (vertical text without VORG/vmtx measures each glyph by
its extents) and the extents/paint/PNG getters;
- the subsetter, for every output glyph of every strike in
IndexSubtableArray::build_lookup().
With a ~320 KB font one vertical hb_shape() of 2000 letters took ~31 s
against ~0.25 s for the same font with the record count set to 1, and
a ~303 KB font kept hb-subset --gids='*' busy for ~100 s.
build_lookup() now maps each retained glyph to the first record that
covers it in one pass over the records (a copy of the glyphset with
del_range() after each record keeps the first-covering-record rule),
instead of searching the array per glyph. Output is byte-identical.
The accelerator builds a bounded per-face index: for the first strike
of each ppem it records the disjoint (ppem, glyph range) -> record
index spans in a sorted vector that find_table() binary searches,
preserving the first-covering-record rule exactly. The index is
capped at HB_CBDT_MAX_INDEX_ENTRIES (a new limit in hb-limits.hh): a
strike whose records would overflow it, or that hits an allocation
failure, falls back to the original linear walk via walk_ppems, so
the index never exceeds the cap no matter how many records the
sanitizer accepted. BitmapSizeTable::find_table() is kept as that
fallback.
Known limitation: the cap is one shared budget, filled in sizeTables
order. A single ~512 KB filler strike of ~65535 one-glyph records
exhausts it, so every strike after it in the array keeps the full
per-glyph walk; a font under 3x the reproducer's size can still force
that walk for those later strikes. This is acceptable for a
non-security performance bug and keeps lookup results exact for every
font. Per-strike lazy indexing (build a strike's index on first use,
under its own cap) is the real follow-up and is left out here to keep
the change small.
Lookups are unchanged. The reproducer drops from ~31 s to ~0.39 s
with identical shaped output; the 303 KB subsetter case drops to
~0.07 s; the 197 MiB worst case (255 strikes at distinct ppems
sharing one 65535-record array) now peaks at ~18 MiB. Adds
test_hb_ot_color_png_cbdt_records (pins the first-covering-record
rule through the index) and test_subset_cbdt_many_records (a
65535-glyph, 64-strike, keep-everything subset that must finish
quickly). The full test suite passes; ASan/UBSan clean.
Reported by Anthropic's OSS Scanner as ordinary bug ANT-2026-YJXG98O5.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The draw encoder returns the empty blob for outlines without curves.
Treating it as a clip sub-blob leaves a layer referring to the next
payload or the end of the encoded data. Cache empty glyph and path
clips separately and skip their consuming layers. Preserve the
paint encoder's no-ink contract when only group operations remain,
returning an empty blob with zero extents.
Use fallible blob creation for gradient payloads so allocation failure
cannot produce the same zero-length sub-blob references.
Add an API regression using an ordinary font and paint callbacks,
covering solid and gradient layers, empty paths, groups, and clip slot
reuse. Validate the surviving layer's outline and band references.
The regression fails on the original encoder; the full Meson suite
passes (274 tests).
Reported by Anthropic's OSS Scanner as ANT-2026-5Z1FLVCW.
Assisted-by: OpenAI Codex
hb_pair() preserves references to lvalue arguments. The alternate
collection callbacks returned pairs referencing their own by-value
parameters, so the next iterator stage read them after the call ended.
Pass each AlternateSubst glyph directly to the collector helper, which
already encodes its alternate index. This also keeps alternate_count
keyed by the original glyph. Return a value pair for SingleSubst format
1, as the subsetting path already does.
Cross-check collected maps against the per-glyph getter for four
SourceSansPro lookups. The alternate and both SingleSubst format 1
cases fail on the previous code; the format 2 control passes.
Testing: meson test -C build (292 passed; check-symbols skipped on
macOS). All five alternate API tests also pass under ASan and UBSan,
with stack-use-after-return detection enabled.
Discovered by Anthropic's OSS Scanner, as vulnerability
ANT-2026-N7S3EYU4.
Assisted-by: OpenAI Codex
The glyph slot belongs to the shared FreeType face. Copy its bitmap
and dimensions before releasing the face lock, then query extents
and invoke the image callback without the lock. Fail if the bitmap
copy cannot be allocated.
Add a bounded shared-font paint regression using the existing emoji
fixture. Check BGRA blob dimensions and reenter the font from the
image callback. The test crashes before the fix and passes after it.
The full Meson suite passes (274 tests).
Reported by Anthropic's OSS Scanner as ANT-2026-ANVKHBVD.
Assisted-by: OpenAI Codex
Check ensure(glyph_count) before writing Graphite output. Release the
feature values and segment and return failure when buffer growth fails.
Add a small synthetic font and a bounded regression that refuses buffer
growth via max_len. The normal path produces 164 glyphs; the failure path
retains the original input length and reports allocation failure. Include
the font generator, whose output matches the checked-in fixture.
The new regression fails before the fix under ASan and passes afterward.
All 276 tests pass with Graphite2 enabled; the regression also passes under
ASan and UBSan.
Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-HEQW39B7.
Assisted-by: OpenAI Codex
hb-cairo's per-glyph work budget was spent only on emitted path segments,
so a COLRv1 font could pay once for a clip outline (push_clip_glyph) and
then have cairo re-rasterize it for every PaintSolid/gradient/group
composite under it, up to the COLR edge limit. That is the
multiplication of limits the shared budget in hb-limits.hh exists to
prevent: a 2 KB font kept hb-view busy for over a minute on one glyph.
Charge every composite in the cairo backend, where the cost is incurred
and where the sibling backends already charge per operation (hb-raster
charges pixel area per paint). hb_cairo_context_t now counts the
segments of the current path and keeps a stack of the clip paths in
force, maintained by the push_clip_* callbacks and pop_clip; spend_paint()
charges every fill, paint, group and gradient with (1 + segments) times a
per-source weight, squared when more than one path is in force since
cairo then intersects the paths per operation. These segment and clip
counts are inputs to the existing budget_remaining counter; they are not
a separate per-callback limit. The weights (HB_BUDGET_512 for
solid/group, 1024 for linear/radial gradients, a new HB_BUDGET_8192 for
the sweep mesh pattern) follow per-composite timings measured on
cairo 1.18.
Nested color glyphs are already painted inline by the color_glyph
callback, so their composites are charged against the clips in force at
that point; no change is needed there.
Behaviour change: a glyph whose composites exceed the budget (about 32k
segment-composites, roughly a second of cairo time at hb-view's default
size) is truncated best-effort, as outline work already is. All glyphs
of the COLRv1 glyf (static and variable) and CFF2 test fonts render
byte-identically through hb-view with and without this change.
A regression test with a generated 3 KB font is added to
test/api/test-cairo.c alongside its fontTools generator; it finishes in
about a second once the paints are charged and guards against
reintroduction through the meson test timeout rather than a
discriminating assertion.
Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-38OVH0N4.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Release the face lock around solid, gradient, and custom palette
callbacks. Keep lazy FreeType color-stop reads locked and give each
getter call its own iterator, so callbacks can query the same font
without deadlocking or disturbing another stop query.
Snapshot the selected palette once per COLRv1 traversal, shared by
the bounds and paint passes. Nested paints can select a different
palette on the face; they must not change the outer paint's colors.
Return failure if the palette copy cannot be allocated. Stops remain
lazy and no cache policy or limits change.
Add a bounded callback regression with the existing COLRv1 fixture.
It queries font extents, performs nested paints with another palette,
and checks repeated and paged stop reads against the OT backend.
The original code times out; unlocking without copying the palette
fails the color comparison. The full Meson suite passes: 274 tests, no failures.
Reported by Anthropic's OSS Scanner as ANT-2026-YPLDSFHA.
Assisted-by: OpenAI Codex
IndexSubtableRecord::add_new_subtable() bounds-checks each retained
glyph's image block against the source CBDT table, but nothing
requires the blocks of different glyphs (or strikes) to be distinct
and nothing limits the total copied. A format 3 offsetArray of
0, 65535, 0, 65535, ... makes every even glyph copy the same 64 KB,
so a ~186 KB font makes one hb_subset_or_fail() peak at ~3.8 GB and
emit a ~1.97 GB font. The existing source_blob->length * 256 cap
covers only the serializer buffer holding the new CBLC, not the CBDT
side buffers.
Charge every block copied out of the source CBDT to a byte budget
that is proportional to the source table and shared across strikes,
and fail the strike when it runs out; the existing subset_size_table()
path then reverts that strike and continues. The budget lives in
cbdt_dedup_context_t, which CBLC::subset already shares across every
strike, and is set to cbdt_length * HB_SUBSET_CBDT_MAX_COPY_FACTOR, a
new limit (64) in hb-limits.hh. The charge is taken before the copy
into the per-strike buffer, so strikes that end up sharing data are
bounded as well, and it covers index formats 1/2/3 and overlapping
records, not only non-monotonic format 3 arrays. The budget defaults
to unlimited, so the direct users of the struct (test-cbdt-cache) are
unaffected; a well-formed font copies each byte at most once per
strike, so only a font whose strikes reference the table more than 64
times over loses bitmaps.
This is distinct from the integer-overflow hardening of
_copy_data_to_cbdt() in PR #6485: that bounds the final append to
cbdt_prime, this bounds the overlap amplification before the copy.
Adds test_subset_cbdt_overlapping_images, which builds the format 3
shape above and asserts the output CBDT stays within the factor
(524292 > 65536 on the unpatched tree). The api and subset suites
pass and the reproducer drops from 3767 MiB to 17 MiB.
Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-C39OXNU0.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Keep the memory-backed FT_Face blob on the hb_face_t even when the
OpenType sanitizer discards its copy. Otherwise the destroy callback
can release the FT_Face while the face or font still uses it. Return
the empty object on allocation failure before accessing that pointer.
Keep a blob loader's input bytes on the FT_Face rather than the
hb_face_t, since retained table blobs can outlive the latter. Keep the
library reference on the input blob and release it outside the static
FreeType mutex. Initialize file-loader ownership before transferring
references as well.
Add regressions for destroy-callback timing, referenced font lifetime,
and table blobs retained past the source face. All 293 tests pass,
including all eight FreeType subtests under ASan and UBSan. A separate
sanitized ownership probe passes 154 allocation-failure cases.
Discovered by Anthropic's OSS Scanner, as vulnerabilities
ANT-2026-FC0F75Y2 and ANT-2026-O2E5WAA5.
Assisted-by: OpenAI Codex
hb_cairo_glyphs_from_buffer() asserted that buffer clusters are monotone
in the buffer direction, but hb_shape() does not guarantee that:
HB_BUFFER_CLUSTER_LEVEL_CHARACTERS, shaping that hits the ops limit
mid-lookup, and Indic reordering corner cases can all produce
non-monotone clusters. The function runs from HarfBuzz's own cairo
text_to_glyphs callback on attacker-controlled text and fonts, so the
assertion was an input-dependent abort (and, with NDEBUG, an unchecked
backward walk off the ends of the utf8 buffer).
The cluster-counting loop that already walks the buffer now detects a
step against the buffer's direction and falls back to a single cairo
cluster mapping all of the utf8 to all of the glyphs, which cairo
accepts. The monotonicity assertions in the fill step then hold by
construction and glyph output is unchanged for monotone buffers.
A regression test in test/api/test-cairo.c feeds monotone and
non-monotone LTR/RTL buffers through both cluster modes and checks the
cluster counts and byte/glyph totals; it aborts on the pristine tree.
Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-T4PZ1H72.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
hb_cairo_init_scaled_font() must hand exactly one reference of the
hb_font_t to the cairo_scaled_font_t. For a face-based font face
(hb_cairo_font_face_create_for_face()) it creates the font with a
reference count of 1, but then still called hb_font_reference() before
attaching it, so the creating reference was never released. Every
finalized scaled font therefore leaked an hb_font_t, pinning its
hb_face_t, the font blob and the accelerators until the process exits.
Cairo finalizes scaled fonts during normal operation once its cache
fills, so the leak accumulates as content selects distinct sizes,
transforms or font options.
Take the extra reference only in the branch where the font is the
shared one owned by the cairo font face (the font-based constructor),
and transfer the freshly created font as-is. The set_user_data result
is now checked and the font released on failure, matching the
budget/color-cache idiom a few lines below and the font-face
constructors in the same file.
A callback installed with hb_cairo_font_face_set_font_init_func() that
returns a different font keeps its historical behavior: the returned
font is referenced rather than assumed to transfer ownership, so no
in-tree contract changes and no caller can turn into a use-after-free.
hb-view uses the font-based constructor and was unaffected.
A regression test in test/api/test-cairo.c registers a face destroy
notifier, draws through a face-based font face, flushes cairo's
scaled-font cache and asserts the face was destroyed; it fails on the
unpatched library and passes with the fix.
Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-BAUN9JN4.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
hb_cairo_paint_color_glyph() accepted the color_glyph paint callback
and drew the nested glyph with cairo_show_glyphs(), which re-enters
hb_font_paint_glyph() through a new cairo scaled font with a fresh
hb_paint_context_t. The glyph decycler, HB_MAX_NESTING_LEVEL and the
edge budget therefore start over at every level, so two glyphs that
paint each other with PaintColrGlyph recurse until the stack is
exhausted. The per-scaled-font hb_cairo_budget_t cannot bound this
either: the nested glyph is shown through a different scaled font, so
each level gets its own budget.
Decline the callback, returning false exactly as hb-raster's does, so
the COLR (and hb-ft-colr) walk paints the nested glyph inline under the
decycler and depth limits of the walk already in progress.
A regression test with two PaintColrGlyph glyphs that paint each other
is added to test/api/test-cairo.c; it aborts on the unpatched library
and passes with the fix.
Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-VPKA505E.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Glyph zero is always reserved for .notdef. Reject mappings that assign
another retained glyph to it, so the output list has one entry per id.
Also bound the resulting glyph count by the widest supported count
field, MAXP's HBUINT24. Account for the unmapped glyphs and the initial
slot before assigning ids, avoiding wraparound and oversized counts in
table subsetters. The limit applies to the count, not the highest id.
Document these constraints and test valid renumbering, gaps, ignored
remapping of .notdef, reserved-id collisions, and out-of-range counts.
The regression and stock hb-subset both reproduce the issue under ASan
before the fix. All 293 tests pass after it, including the subset suite;
the API subset tests and command-line checks also pass ASan and UBSan.
Discovered by Anthropic's OSS Scanner, as vulnerability
ANT-2026-6I1RIFMQ.
Assisted-by: OpenAI Codex
A custom glyph mapping can leave unassigned output glyph IDs beyond
the source glyph count. The preprocessing glyph-to-SID map only covers
source glyphs, so use the existing charset lookup for those gaps and
skip the map-based range shortcut there.
Compare plain and preprocessed subsets of existing name-keyed and
CID-keyed fonts with output gaps. The new regression fails under ASan
before the fix. The complete ASan/UBSan Meson suite passes afterward
(293 tests, including 23 CFF1 API subtests).
Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-42ZOI3TR.
Assisted-by: OpenAI Codex
The graph total is size_t, while the output vector allocation takes an
unsigned int. Check the total against the blob length limit before that
conversion, so the allocation and serialization context use the same
size. Totals above INT_MAX cannot produce a valid output blob anyway.
Add a public-API regression whose objects share their backing storage,
keeping its memory use small while exercising a large graph total.
Testing: meson test -C build (292 passed; check-symbols skipped on
macOS), plus test-subset-repacker with ASan and UBSan. The regression
reproduces the invalid write without the check and fails cleanly with it.
Discovered by Anthropic's OSS Scanner, as vulnerability
ANT-2026-4Q0YO46E.
Assisted-by: OpenAI Codex
The baseline fallback accepts an OpenType script tag but compared it
with hb_script_t values. Convert the tag before choosing the glyph
used to synthesize the hanging baseline.
Exercise Bengali's old and new OpenType tags, Tibetan, and the script
and language entry point. The updated test fails before the fix
(622 versus 600); the full Meson suite passes (293 tests).
Reported by Anthropic's OSS Scanner as ordinary bug ANT-2026-COIT72UF.
Assisted-by: OpenAI Codex
The point-in-quad test rejected the interior side of each edge for
both winding orders. Reverse the comparisons for rectangle and mask
intersections, and clarify how the edge normal depends on winding.
Add a regression for skew, reflected skew, and rotation, with one or
two nested rectangle clips to exercise both intersection paths. The
center pixel was transparent before the fix. The full Meson suite
passes (293 tests).
Reported by Anthropic's OSS Scanner as ordinary bug ANT-2026-AM92X98M.
Assisted-by: OpenAI Codex
Fonts without vhea returned the ascender for the vertical descender
metric. Read the descender from the synthesized vertical font extents,
as the horizontal fallback already does.
Add a regression comparing all three fallback vertical metrics with
the font extents. It fails before this change (1024 versus -1024).
The full Meson suite passes (293 tests).
Reported by Anthropic's OSS Scanner as ordinary bug ANT-2026-4UNO2SK8.
Assisted-by: OpenAI Codex
CFF1 INDEX counts are 16-bit. Serializing a larger iterator truncated
its count before reserving the offset array, then wrote offsets for
every item. Check the count before allocating or writing the offsets.
Test the CFF1 boundary and the corresponding valid CFF2 counts, and
reject a subset glyph mapping that overflows the CharStrings INDEX.
Both regressions fail before this change. The full Meson suite passes
(293 tests), including the subset and API suites.
Discovered by Anthropic's OSS Scanner, as vulnerability
ANT-2026-8ROS1VQ9.
Assisted-by: OpenAI Codex
Changing extents during painting could allocate small group surfaces
against the original root and clip, causing out-of-bounds reads and
writes. Keep all session surfaces at the root's extents.
Use the same extents for group clear charges and pixel budget
recharges, so changing the configured rectangle cannot undercount
work on the active image. Document that render clears extents rather
than deferring a mid-session change to the next image.
Adapt the pixel regression from #6450 and check the render lifecycle.
Add an internal test for new and cached group clear charges and
budget recharging, using small buffers.
Reproduced the heap overflow on main under ASan. The budget test
fails with #6450. With this change, both raster test targets pass
under ASan+UBSan and the full Meson suite passes (274 tests).
Assisted-by: OpenAI Codex
Co-authored-by: nussaiba shaikh <nussaibah@bugqore.com>
Saturated int32 extents can round up to 2^31 when converted to float.
Clamp each scaled field before converting back to hb_position_t.
Compute width and height in double relative to the stored, clamped
bearings, preserving the existing formulas when a bearing saturates.
Adapt the COLR clip-box regression from #6459 and cover positive and
negative scales. At default scale, rounding INT32_MAX up to 2^31
leaves a one-unit extent relative to the clamped bearing.
Reproduced the original float-cast-overflow under UBSan. After the
fix, the color, extents, and font-scale API tests pass under UBSan,
and the full Meson test suite passes (273 tests).
Co-authored-by: nussaiba shaikh <nussaibah@bugqore.com>
Assisted-by: OpenAI Codex
Returning false without setting a serializer error treats the CFF
subset as empty and silently drops its outlines. Record an error when
format 1 needs more than 255 encoding ranges so subsetting fails.
Reuse the many-codes fixture to check that 255 ranges still succeed
and 256 ranges fail. The regression fails before the fix.
Testing: meson test -C build (273 passed).
Assisted-by: OpenAI Codex
A format 1 Encoding can give codes to more than 255 glyphs, since
codes may repeat across ranges. When the subset keeps more than 255
of those glyphs, as with retain-gids, plan_subset_encoding() hit
assert (subset_enc_num_codes <= 0xFF).
Choose format 0 only when it can hold the codes, and fail cleanly in
the format 1 serializer instead of truncating nRanges past 255.
Add a test font whose format 1 Encoding covers 768 glyphs, and the
reporter's font to the fuzzing corpus.
Fixes: https://github.com/harfbuzz/harfbuzz/issues/6031
Assisted-by: Claude
Assisted-by: OpenAI Codex
A subroutine can push all four seac operands, return, and leave the
glyph's own endchar to consume them. Treat callsubr and callgsubr
immediately before endchar as possible seac suffixes even when no
subroutine contains endchar.
Add a synthetic CFF1 regression font for the operand-only subroutine
case.
Assisted-by: OpenAI Codex
A subroutine can terminate a glyph with endchar, and dotsection preserves
live operands. Account for both cases when deciding whether a CFF1
charstring can form a seac composite.
Cache whether any subroutine may contain endchar so ordinary fonts keep
the fast trailing-byte check. Skip component closure when all glyphs are
already retained, except when computing reusable accelerator metadata.
Add regressions for endchar in a local subroutine and operands preserved
across dotsection.
Assisted-by: OpenAI Codex
Clear flex-depth deltas when they all round to zero and reject unexpected
operators in the absolute-rounding pass. Cover static fractional operands
in a charstring that also contains blends.
Remove command-capture branches made redundant by the full-instancing
control flow.
Testing: meson test -C build (295 passed, one skipped).
Assisted-by: OpenAI Codex
Context format 6 is unavailable when HB_NO_BEYOND_64K is defined, so
do not register its dependency test in that configuration.
Tested with the default test-ot-depend target, an
HB_NO_BEYOND_64K test-ot-depend build, and the full Meson test suite.
Assisted-by: OpenAI Codex
ContextFormat3_6<MediumTypes> (context format 6) stores its input
Coverage offsets as Offset24, but depend() passed them to
context_depend_lookup() cast to HBUINT16, so every input position
after the first decoded the wrong bytes as its offset.
intersects_coverage() then followed that value to a Coverage table
sanitize never checked.
With small offsets the misread value is 0, which points at the
subtable header, and the nested lookup's dependencies are silently
dropped. A crafted rule can instead point the misread offset at bytes
shaped like a large Coverage, and CoverageFormat1_3::intersects() reads
past the end of the GSUB blob (ASan heap-buffer-overflow via
hb_subset_depend_from_face_or_fail).
The other ContextFormat3_6 methods pass coverageZ.arrayZ + 1 as is and
let glyph_data_t pick the width. Do the same here.
ChainContextFormat3 has the same cast but only has a 16-bit
instantiation.
Add a format 6 font and test to test-ot-depend.c; it fails without
the fix. Tested with meson test under ASan+UBSan with
-Dexperimental_api=true.
Assisted-by: Claude
Without coordinates, blend_arg_t stores only a flat delta vector.
A blend used as a later blend's delta loses its own deltas, changing
outlines during partial instancing or desubroutinization.
Reject that case in the usage and flatten passes. Retained subroutine
collection needs only blend identity, and full instancing evaluates
blends numerically, so keep both paths working. Mark CFF2 planning
failures as serialization errors so the subset API returns failure
instead of a face missing its outline table.
Add a generated two-axis font and exercise retained subsetting, full
instancing, rejected partial/desubroutinized products, and supported
nested defaults. The regression fails before the fix. Full Meson suite:
272 passed, one skipped.
Assisted-by: OpenAI Codex
A partial TrueType instance can round a child's points and its
component offset independently. A later full instance at the remaining
axes' defaults recalculates bounds but leaves the source glyph header
unchanged, so it can disagree with the stored component geometry and
with the updated global bounds.
Compile glyphs through the owned-byte path for default pins as well,
and free those buffers on both serialization and failure paths.
Add a generated regression where partial instancing stores child xMax
11 and component offset 1, then default instancing must write xMax 12.
The assertion fails before the fix. The full Meson suite passes with
272 tests successful and one skipped; OTS accepts the source fixture.
Assisted-by: OpenAI Codex <codex@openai.com>
Retained subroutine remapping assumes the number preceding a call is
in the same program. Caller-supplied targets violate that assumption
and can silently change glyph outlines when unused subroutines are
removed. Enforce the existing support boundary in CFF1 and CFF2.
Report plan failures as serialization errors, rather than silently
dropping the CFF table. Explicit desubroutinization still handles the
regression fonts and preserves both outlines.
Validation: full Meson suite, 272 passed and one skipped.
Assisted-by: OpenAI Codex
Private DICT entries can accumulate several CFF2 blends before their
final operator. An eight-bit byte count truncated these spans modulo
256 during serialization, producing malformed output.
Use a full-width count and cover a 579-byte Private DICT with forty
variation regions and fourteen blended BlueValues.
Validation: full Meson suite, 272 passed and one skipped.
Assisted-by: OpenAI Codex
Rounding relative charstring operands independently accumulates errors,
opening contours and displacing stem hints after instancing. Track
absolute outline coordinates and stem edges, round their defaults and
surviving variation deltas, then emit relative operands again.
Preserve compact path operators. Conservatively retain relative rounding
for every glyph containing flex1, avoiding variation-dependent direction
analysis. Leave charstrings without blends unchanged.
Add a generated regression font covering closed contours, compact curves,
flexes, masks, and fractional static operands. Check full and partial
instances, contour closure, point accuracy, and the flex1 fallback. Refresh
the existing serialized CFF expectations.
Testing: the complete Meson suite passes (294 passed, one skipped), as do
the CFF2 API tests under ASan and UBSan.
See-also: https://github.com/fonttools/fonttools/pull/4338
Assisted-by: OpenAI Codex
When every retained glyph is empty, the glyf instancer leaves the
head bounds accumulator at its inverted initial sentinels. Reset the
accumulator after processing all glyphs so head has zero bounds.
Extend the zero-contour instruction regression to check bounds for
partial/full instances and default pins, with and without hints.
The regression fails before the fix. Full Meson: 272 passed, one skipped.
Assisted-by: OpenAI Codex
OFF 2026 section 5.3.3.11.2 permits larger ItemVariationStores and
specifies a saturated length field of 65535. Partial CFF2 instancing
currently rejects these stores while serializing them.
Saturate the field while retaining the 32-bit offset size check.
Add a font with 200 referenced regions over 60 axes and exercise
partial instancing and extents at three locations. The test fails
before the fix because the output loses its CFF2 table.
Validation: full Meson suite, 272 passed and one skipped.
Assisted-by: OpenAI Codex
The ordinary CFF2 Private DICT parser ignores hint blend operators but
leaves their raw operands on its stack. Multiple valid blend groups can
therefore overflow the stack during font loading, making glyph extents
and drawing fail. The subset parser already discards these operands.
Clear ignored operands after each hint blend in the ordinary parser too.
Add a synthetic font with two seven-result groups over 40 regions and
check its glyph extents at default and non-default locations. Each group
fits the stack, but their raw operands together exceed its capacity.
The regression fails before the fix and passes after. The complete
Meson suite passes: 272 tests passed, one skipped.
Assisted-by: Codex <noreply@openai.com>
Instancing a CFF2 font with only empty outlines leaves the head bounds
accumulator at its inverted initialization sentinels. These are then
serialized as xMin=yMin=32767 and xMax=yMax=-32767.
Reset an empty accumulator to zero after collecting CFF2 extents. This
also provides a valid FontBBox if the instance is downgraded to CFF1.
Add a reproducible synthetic font and an API regression that fails before
the fix. The regression also checks preservation of the empty glyph's
advance and bearing. The complete Meson suite passes: 272 tests passed,
one skipped.
Assisted-by: Codex <noreply@openai.com>
hb_shape_justify() copies the buffer text so it can reshape while
solving for the axis value, but only the solver path at the end
frees the copy. The three "nothing to solve" success returns
(default advance already in range, maximum expansion still short of
the target, maximum shrink still above it) and the three shaping
failure returns leak it, so ordinary line justification leaks one
text copy per call.
Free it with a scope guard right after the allocation, as the rest
of the tree does, and drop the explicit free at the end.
Reproduced with leaks --atExit on a plain experimental-API build:
four calls on Estedad-VF.ttf give four ROOT LEAKs at hb-shape.cc:319,
none with the fix. Add test-shape-justify.c covering all five paths
under the experimental-API test list so the asan-ubsan job runs it
under LeakSanitizer. The full ASan+UBSan Meson suite passes
(289 ok, 2 skipped).
Assisted-by: Claude
* [glyf] Charge composite offsets to the work budget
Composite glyphs prepare component offsets before descending into
children. This work was not charged to the shared rendering budget,
including offsets for children later skipped by cycle detection.
Repeated preparation through COLR extents could time out the shaper.
Charge each offset before loading it and restore the scratch length
on failure. Add a cyclic-composite budget regression and the minimized
fuzzer testcase.
The full Meson suite passes (292 passed, one skipped). The reproducer
completes under ASan/UBSan in 17 seconds instead of timing out after
60 seconds. A failing-allocation variant passes 100 runs.
Fixes: https://oss-fuzz.com/testcase-detail/6193853460447232
Assisted-by: OpenAI Codex
* [glyf] Charge component preparation as traversal work
Component preparation parses records and updates scratch vectors, but
charging one unit per record still allows excessive work within the
shared budget. Use the existing 16-unit glyph traversal charge for
preparing a component, including children skipped by cycle detection.
Increase the cyclic-composite regression's budget so it also catches
the undercharged preparation path. The reproducer now takes about
1.1 seconds under ASan/UBSan and 0.03 seconds in the normal build.
Tested with the full Meson suite (292 passed, one skipped), 100
sanitizer reproducer runs, and 100 failing-allocation variant runs.
Assisted-by: OpenAI Codex
Unbounded variation deltas can overflow integer conversions while
instancing COLRv1 paints and clip boxes. Clamp coordinates, radii,
affine coefficients, and fixed-point values before narrowing them.
Keep affine base precision and existing alpha and clip rounding.
Add a generated font and regression checks for positive and negative
overflow in full and composed instances. Parenthesize the fixed-point
roundf argument so its template comma is safe for macro expansion.
Validation: meson compile -C build and meson test -C build pass
(292 tests passed, one skipped). The font regenerates identically.
Assisted-by: OpenAI Codex
hb_font_set_variation() seeds its new design coords from the font's
existing ones for every axis of the current face, trusting an assert
that their lengths match. hb_font_set_face() keeps the font's
variation coords, which stay sized for the old face, so switching to
a face with more axes and then calling hb_font_set_variation() reads
past the old array: a heap-buffer-overflow read with NDEBUG, an
assertion failure otherwise.
Only reuse the existing design coords when their length matches the
current face; otherwise start from the defaults, as when none are set.
Reproduced the overflow under ASan with NDEBUG and the assertion
failure in the default build. Added a regression test in test-font.c
that fails without the fix. The full ASan+UBSan Meson suite passes.
Assisted-by: Claude