mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-28 09:09:13 +01:00
[layout] Charge GSUB/GPOS sanitize-time arrays to max_ops (#6631)
* [sanitize] Charge ChainRule backtrack/input/lookahead arrays to max_ops ChainRule::sanitize() checks the length of each of its three arrays but only sanitizes the trailing LookupRecord array, so it never charges max_ops for the bytes it skipped over. A table with many ChainRuleSet offsets all pointing at one large ChainRule could therefore be sanitized in time proportional to offsets x rule size, escaping the sanitizer's work bound (restoring the accounting removed by385896ff6). Charge the skipped span (from this to the LookupRecord array) to check_ops before sanitizing the records. Adds a fuzzer regression font. Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-EFNNHRHV. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * [GPOS] Charge zero-size ValueRecord arrays to the sanitizer op budget When a ValueFormat is empty its records take no bytes, so ValueFormat::sanitize_values() and PairPosFormat2::sanitize() pass check_range() without charging max_ops for the records, while later code (the subsetter, variation-index collection) still walks count records. A tiny table can thus declare a huge valueCount / class matrix and cost the subsetter CPU out of proportion to its size. Charge count ops when the record size / stride is zero, following the918193ebfprecedent. Adds two fuzzer regression fonts. Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-HFGOLC64. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
1 parent
c67232c237
commit
8f93b6d21b
5 files changed
+15
No files matched your search
@@ -182,6 +182,11 @@ struct PairPosFormat2_4 : ValueBase
|
||||
return_trace (c->check_range ((const void *) values,
|
||||
count,
|
||||
stride) &&
|
||||
/* Records of two empty ValueFormats take no bytes, so the
|
||||
* range check neither bounds count nor charges for it.
|
||||
* Manually modify the sanitizer max ops to take this into
|
||||
* account. */
|
||||
(likely (stride) || c->check_ops (count)) &&
|
||||
(c->lazy_some_gpos ||
|
||||
(valueFormat1.sanitize_values_stride_unsafe (c, this, &values[0], count, stride) &&
|
||||
valueFormat2.sanitize_values_stride_unsafe (c, this, &values[len1], count, stride))));
|
||||
|
||||
@@ -415,6 +415,12 @@ struct ValueFormat : HBUINT16
|
||||
|
||||
if (!c->check_range (values, count, size)) return_trace (false);
|
||||
|
||||
/* Records of an empty ValueFormat take no bytes, so the range check
|
||||
* neither bounds count nor charges for it, while later code (eg. the
|
||||
* subsetter) still walks count records. Manually modify the sanitizer
|
||||
* max ops to take this into account. */
|
||||
if (unlikely (!size && !c->check_ops (count))) return_trace (false);
|
||||
|
||||
if (c->lazy_some_gpos)
|
||||
return_trace (true);
|
||||
|
||||
|
||||
@@ -4910,6 +4910,10 @@ struct ChainRule
|
||||
if (unlikely (!lookahead.len.sanitize (c))) return_trace (false);
|
||||
hb_barrier ();
|
||||
const auto &lookup = StructAfter<decltype (lookupX)> (lookahead);
|
||||
/* The length checks above don't charge max_ops for the arrays they
|
||||
* skipped over; charge them here so that many offsets pointing at
|
||||
* the same large rule cannot escape the sanitizer's work bound. */
|
||||
if (unlikely (!c->check_ops ((const char *) &lookup - (const char *) this))) return_trace (false);
|
||||
return_trace (likely (lookup.sanitize (c)));
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Reference in new issue
Block a user