Medium CVSS 4.3 webkit Integer Overflow 🔧 Commit mapped

Overview

Medium
Severity
4.3
CVSS
No
Exploited ITW
Fixed
Fix Status
DescriptionProcessing maliciously crafted web content may lead to an unexpected process crash
ComponentWTF
Bug ClassInteger Overflow
Tracker301371
Fix commitad4544045d66 (WebKit/WebKit) +22/-6
CWECWE-787, CWE-120 (Out-of-bounds write, Buffer overflow)
CVSS vectorCVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:L
CISA KEVNot listed
CreditedHossein Lotfi (@hosselot) of Trend Micro Zero Day Initiative
Disclosed2025-12-12

Background

WTF HashTable
The core open-addressing hash table underlying HashMap/HashSet across WebKit, sized in powers of two.
Checked<unsigned>
A wrapper that traps arithmetic overflow instead of wrapping, forcing overflow to be handled rather than silently producing a small value.
Rehash / best table size
On growth the table computes a new power-of-two size from the key count; overflow here yields an undersized allocation.

Root Cause Analysis

This fixes an unsigned integer overflow in WTF::HashTable’s size computation that could produce an undersized table allocation and subsequent out-of-bounds access. computeBestTableSize() and rehash() computed table sizes with plain unsigned arithmetic: bestTableSize = roundUpToPowerOfTwo(keyCount) followed by conditional doublings (bestTableSize *= 2), and rehash() derived newSize from oldSize. For a hash table driven to a very large key count, these unsigned multiplications/roundings can overflow 2^32 and wrap to a small value, so the table is allocated far smaller than the number of entries it must hold; reinserting entries then indexes past the allocation — an out-of-bounds read/write and heap corruption.

The fix converts the size accounting to Checked<unsigned> (newSize, oldSize, bestTableSize, and rehash’s newTableSize parameter) so any overflow in the rounding or doubling traps instead of silently wrapping, and returns std::max(bestTableSize.value(), minimumTableSize). It also adds deleteReleasedWeakBuckets(), which sweeps released weak buckets (decrementing keyCount, incrementing deletedCount) before rehash so the count feeding the size computation reflects reclaimed weak entries.

The restored invariant is that table-size math cannot silently wrap to an undersized allocation. The precise overflowing multiply is one of the bestTableSize *= 2 / roundUpToPowerOfTwo steps now wrapped in Checked<unsigned>.

Key insight
HashTable sized itself with plain unsigned arithmetic, so an enormous key count could overflow the power-of-two/doubling math and allocate a table far too small; Checked<unsigned> makes the overflow trap.

Attack Path

  1. Grow a hash table Drive a WTF HashTable/HashMap/HashSet (reachable via DOM/JS object bookkeeping) toward an enormous key count.
  2. Overflow the size math computeBestTableSize/rehash’s unsigned rounding and doubling wrap past 2^32 to a small size.
  3. Undersized allocation The table backing store is allocated too small for the live entries.
  4. Out-of-bounds write Reinserting entries indexes beyond the allocation, corrupting the heap in the WebContent process.

Impact Assessment

A heap out-of-bounds write primitive in the WebContent process, driven by inflating a hash table’s key count until its size computation overflows and under-allocates. Size-overflow-to-undersized-allocation is a classic, strong corruption primitive; the advisory rates it a crash, but the class supports controlled heap corruption toward code execution.

Changed Functions

FunctionChangeNotes
HashTable::computeBestTableSize
Source/WTF/wtf/HashTable.h
modified Uses Checked<unsigned> for bestTableSize so roundUpToPowerOfTwo and the *=2 doublings trap on overflow; returns std::max(bestTableSize.value(), minimumTableSize).
HashTable::rehash
Source/WTF/wtf/HashTable.h
modified Takes Checked<unsigned> newTableSize and computes newSize/oldSize as Checked<unsigned> to prevent wraparound to an undersized table.
HashTable::deleteReleasedWeakBuckets
Source/WTF/wtf/HashTable.h
added Sweeps released weak buckets before rehash (adjusting key/deleted counts) so the size computation is based on live entries.

Files Changed

  • Source/WTF/wtf/HashTable.h

Audit Directions

  • Same file: residual unsigned math
    In HashTable.h confirm all size/count arithmetic feeding allocation (tableSize, keyCount, deletedCount) is overflow-checked, including reinsert and shrink paths.
  • Container size computations
    Grep WTF containers (Vector, HashTable, BitVector) for roundUpToPowerOfTwo/*=2 on unsigned sizes without Checked<> before an allocation.

Original Bug Report

The reporter's bug is still restricted on the tracker.