Use after free in DOM (CVE-2026-17694)
The ElementDataCache in Chromium's Blink engine fails to filter out reserved sentinel hash values (0 and 0xFFFFFFFF) before inserting them into a hash map. This causes the garbage collector to skip tracing the bucket, leading to a use-after-free when the cached object is later dereferenced.
Google Chrome
Originally disclosed on Chrome VRP
- Fix shipped in 2 months
Project Fortify, an experimental security project, has identified the following potential security issue. If you're a feature owner CC-ed on this bug, please do your best to review these reports. Please see https://chromium.googlesource.com/chromium/src/+/main/docs/security/ai-generated-security-bugs-faq.md for more information.
Overview: ElementDataCache fails to sanitize hash keys before inserting them into shareable_element_data_cache_, allowing reserved sentinel values (0 and 0xFFFFFFFF) to be stored in release builds. During garbage collection, Oilpan tracing skips the bucket containing the sentinel key, resulting in the cached ShareableElementData being prematurely swept. Subsequent lookups retrieve and dereference this swept object, potentially leading to a high-severity Use-After-Free (UAF) in the renderer process.
Affected files:
third_party/blink/renderer/core/dom/element_data_cache.ccthird_party/blink/renderer/core/dom/element_data_cache.h
Estimated timestamp from git blame: 2025-01-06
Root Cause
In third_party/blink/renderer/core/dom/element_data_cache.cc, the function ElementDataCache::CachedShareableElementDataWithAttributes retrieves a key using HashInts and inserts it directly into the shareable_element_data_cache_ map without filtering out reserved sentinel keys:
unsigned hash = HashInts(tag_name->GetHash(), AttributeHash(attributes));
ShareableElementDataCache::ValueType* it =
shareable_element_data_cache_.insert(hash, std::pair(nullptr, nullptr))
.stored_value;
The backing cache shareable_element_data_cache_ is a HeapHashMap defined in element_data_cache.h as:
using ShareableElementDataCache =
HeapHashMap<unsigned,
std::pair<const StringImpl*, Member<ShareableElementData>>,
AlreadyHashedTraits>;
Because it uses AlreadyHashedTraits (which inherits from GenericHashTraits<unsigned> -> IntHashTraits<unsigned>), the keys are not re-hashed. Under IntHashTraits<unsigned>, the hash table reserves two sentinel values:
EmptyValue() == 0DeletedValue() == 0xFFFFFFFF(i.e.static_cast<unsigned>(-1))
Normally, when custom or raw integer hashes are used directly as table keys, sentinel collisions must be avoided. For example, the CSS MatchedPropertiesCache handles this safely:
// third_party/blink/renderer/core/css/resolver/matched_properties_cache.cc
if (hash == HashTraits<unsigned>::EmptyValue() ||
hash == HashTraits<unsigned>::DeletedValue()) {
hash ^= 0x80000000;
}
However, this mitigation is missing in ElementDataCache::CachedShareableElementDataWithAttributes, allowing raw sentinel hash values to be inserted directly into the hash table.
Oilpan Tracing Bypass and Use-After-Free (UAF)
In official release builds (where the assertion DCHECK(!IsEmptyOrDeletedBucket(*entry)) is compiled out), the table successfully stores the entry at the sentinel key 0xFFFFFFFF.
During Garbage Collection, Oilpan traces the backing storage of HeapHashMap but explicitly skips buckets whose key matches the empty or deleted sentinels to avoid scanning inactive entries:
// third_party/blink/renderer/platform/heap/collection_support/heap_hash_table_backing.h
if (!IsHashTraitsEmptyOrDeletedValue<typename Table::KeyTraitsType>(
*concurrent_bucket.key())) { // <--- Returns true for 0xFFFFFFFF, skipping the bucket
...Trace(visitor, concurrent_bucket.bucket());
}
Because tracing is skipped, the strong reference Member<ShareableElementData> inside that bucket is never marked by the garbage collector. When GC completes, the underlying ShareableElementData object is swept and reclaimed, leaving a dangling pointer in the active cache slot.
On subsequent lookup for the same key, because AlreadyHashedTraits::kSafeToCompareToEmptyOrDeleted is true, the Equal() comparison is evaluated before checking IsDeletedBucket(). This matches 0xFFFFFFFF == 0xFFFFFFFF and retrieves the stale slot.
ElementDataCache::CachedShareableElementDataWithAttributes then evaluates the returned value:
if (it->value.second == nullptr || it->value.first != tag_name ||
!HasSameAttributes(attributes, *it->value.second)) { // <--- Dereferences swept object (UAF)
If the comparison evaluates to false, the dangling pointer is returned to the element creation logic, resulting in a long-lived dangling pointer that can be leveraged to execute code within the renderer process.
Potential Steps to Reproduce
(Note: These are potential steps as our analysis has been conducted statically without a functional runtime environment or PoC)
- Navigate to a webpage hosting malicious JavaScript.
- The JavaScript dynamically creates various combinations of tag names and attribute sets on helper elements to locate a set whose pointers and hash key map exactly to
0xFFFFFFFFunder the deterministicHashIntsimplementation. - The page streams or parses an HTML element with this exact combination, forcing the insertion of key
0xFFFFFFFFin theElementDataCache. - The page drops all external references to the element and its
ShareableElementData. - Trigger an Oilpan Garbage Collection cycle. Since the bucket at key
0xFFFFFFFFis treated as a deleted sentinel, the tracing phase skips it and sweeps theShareableElementDataobject. - Trigger the creation of another element with the same attributes. The cache returns the dangling pointer to the swept memory, causing a Use-After-Free during attribute verification or subsequent styling.
Recommended Fix
Sanitize the computed hash key in CachedShareableElementDataWithAttributes to avoid reserved sentinel values before attempting to lookup or insert into the hash map:
unsigned hash = HashInts(tag_name->GetHash(), AttributeHash(attributes));
if (hash == HashTraits<unsigned>::EmptyValue() ||
hash == HashTraits<unsigned>::DeletedValue()) {
hash ^= 0x80000000;
}
This ensures sentinel values are never used as active keys in HeapHashMap.
Evaluated with Chrome root at commit: 5133b93d189b383c37805b1cf3a9d2dbfe8d7379
Results so far have been promising, but there can be wrong deductions. Feel free to adjust as follows:
- If you are familiar with the severity guidelines, you may adjust the severity.
- If this is a false positive, and there's no work to be done, please close as WAI.
- If there is work to do here but not a vulnerability, please change the issue type to Task/Bug/FR.
Data from false positives will be used to improve accuracy over time. And please feel free to reach out to me directly if you have concerns or feedback on the project.
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
Likely the hash key computed by HashInts is inserted directly into a HeapHashMap without checking for reserved sentinel values, so the garbage collector skips tracing that bucket.
Impact
A remote attacker could potentially execute arbitrary code within the renderer process by exploiting the use-after-free, though the report notes the analysis is static and no proof-of-concept exists.
What the attacker needed
Victim visits a malicious webpage; JavaScript enabled; release build of Chromium
The fix
The hash key should be sanitised to avoid reserved sentinel values before insertion, for example by XORing with 0x80000000 when the hash equals an empty or deleted value.
How it was found
- Navigate to a webpage hosting malicious JavaScript.
- The JavaScript dynamically creates various combinations of tag names and attribute sets on helper elements to locate a set whose pointers and hash key map exactly to 0xFFFFFFFF under the deterministic HashInts implementation.
- The page streams or parses an HTML element with this exact combination, forcing the insertion of key 0xFFFFFFFF in the ElementDataCache.
- The page drops all external references to the element and its ShareableElementData.
- Trigger an Oilpan Garbage Collection cycle. Since the bucket at key 0xFFFFFFFF is treated as a deleted sentinel, the tracing phase skips it and sweeps the ShareableElementData object.
- Trigger the creation of another element with the same attributes. The cache returns the dangling pointer to the swept memory, causing a Use-After-Free during attribute verification or subsequent styling.
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 hash map uses special key values to mark empty or deleted slots. If a real key accidentally equals one of these sentinels, the map's cleanup logic (garbage collection) may ignore that entry, leaving a pointer to freed memory. Later use of that pointer can crash the browser or let an attacker run code.
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.