Heap buffer overflow in Base (CVE-2026-19156)
A heap buffer overflow occurs in the shared base::SubstringSetMatcher when duplicate pattern strings are supplied, because the uniqueness check only exists in debug builds. An attacker who can influence the pattern set, such as through extension declarativeNetRequest regex rules, could cause a small out-of-bounds write in the browser process.
Originally disclosed on Chrome VRP
- Fix shipped in 28 days
VULNERABILITY DETAILS
Heap-buffer-overflow (4-byte out-of-bounds write) in base::SubstringSetMatcher during tree construction (Build()), reported by GWP-ASan: WRITE of size 4, 0 bytes to the right of a 1040-byte region.
Root cause: SubstringSetMatcher::Build() requires unique pattern strings, but its uniqueness CHECK is compiled only in DCHECK-enabled builds and is absent from release builds. Duplicate strings terminate at the same Aho-Corasick node, causing repeated calls to SetMatchID() and redundant kMatchIDLabel edges. Each node's edge array is capped at 260 four-byte entries (1040 bytes). In the repro, 256 character edges plus one valid and three duplicate match-id edges fill the array. When Build() subsequently adds the failure edge, SetFailure() calls SetEdge() to write the 261st edge, four bytes past the allocation.
The debug-only uniqueness check is compiled out of release builds, so nothing prevents the corruption there. GWP-ASan caught it via a guard page; without the guard page (the common, unsampled case) it is a silent 4-byte corruption of the adjacent heap allocation. The write value is a packed AhoCorasickEdge (9-bit label + 23-bit node index), and both the location and the node-index value are influenced by the input pattern set.
Reachability: SubstringSetMatcher is a shared //base primitive. It is fed attacker-influenceable input through the extension declarativeNetRequest regex path (RegexRulesMatcher/RegexSetMatcher) -- FilteredRE2 emits candidate "atom" substrings that are passed to SubstringSetMatcher::Build() -- and is also used by components/url_matcher.
VERSION
Chrome Version: 152.0.4141.0; the vulnerable code is long-standing, so all current stable/beta/dev channels are affected. Operating System: Observed on Windows via GWP-ASan. The affected code is platform-independent C++ in //base, so it is not OS-specific.
REPRODUCTION CASE
This is not a web-page bug; it triggers in the browser process during matcher construction.
Minimal deterministic repro (unit test): register the following patterns and call SubstringSetMatcher::Build():
- "a" (one pattern) - so node "ba" gets a stored non-root failure edge,
- "ba" four times (distinct IDs) — the duplicate strings that add extra match-id edges,
- "ba" + <byte> for all 256 byte values — fills node "ba" to its 256 character-edge maximum.
Node "ba" reaches 256 + 4 = 260 edges (the cap); the failure edge added next is the overflowing 261st write. Must be built without DCHECKs (e.g. ASan with dcheck_always_on=false), because Build()'s debug-only uniqueness check otherwise aborts before the release path is reached.
Ready-to-run test (drop into base/substring_set_matcher/substring_set_matcher_unittest.cc):
// Regression test for a heap-buffer-overflow in AhoCorasickNode::SetEdge().
// Duplicate pattern strings give one node multiple kMatchIDLabel edges. Node
// "ba" reaches 256 char edges + 4 duplicate match IDs = 260 (the storage cap),
// so the failure edge added next is the overflowing 261st SetEdge() call.
// Built only without DCHECKs: the duplicate strings trip Build()'s DCHECK-only
// uniqueness check before this release-only overflow path is reached.
#if !DCHECK_IS_ON()
TEST(SubstringSetMatcherTest, DuplicatePatternEdgeOverflow) {
std::vector<MatcherStringPattern> patterns;
MatcherStringPattern::ID id = 0;
// "a" is a pattern so node "ba" gets a non-root failure edge.
patterns.emplace_back("a", id++);
// Four identical "ba" patterns -> four match-ID edges (three illegal dups).
patterns.emplace_back("ba", id++);
patterns.emplace_back("ba", id++);
patterns.emplace_back("ba", id++);
patterns.emplace_back("ba", id++);
// 256 character children on node "ba".
for (int i = 0; i < 256; ++i) {
std::string str;
str.push_back('b');
str.push_back('a');
str.push_back(static_cast<char>(i));
patterns.emplace_back(str, id++);
}
SubstringSetMatcher matcher;
matcher.Build(patterns);
}
#endif // !DCHECK_IS_ON()
POTENTIAL FIX
Make SetMatchID() idempotent. A node can end at most one pattern, so repeated calls for a duplicate string should keep the first match ID and add no further edge.
File: base/substring_set_matcher/substring_set_matcher.h
void SetMatchID(MatcherStringPattern::ID id) {
// A node ends at most one pattern; a duplicate would add a second
// kMatchIDLabel edge that can overflow the node's storage in SetEdge().
if (IsEndOfPattern()) {
return;
}
DCHECK(id < kInvalidNodeID); // This is enforced by Build().
SetEdge(kMatchIDLabel, static_cast<NodeID>(id));
has_outputs_ = true;
}
This preserves behavior for valid unique inputs while preventing redundant match-ID edges from exhausting the node’s edge storage in release builds.
FOR CRASHES, PLEASE INCLUDE THE FOLLOWING ADDITIONAL INFORMATION
Type of crash: browser process Crash State:
#0 base::SubstringSetMatcher::AhoCorasickNode::SetEdge
base/substring_set_matcher/substring_set_matcher.cc:479
#1 base::SubstringSetMatcher::AhoCorasickNode::SetFailure
base/substring_set_matcher/substring_set_matcher.cc:490
#2 base::SubstringSetMatcher::CreateFailureAndOutputEdges
base/substring_set_matcher/substring_set_matcher.cc:318
#3 base::SubstringSetMatcher::BuildAhoCorasickTree
base/substring_set_matcher/substring_set_matcher.cc:224
#4 base::SubstringSetMatcher::Build
base/substring_set_matcher/substring_set_matcher.cc:90
#5 base::SubstringSetMatcher::Build
base/substring_set_matcher/substring_set_matcher.cc:51
#6 extensions::declarative_net_request::RegexRulesMatcher::MatchHelper::InitializeMatcher
extensions/browser/api/declarative_net_request/regex_rules_matcher.cc:331
#7 extensions::declarative_net_request::RegexRulesMatcher::MatchHelper::MatchHelper
extensions/browser/api/declarative_net_request/regex_rules_matcher.cc:194
#8 extensions::declarative_net_request::RegexRulesMatcher::RegexRulesMatcher
extensions/browser/api/declarative_net_request/regex_rules_matcher.cc:110
#9 extensions::declarative_net_request::RulesetMatcher::RulesetMatcher
extensions/browser/api/declarative_net_request/ruleset_matcher.cc:257
#10 std::__Cr::make_unique
third_party/libc++/src/include/__memory/unique_ptr.h:756
#11 extensions::declarative_net_request::RulesetSource::CreateVerifiedMatcher
extensions/browser/api/declarative_net_request/ruleset_source.cc:142
#12 extensions::declarative_net_request::FileBackedRulesetSource::CreateVerifiedMatcher
extensions/browser/api/declarative_net_request/file_backed_ruleset_source.cc:465
#13 extensions::declarative_net_request::RulesetInfo::CreateVerifiedMatcher
extensions/browser/api/declarative_net_request/file_sequence_helper.cc:386
#14 extensions::declarative_net_request::FileSequenceHelper::UpdateDynamicRules
extensions/browser/api/declarative_net_request/file_sequence_helper.cc:489
FileSequenceHelper::UpdateDynamicRules was dispatched asynchronously through base::OnceCallback on a base::ThreadPool worker. Generic callback and worker-thread frames are omitted
CREDIT INFORMATION
Externally reported security bugs may appear in Chrome release notes. If this bug is included, how would you like to be credited? Reporter credit: Viktoria Zlatinova
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The uniqueness check for pattern strings is compiled only into debug builds, so release builds allow duplicate strings to add redundant match-id edges until the node's fixed edge array overflows.
Impact
The overflow is a silent four-byte corruption of the adjacent heap allocation in normal unsampled builds, and the write location and value are influenced by the input pattern set; it was caught here only because GWP-ASan placed a guard page after the allocation.
What the attacker needed
Ability to supply duplicate patterns; release build without debug checks; browser process matcher construction
The fix
SetMatchID() should be made idempotent so a node keeps only its first match ID and adds no further edge for duplicate strings.
How it was found
- Register a single-character pattern so the target node gets a non-root failure edge.
- Register the same two-character pattern four times with distinct IDs to add duplicate match-id edges.
- Register that two-character pattern followed by every possible byte value to fill the node's character edges.
- Build the matcher without debug checks enabled so the release-only overflow path is reached.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A matcher is a piece of code that checks text against a list of patterns. It stores each pattern in a tree, and each tree node has a fixed-size list of outgoing links. If the same pattern is added several times, extra links are created until the list overflows and a few bytes are written past the end of the memory block, which can corrupt nearby data.
What is Memory corruption?
Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.