Table records of a font file may overlap, so the sum of the passed
-through table lengths is not bounded by the size of the font: with
HB_SUBSET_FLAGS_PASSTHROUGH_UNRECOGNIZED a 262 KB font of aliased
records made _hb_face_builder_data_reference_blob() allocate and fill a
~4 GiB buffer, only for hb_blob_create() to refuse it.
Accumulate face_length with hb_unsigned_add_overflows() and return
nullptr as soon as the total reaches 1u<<31, the length
hb_blob_create_or_fail() refuses, so the 2-4 GiB allocate-fill-free
cycle no longer happens; the serializer's own bounds already prevented
any overrun once the sum wrapped. Output for every input that succeeded
before is unchanged.
The endless retry that turned this into a hang is fixed in the
companion commit (hb_face_reference_blob() no longer recurses into
itself on the fallback builder).
Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-NCMHVO1A.
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>
Format 2 class values are byte offsets, but ExtendedTypes::offsetToIndex
leaves them unchanged. Use byteOffsetToIndex to convert their sum to an
FWORD index. ObsoleteTypes retains the existing kern format 2 behavior.
Add a synthetic font and shaping regressions covering negative and
positive kerning, the final array entry, zero classes, missing lookup
entries, and disabled kerning.
The shaping regression fails without the fix. The full Meson test suite
passes, and Helvetica Light's LY, AY, Hi, and HH kerning matches CoreText.
Fixes: https://github.com/harfbuzz/harfbuzz/issues/6461
Assisted-by: OpenAI Codex
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
Ligature split points skipped null offsets while the ranges used to
clone and shrink subtables counted every slot. Advance the split index
for null offsets too, so both stages refer to the same ligatures.
Also reject an inverted range after narrowing it to the remaining
links, before calculating the number of ligatures to allocate.
Add a regression that compares the split graph with the expected
subtables when one ligature set has trailing null offsets.
Testing: meson test -C build (292 passed; check-symbols skipped on
macOS), plus the repacker test and shared-ligature font check with
ASan and UBSan.
Discovered by Anthropic's OSS Scanner, as vulnerability
ANT-2026-9C9WB0KM.
Assisted-by: OpenAI Codex
Reject allocation requests above INT_MAX before growing the capacity,
and cap geometric growth at that limit. Otherwise the unsigned growth
loop can wrap, or a successful allocation can store a negative value
in the signed capacity field. Normalize exact requests before checking
the limit so the existing length is included.
Test both normal and exact oversized requests, preservation of existing
contents on failure, and saturation of geometric growth. Intercept the
allocator in the unit test to avoid allocating large buffers. The new
regression fails before the fix. All 293 tests pass, and test-vector
passes under ASan and UBSan.
Discovered by Anthropic's OSS Scanner, as vulnerability
ANT-2026-N6HMDRS8.
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 saturating size helper returns size_t, so assigning its product to
unsigned can truncate it before the UINT_MAX check. Check multiplication
at unsigned width before resizing the buffer used by compile_unsafe().
Validated the reported high-count case under ASan/UBSan: it fails cleanly
after this change. A small control produces byte-identical output. The
ASan/UBSan Meson suite passes; check-symbols also passes after generating
its symbol manifests.
The large input remains a manual regression because it requires several
GB of memory.
Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-V0UYCX4C.
Assisted-by: OpenAI Codex
A missing component skipped a fallback ligature but left its partial
component list counted. Later ligatures then used the wrong letters.
Write tentative components at the current offset and advance the
count only after every component has matched.
Add a generated GSUB-less font and two shaping regressions, covering
both the wrong ligature and the valid ligature it displaced, with ot
and ft font functions. All four cases fail before the fix. The full
Meson suite passes (293 tests, 6227 in-house shaping subtests).
Reported by Anthropic's OSS Scanner as ordinary bug ANT-2026-EMRGZ57Y.
Assisted-by: OpenAI Codex
The class-zero intersection loop skipped ranges starting at glyph 0
without advancing the last glyph, and consulted a separate iterator
instead of the range being visited. Probe only actual gaps and always
advance past each range, so unlisted glyphs retain class-zero rules.
Check all 256 glyph sets over eight glyphs against per-glyph class
lookup for empty, contiguous, gapped, and explicit class-zero ranges.
The regression fails on the old source. The full Meson suite passes
(293 tests), including shape and subset.
Reported by Anthropic's OSS Scanner as ordinary bug ANT-2026-K9HEP9ZU.
Assisted-by: OpenAI Codex
The PDF draw renderer emitted paths in Y-up coordinates but vertically
mirrored the MediaBox and background rectangle. Use the same extents
for the content, page, and background, matching the paint renderer.
Regenerate the existing PDF fixture with hb-vector. Only the page box
and background coordinates change. Its page now covers the glyphs'
outline Y range; the old page did not. The updated vector regression
fails on the old source. The full Meson suite passes (293 tests).
Reported by Anthropic's OSS Scanner as ordinary bug ANT-2026-0ER2GEWZ.
Assisted-by: OpenAI Codex
The SVG body is flipped from font coordinates once at render time.
The path-clip callback still emitted its own vertical flip from the
older renderer, mirroring the clip relative to the drawing. Remove
that transform, matching rectangle and glyph clips.
Add a paint/show-extents vector regression and generate its expected
SVG with hb-vector. It fails on the old code. The full Meson suite
passes (293 tests).
Reported by Anthropic's OSS Scanner as ordinary bug ANT-2026-BZKWFGVZ.
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
* [var] Recalculate intermediate tuples with a cached zero scalar
The shared-tuple scalar cache describes the default region around a
shared peak. An intermediate region can extend beyond that peak, so a
cached zero need not mean its own contribution is zero. Only reuse a
cached one for intermediate tuples; otherwise evaluate their region.
Check cached and uncached results across the axis range and in both
tuple evaluation orders. The regression fails before the fix. The
full Meson suite passes (293 tests), including the shape suite.
Reported by Anthropic's OSS Scanner as ordinary bug ANT-2026-RTBS23VC.
Assisted-by: OpenAI Codex
* [var] Drop cache reuse for intermediate tuples
Keep the plain shared-tuple cache fast path and remove the secondary
probe for intermediate tuples. Evaluate their own regions and disable
cache writes before the axis loop, including at exact peak locations.
This also removes the redundant per-axis cache-pointer reset.
The full Meson suite passes (293 tests), including the cache regression
and the shape and subset suites.
Follow-up for ordinary bug ANT-2026-RTBS23VC.
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
The bounds vectors used to rebuild hhea and vhea expect non-negative
widths and heights, with a sentinel for glyphs without outlines.
CFF2 instancing stored negative extents.height values and replaced the
sentinel for empty glyphs. Store yMax - yMin and preserve empty bounds.
Regenerate the three affected expected fonts through the subset test
generator. Only header metrics and checksums change. The new vhea
values agree with FontTools recalculation from the glyph outlines.
Both affected test cases fail without the source fix; the full Meson
suite passes with it (293 tests).
Reported by Anthropic's OSS Scanner as ordinary bug ANT-2026-3LQ6CVVN.
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
Windows headers define small as char, so the local extent variable
breaks compilation in both MSVC CI configurations. Rename it to
small_extents.
Reproduced the failure with the macro defined and verified that the
same compilation succeeds after the rename. The MinGW cross-compiler
syntax check and full Meson suite pass (274 tests).
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
After computing subroutine closure, reuse source charstrings and
subroutines when every retained subroutine keeps its original number.
This avoids re-encoding full identity CFF1 subsets while preserving
the existing pruning behavior when any subroutine is unused.
The full Meson test suite passes (295 passed, 1 skipped).
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
* Don't divide by zero interpolating duplicate trak tracks
TrackData::get_tracking() brackets the requested track value (always
0 when shaping) between entries i and j and interpolates with
(track - t0) / (t1 - t0). The bracketing scan doesn't assume the
entries are sorted or distinct, so two entries that both have track
value 0.0 end with i = 1, j = 0. That skips the exact-match return
and computes 0/0. The NaN reaches hb_font_t::em_multf(), where the
cast to hb_position_t is undefined (UBSan float-cast-overflow at
hb-font.hh:1167); in practice the advance becomes INT_MIN on x86 and
the tracking is dropped on arm64.
Sanitize accepts such a table, so any font with STAT plus this trak
reaches it from hb_shape(); the CoreText font funcs call the same
getter.
Handle t0 == t1 the way TrackTableEntry::interpolate_at() already
handles equal sizes, by averaging the two values.
Added a 108-byte font to the aat-trak shape tests. It fails without
the fix and passes with it. meson test passes on an ASan+UBSan
debug build.
Assisted-by: Claude
* [aat] Pin duplicate-trak test to ot font funcs
The 108-byte test font only carries STAT and trak, with no head,
hhea or hmtx. The ot font funcs give each glyph a 500 advance, but
FreeType reports 1000 and DirectWrite refuses to load the font, so
the ft and directwrite runs of the test disagreed with the expected
output. The test only needs to exercise the trak interpolation,
so pin it to --font-funcs=ot like other minimal-font tests.
Tested with meson test -C build; the shape suites pass with
FreeType enabled.
Assisted-by: Claude
Split long CFF charset runs into format 1 chunks and compare the
resulting size with formats 0 and 2. Previously, any run longer than
256 glyphs forced all ranges to format 2.
This reduces the CFF table for NotoSansSC-Thin.otf by 13,938 bytes
without changing decoded table contents.
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