Use after free in WebRTC (CVE-2025-10501)
A use-after-free occurs in MediaStreamDescriptor when the garbage collector runs while a Vector of observers is being iterated, allowing a freed object to be used. An attacker could potentially exploit this to cause a crash or execute arbitrary code in the renderer.
- Fix shipped in 27 days
Steps to reproduce the problem
- chrome.exe --js-flags="--stress-incremental-marking --expose-gc" --no-sandbox
Problem Description
void MediaStreamDescriptor::AddComponent(MediaStreamComponent* component) {
'''
'''
// Iterate over a copy of |observers_| to avoid re-entrancy issues.
Vector<WebMediaStreamObserver*> observers = observers_;
for (auto*& observer : observers)
observer->TrackAdded(WebString(component->Id()));
}
A vulnerability occurs when the garbage collector runs while maintaining GC objects on the stack using a Vector.\
SpaceSplitString::Data* SpaceSplitString::Data::Create(
const AtomicString& string) {
auto result = SharedDataMap().insert(string, nullptr);
SpaceSplitString::Data* data = result.stored_value->value;
if (result.is_new_entry) {
data = MakeGarbageCollected<SpaceSplitString::Data>(string);
result.stored_value->value = data;
}
return data;
}
```\
As shown in the asan.log file, the MakeGarbageCollected function can be called from the SpaceSplitString function and several other functions within the TrackAdded function.\
```c++
void CppHeap::ReportBufferedAllocationSizeIfPossible() {
'''
'''
used_size_.fetch_add(static_cast<size_t>(bytes_to_report),
std::memory_order_relaxed);
allocated_size_ += bytes_to_report;
if (v8_flags.incremental_marking) {
if (allocated_size_ > allocated_size_limit_for_check_) {
Heap* heap = isolate_->heap();
heap->StartIncrementalMarkingIfAllocationLimitIsReached(
heap->main_thread_local_heap(),
heap->GCFlagsForIncrementalMarking(),
kGCCallbackScheduleIdleGarbageCollection);
if (heap->incremental_marking()->IsMajorMarking()) {
if (heap->AllocationLimitOvershotByLargeMargin()) {
heap->FinalizeIncrementalMarkingAtomically(
i::GarbageCollectionReason::kExternalFinalize);
} else {
heap->incremental_marking()->AdvanceOnAllocation();
}
}
allocated_size_limit_for_check_ =
allocated_size_ + kIncrementalMarkingCheckInterval;
}
}
}
}
```\
If there is a lot of memory allocated so far inside the MakeGarbageCollected function, you can call FinalizeIncrementalMarkingAtomically through the ReportBufferedAllocationSizeIfPossible function to execute Full GarbageCollect.\
The probability of the conditions for executing the above GarbageCollect is very low and can change a lot depending on the version, environment, etc., so the probability can be adjusted by taking actions such as setting the ArrayBuffer allocation size and loop count to different values.
# Summary
Use-After-Free in MediaStreamDescriptor
# Custom Questions
#### Type of crash:
Renderer
#### Crash state:
Crash referencing vftable
#### Reporter credit:
sherkito
# Additional Data
Category: Security \
Chrome Channel: Not sure \
Regression: N/A \
Context
This is a use-after-free (UAF) in Chrome's WebRTC code, specifically in MediaStreamDescriptor. The class keeps a list of observers (observers_) and notifies each one when a track is added. The bug is a garbage-collection interaction: a GC object is held on the stack in a Vector while code that can trigger a full garbage collection runs, so the object can be freed and then used.
The report is a Chrome VRP advisory credited to sherkito, rated high severity, with a bounty of 10000.00 USD, disclosed on 2025-09-18. The weakness class is use after free and the affected asset is WebRTC. The crash is in the renderer and the crash state is described as referencing the vftable.
Setup
The only precondition the report gives is a Chrome launch with specific JavaScript flags and sandbox disabled:
chrome.exe --js-flags="--stress-incremental-marking --expose-gc" --no-sandbox
--stress-incremental-marking makes V8 run incremental marking aggressively, and --expose-gc exposes the gc() function to JavaScript so the collector can be driven from a page. --no-sandbox disables the renderer sandbox. The report does not state a Chrome version, channel or platform beyond the chrome.exe binary name, and it lists the Chrome Channel as "Not sure" and Regression as "N/A".
Finding it
The researcher points at MediaStreamDescriptor::AddComponent, which iterates over a copy of the observer list to avoid re-entrancy problems:
void MediaStreamDescriptor::AddComponent(MediaStreamComponent* component) {
'''
'''
// Iterate over a copy of |observers_| to avoid re-entrancy issues.
Vector<WebMediaStreamObserver*> observers = observers_;
for (auto*& observer : observers)
observer->TrackAdded(WebString(component->Id()));
}
The copy is a Vector of pointers to observers. The report's stated condition is that a vulnerability occurs when the garbage collector runs while GC objects are being kept on the stack in a Vector.
The second piece of code is SpaceSplitString::Data::Create, which allocates a GC object with MakeGarbageCollected:
SpaceSplitString::Data* SpaceSplitString::Data::Create(
const AtomicString& string) {
auto result = SharedDataMap().insert(string, nullptr);
SpaceSplitString::Data* data = result.stored_value->value;
if (result.is_new_entry) {
data = MakeGarbageCollected<SpaceSplitString::Data>(string);
result.stored_value->value = data;
}
return data;
}
The report says that, as shown in the asan.log file, MakeGarbageCollected can be called from the SpaceSplitString function and from several other functions inside TrackAdded. In other words, the observer callback reached through the stack-held Vector can allocate, and allocation is what can drive the collector.
Exploitation
Step 1: launch Chrome with the stress flags
chrome.exe --js-flags="--stress-incremental-marking --expose-gc" --no-sandbox
This enables aggressive incremental marking and exposes gc() to page JavaScript, and removes the sandbox. The report does not describe the page content used to reach AddComponent or to tune the allocation sizes and loop counts.
Step 2: reach TrackAdded through the observer copy
AddComponent copies observers_ into a local Vector and calls observer->TrackAdded(...) for each entry. The Vector and its raw pointers are on the stack, outside the GC's root set.
Step 3: allocate inside TrackAdded
Inside TrackAdded, MakeGarbageCollected can be called, for example from SpaceSplitString::Data::Create. Each such allocation is reported to the heap through CppHeap::ReportBufferedAllocationSizeIfPossible:
void CppHeap::ReportBufferedAllocationSizeIfPossible() {
'''
'''
used_size_.fetch_add(static_cast<size_t>(bytes_to_report),
std::memory_order_relaxed);
allocated_size_ += bytes_to_report;
if (v8_flags.incremental_marking) {
if (allocated_size_ > allocated_size_limit_for_check_) {
Heap* heap = isolate_->heap();
heap->StartIncrementalMarkingIfAllocationLimitIsReached(
heap->main_thread_local_heap(),
heap->GCFlagsForIncrementalMarking(),
kGCCallbackScheduleIdleGarbageCollection);
if (heap->incremental_marking()->IsMajorMarking()) {
if (heap->AllocationLimitOvershotByLargeMargin()) {
heap->FinalizeIncrementalMarkingAtomically(
i::GarbageCollectionReason::kExternalFinalize);
} else {
heap->incremental_marking()->AdvanceOnAllocation();
}
}
allocated_size_limit_for_check_ =
allocated_size_ + kIncrementalMarkingCheckInterval;
}
}
}
}
When enough memory has been allocated, the allocation limit check can lead to FinalizeIncrementalMarkingAtomically and a full garbage collection. Because the observer pointers are held on the stack in a Vector, a full garbage collection triggered during the loop can lead to a use after free.
Step 4: tune the probability
The report is explicit that the probability of hitting the conditions for this garbage collection is very low and varies a lot with version and environment. It can be adjusted by setting the ArrayBuffer allocation size and the loop count to different values.
Root cause
The mistake is holding GC objects on the stack in a Vector while calling code that can allocate and therefore trigger a garbage collection. The comment in AddComponent shows the copy exists to avoid re-entrancy issues, but the copy itself is not a GC root. The allocation path in CppHeap::ReportBufferedAllocationSizeIfPossible can escalate to FinalizeIncrementalMarkingAtomically, which runs a full collection while the loop is still using the copied pointers.
Impact
The conditions are narrow: the collector must run at the right moment, and the report notes the probability is very low and environment-dependent.
Fix
Variants to test
- Other observer or callback loops that copy a container of GC-managed pointers to a stack
Vectorand then call into code that allocates. A positive result is a crash or ASan report showing a freed object used after the loop's allocation point. - Other
MakeGarbageCollectedcall sites reachable from such callbacks, such as string or attribute helpers likeSpaceSplitString::Data::Create. A positive result is a collection triggered inside the callback while the stack-held pointer is still in use. - Allocation-limit tuning with different ArrayBuffer sizes and loop counts under
--stress-incremental-marking. A positive result is a reproducible crash whose frequency changes with those values, matching the report's note that the probability is adjustable. - Running the same paths with
--expose-gcand explicitgc()calls to widen the window. A positive result is a crash that does not occur without the forced collection.
What happened, in plain words
Chrome is a web browser. Inside Chrome there is a piece of software called WebRTC, which handles real-time audio and video between browsers, for example video calls in a web page. WebRTC organises a call as a "media stream", and a media stream is made of "tracks" (one track might be your microphone, another your camera).
When a track is added to a stream, Chrome tells a list of interested helper objects, called "observers", that a track has arrived. To do that safely, Chrome first copies the list of observers into a temporary container and then walks through the copy, calling each observer in turn.
The problem is what that temporary container is and where it lives. It is a plain list of memory addresses (pointers) sitting in a region of memory called the stack, which belongs to the running function. The report's stated condition is that a vulnerability occurs when the garbage collector runs while GC objects are being kept on the stack in a Vector. So while the loop is running, a garbage collection can occur, and the loop can then use an object that has been freed. Using memory after it has been freed is a well-known bug class called "use after free".
This report is a Chrome VRP advisory. VRP stands for Vulnerability Reward Program: a scheme where Google pays people who find and report security bugs in Chrome. The researcher credited is sherkito. The severity is rated high, the bounty was 10000.00 USD, and it was disclosed on 2025-09-18. The weakness class is use after free and the affected asset is WebRTC. The crash happens in the renderer, which is the part of Chrome that runs web pages, and the crash state is described as referencing the vftable.
Setup
The only precondition the report gives is a particular way of starting Chrome, with some JavaScript flags and with the sandbox turned off:
chrome.exe --js-flags="--stress-incremental-marking --expose-gc" --no-sandbox
Line by line:
chrome.exeis the Chrome program on Windows. Everything after it is a command-line option.--js-flags="..."passes options to V8, the JavaScript engine inside Chrome. V8 is the part that reads and runs the JavaScript on web pages.--stress-incremental-markingtells V8 to run its incremental marking very aggressively. Incremental marking is the first phase of garbage collection, where V8 walks through objects and marks the ones still in use. "Incremental" means it does this in small slices rather than all at once. Stressing it means doing it much more often than normal, which makes rare timing problems happen more easily.--expose-gcmakes a function calledgc()available to JavaScript on the page. Callinggc()asks the engine to run the garbage collector right away, so a page can force collection at a chosen moment instead of waiting for it to happen naturally.--no-sandboxturns off the renderer sandbox. The sandbox is a security boundary that stops a compromised web page from reaching the rest of the computer. Turning it off makes debugging easier but is not how Chrome normally runs.
The report does not state a Chrome version, channel or platform beyond the chrome.exe binary name, and it lists the Chrome Channel as "Not sure" and Regression as "N/A".
Finding it
The researcher points at a function called MediaStreamDescriptor::AddComponent. This is the code that adds a track to a stream and notifies the observers:
void MediaStreamDescriptor::AddComponent(MediaStreamComponent* component) {
'''
'''
// Iterate over a copy of |observers_| to avoid re-entrancy issues.
Vector<WebMediaStreamObserver*> observers = observers_;
for (auto*& observer : observers)
observer->TrackAdded(WebString(component->Id()));
}
Line by line:
void MediaStreamDescriptor::AddComponent(MediaStreamComponent* component)declares the function. It takes a pointer to the track being added and returns nothing.- The
'''lines stand for code that is not shown in the report. - The comment explains the intent: the code walks over a copy of the observer list to avoid re-entrancy issues. Re-entrancy means a function being interrupted by another call into the same code before it has finished, which can corrupt state.
Vector<WebMediaStreamObserver*> observers = observers_;makes that copy.observers_is the class's own list of observers.Vectoris a growable array, and here it holds pointers to observer objects. The copy is a local variable, so it lives on the stack.for (auto*& observer : observers)loops over each pointer in the copy.observer->TrackAdded(WebString(component->Id()));calls the observer'sTrackAddedmethod, passing the track's identifier wrapped as a string.
The copy is a Vector of pointers to observers. Roots are the starting points the collector uses to decide what is still reachable; anything not reachable from a root can be freed.
The second piece of code is SpaceSplitString::Data::Create, which allocates a GC-managed object with MakeGarbageCollected:
SpaceSplitString::Data* SpaceSplitString::Data::Create(
const AtomicString& string) {
auto result = SharedDataMap().insert(string, nullptr);
SpaceSplitString::Data* data = result.stored_value->value;
if (result.is_new_entry) {
data = MakeGarbageCollected<SpaceSplitString::Data>(string);
result.stored_value->value = data;
}
return data;
}
Line by line:
- The function takes a string and returns a pointer to a
SpaceSplitString::Dataobject, which is a helper that stores a string split on spaces, such as a list of CSS class names on an HTML element. SharedDataMap().insert(string, nullptr)looks the string up in a shared map and inserts it with an empty value if it is not there. The result says whether this was a new entry.SpaceSplitString::Data* data = result.stored_value->value;reads whatever value is currently stored for that string.if (result.is_new_entry)checks whether the string was newly inserted.data = MakeGarbageCollected<SpaceSplitString::Data>(string);creates a new object managed by the garbage collector. This is an allocation: it asks for memory, and the collector may react to that request.result.stored_value->value = data;stores the new object in the map.return data;hands the object back to the caller.
The report says that, as shown in the asan.log file, MakeGarbageCollected can be called from the SpaceSplitString function and from several other functions inside TrackAdded. ASan, the AddressSanitizer, is a debugging tool that detects memory errors such as using memory after it has been freed; its log is the record of what it caught. In other words, the observer callback reached through the stack-held Vector can allocate, and allocation is what can drive the collector.
Exploitation
Step 1: launch Chrome with the stress flags
chrome.exe --js-flags="--stress-incremental-marking --expose-gc" --no-sandbox
This enables aggressive incremental marking and exposes gc() to page JavaScript, and removes the sandbox. The reason for each flag is the same as in the setup section: make collection happen more often, make it possible to force collection from a page, and remove the sandbox so debugging is easier. The report does not describe the page content used to reach AddComponent or to tune the allocation sizes and loop counts.
Step 2: reach TrackAdded through the observer copy
AddComponent copies observers_ into a local Vector and calls observer->TrackAdded(...) for each entry. The Vector and its raw pointers are on the stack, outside the garbage collector's root set. This step matters because it creates the window: the copy is made and the loop runs while the observers are held on the stack in a Vector.
Step 3: allocate inside TrackAdded
Inside TrackAdded, MakeGarbageCollected can be called, for example from SpaceSplitString::Data::Create. Each such allocation is reported to the heap through CppHeap::ReportBufferedAllocationSizeIfPossible:
void CppHeap::ReportBufferedAllocationSizeIfPossible() {
'''
'''
used_size_.fetch_add(static_cast<size_t>(bytes_to_report),
std::memory_order_relaxed);
allocated_size_ += bytes_to_report;
if (v8_flags.incremental_marking) {
if (allocated_size_ > allocated_size_limit_for_check_) {
Heap* heap = isolate_->heap();
heap->StartIncrementalMarkingIfAllocationLimitIsReached(
heap->main_thread_local_heap(),
heap->GCFlagsForIncrementalMarking(),
kGCCallbackScheduleIdleGarbageCollection);
if (heap->incremental_marking()->IsMajorMarking()) {
if (heap->AllocationLimitOvershotByLargeMargin()) {
heap->FinalizeIncrementalMarkingAtomically(
i::GarbageCollectionReason::kExternalFinalize);
} else {
heap->incremental_marking()->AdvanceOnAllocation();
}
}
allocated_size_limit_for_check_ =
allocated_size_ + kIncrementalMarkingCheckInterval;
}
}
}
}
Line by line:
void CppHeap::ReportBufferedAllocationSizeIfPossible()is the function that tells the heap how much memory has been allocated. The heap is the pool of memory the garbage collector manages.- The
'''lines stand for code that is not shown. used_size_.fetch_add(...)adds the number of bytes to a running counter in a thread-safe way.std::memory_order_relaxedmeans the exact ordering relative to other threads does not matter here, only the total.allocated_size_ += bytes_to_report;adds the same number to a second counter.if (v8_flags.incremental_marking)checks whether incremental marking is switched on, which the stress flag makes sure it is.if (allocated_size_ > allocated_size_limit_for_check_)checks whether enough memory has been allocated since the last check to be worth looking at the collector again.Heap* heap = isolate_->heap();gets the heap for this JavaScript environment. An isolate is one independent JavaScript runtime inside the browser.heap->StartIncrementalMarkingIfAllocationLimitIsReached(...)asks the heap to start incremental marking if the allocation limit has been reached.if (heap->incremental_marking()->IsMajorMarking())checks whether a major marking pass, one that covers all objects, is in progress.if (heap->AllocationLimitOvershotByLargeMargin())checks whether the allocation limit was exceeded by a large margin.heap->FinalizeIncrementalMarkingAtomically(...)finishes the marking in one go, which means a full garbage collection runs right there, inside the allocation call.- Otherwise,
heap->incremental_marking()->AdvanceOnAllocation();just moves marking forward a little. allocated_size_limit_for_check_ = allocated_size_ + kIncrementalMarkingCheckInterval;sets the next threshold so the check is not repeated on every single allocation.
When enough memory has been allocated, the allocation limit check can lead to FinalizeIncrementalMarkingAtomically and a full garbage collection. Because the observer pointers are held on the stack in a Vector, a full garbage collection triggered during the loop can lead to a use after free. A simple comparison: you write a list of phone numbers on a sticky note, the phone book is thrown away and reprinted without those people, and you then dial a number from the sticky note that now belongs to someone else.
Step 4: tune the probability
The report is explicit that the probability of hitting the conditions for this garbage collection is very low and varies a lot with version and environment. It can be adjusted by setting the ArrayBuffer allocation size and the loop count to different values. An ArrayBuffer is a block of raw memory that JavaScript can allocate and fill, so its size controls how much memory the page asks for and therefore how quickly the allocation limit is reached. The loop count controls how many times the page repeats the action, giving more chances for the collector to fire at the wrong moment.
Root cause
The mistake is holding GC objects on the stack in a Vector while calling code that can allocate and therefore trigger a garbage collection. The comment in AddComponent shows the copy exists to avoid re-entrancy issues, but the copy itself is not a GC root. The allocation path in CppHeap::ReportBufferedAllocationSizeIfPossible can escalate to FinalizeIncrementalMarkingAtomically, which runs a full collection while the loop is still using the copied pointers.
Impact
The crash is in the renderer and the crash state is described as referencing the vftable. The vftable is a table of function addresses that the program uses to decide which method to run on an object; if the object's memory has been freed and reused, that table can point anywhere, which is why the crash mentions it. The conditions are narrow: the collector must run at the right moment, and the report notes the probability is very low and environment-dependent.
Fix
Variants to test
- Other observer or callback loops that copy a container of GC-managed pointers to a stack
Vectorand then call into code that allocates. A positive result is a crash or ASan report showing a freed object used after the loop's allocation point. - Other
MakeGarbageCollectedcall sites reachable from such callbacks, such as string or attribute helpers likeSpaceSplitString::Data::Create. A positive result is a collection triggered inside the callback while the stack-held pointer is still in use. - Allocation-limit tuning with different ArrayBuffer sizes and loop counts under
--stress-incremental-marking. A positive result is a reproducible crash whose frequency changes with those values, matching the report's note that the probability is adjustable. - Running the same paths with
--expose-gcand explicitgc()calls to widen the window. A positive result is a crash that does not occur without the forced collection.
Glossary
- API: a defined way for one piece of software to ask another piece of software to do something, like a menu of allowed requests.
- ASan (AddressSanitizer): a debugging tool that detects memory errors such as reading or writing memory after it has been freed.
- ArrayBuffer: a block of raw memory that JavaScript code can allocate and fill with data.
- Bounty: money paid by a company to a researcher who reports a valid security bug.
- Chrome VRP: Google's Vulnerability Reward Program for Chrome, which pays for security bug reports.
- CppHeap: the part of Chrome that manages memory for C++ objects that the JavaScript garbage collector also needs to know about.
- CSS class name: a label on an HTML element used to apply styling; several can be listed on one element, separated by spaces.
- FinalizeIncrementalMarkingAtomically: finishing a garbage collection marking pass in one go, which means a full collection runs at that moment.
- Garbage collector (GC): the part of a runtime that automatically frees memory that is no longer in use.
- GC root: a starting point the garbage collector trusts, such as a global variable, from which it traces which objects are still reachable.
- Heap: the pool of memory from which objects are allocated and which the garbage collector manages.
- Incremental marking: the first phase of garbage collection, done in small slices, where the collector marks objects that are still in use.
- Isolate: one independent JavaScript runtime inside the browser, with its own heap.
- MakeGarbageCollected: a Chrome function that creates an object managed by the garbage collector.
- Media stream: a WebRTC concept for a flow of audio or video, made up of one or more tracks.
- Observer: an object that registers to be told when something happens, here when a track is added to a stream.
- Pointer: a value that holds the memory address of an object.
- Re-entrancy: a function being called again before an earlier call has finished, which can corrupt shared state.
- Renderer: the part of Chrome that runs web pages, separated from the rest of the browser.
- Root set: the collection of roots the garbage collector starts from when deciding what is still reachable.
- Sandbox: a security boundary that stops a compromised web page from reaching the rest of the computer.
- Severity: a rating of how serious a vulnerability is, here high.
- Stack: the region of memory a running function uses for its local variables, which the garbage collector does not scan as roots.
- Track: one audio or video stream inside a media stream, such as a microphone or camera feed.
- Use after free (UAF): a bug where memory is used after it has been freed, so the program reads or calls whatever now occupies that memory.
- V8: the JavaScript engine inside Chrome that runs the JavaScript on web pages.
- Vector: a growable array, a container that holds a list of items.
- vftable: a table of function addresses used to decide which method to run on an object; a crash referencing it suggests a call through a corrupted or freed object.
- WebRTC: the technology that lets browsers send real-time audio and video to each other, used for video calls.