Use after free in Media (CVE-2026-7355)
A use-after-free exists in Chromium's SourceBufferStream because an iterator tracking the next append position can be left dangling when its range is removed during garbage collection, since a safety check fails when the last appended timestamp is unset. An attacker could dereference the dangling iterator and, with heap spraying, potentially gain arbitrary memory write and code execution inside the sandboxed renderer.
Google Chrome
Originally disclosed on Chrome VRP
- Fix shipped in 29 days
Project Fortify, an experimental security project, has identified the following potential security issue.
Overview: A Use-After-Free (UAF) vulnerability exists in SourceBufferStream because the range_for_next_append_ iterator can become dangling when its range is removed during garbage collection. A safety check fails to reset the iterator when last_appended_buffer_timestamp_ is kNoTimestamp, allowing an attacker to dereference the dangling iterator and potentially achieve arbitrary code execution.
Affected files:
media/filters/source_buffer_stream.ccmedia/filters/source_buffer_stream.h
Estimated timestamp from git blame: 2024-04-03
Description
A potential Use-After-Free (UAF) vulnerability exists in media::SourceBufferStream within the Chromium Renderer process. The issue stems from the management of the range_for_next_append_ iterator, which points to a SourceBufferRange within a std::list. Under specific conditions, this iterator can become dangling when the range it points to is removed from the list during garbage collection.
Vulnerability Details
SourceBufferStream maintains range_for_next_append_ (a std::list<std::unique_ptr<SourceBufferRange>>::iterator) to track where the next media append should occur. The FreeBuffers method is responsible for removing ranges to satisfy memory limits. It includes a check to reset the iterator if the range being deleted is the one containing the last appended buffer:
// media/filters/source_buffer_stream.cc
// Check to see if we've just deleted the GOP that was last appended.
base::TimeDelta end_timestamp = buffers.back()->timestamp();
if (end_timestamp == last_appended_buffer_timestamp_) {
// ...
range_for_next_append_ = ranges_.end();
} else {
bytes_freed += bytes_deleted;
}
if (current_range->GetMemoryUsage() == 0) {
DCHECK_NE(current_range, selected_range_);
DCHECK(range_for_next_append_ == ranges_.end() ||
range_for_next_append_->get() != current_range);
// Delete |current_range| by popping it out of |ranges_|.
reverse_direction ? ranges_.pop_back() : ranges_.pop_front();
}
If last_appended_buffer_timestamp_ is kNoTimestamp (which can occur if a new coded frame group is started but no buffers have yet been appended to the stream), the condition end_timestamp == last_appended_buffer_timestamp_ will never be true. In this case, range_for_next_append_ is not reset. When the range is popped from the list, the iterator becomes dangling. Note that the DCHECK verifying the iterator's safety is compiled out in Release builds.
Potential Reachability
This vulnerable state is reachable by performing the following steps through the Media Source Extensions (MSE) API:
- Append Muxed Media: Append an initialization segment and a media segment containing multiplexed audio and video frames to create disjoint buffered ranges (e.g., [0-5s] and [10-15s]).
- Reset Parser: Call
SourceBuffer.abort()to reset the parser state and end the current coded frame group. - Trigger New Coded Frame Group (Video-Only): Append a new media segment that contains only video frames. The
FrameProcessordetects the new coded frame group and broadcastsNotifyStartOfCodedFrameGroupto all track buffers. - Audio Stream State Update: For the audio track,
SourceBufferStream::OnStartOfCodedFrameGroupsetsrange_for_next_append_to an existing overlapping range and callsResetLastAppendedState(), which setslast_appended_buffer_timestamp_tokNoTimestamp. - Trigger Garbage Collection: Append a large amount of video data to exceed the
SourceBuffer's memory limit. This triggersChunkDemuxerStream::EvictCodedFrames()and subsequentlySourceBufferStream::FreeBuffers()for the audio stream. - Bypass Safety Check:
FreeBuffers()deletes the range pointed to byrange_for_next_append_. Becauselast_appended_buffer_timestamp_iskNoTimestamp, the protective check is bypassed, and the range is popped while leavingrange_for_next_append_dangling. - Trigger UAF: Append a new media segment containing audio frames without calling
abort().SourceBufferStream::Append()is called, which dereferences the danglingrange_for_next_append_iterator to callAppendBuffersToEnd.
Impact
Since std::list iterators in libc++ store raw pointers to nodes, this UAF is not mitigated by MiraclePtr (BRP). An attacker can use heap spraying to control the freed list node's contents, allowing them to forge the this pointer for the AppendBuffersToEnd call. Inside AppendBuffersToEnd, operations on member variables (like std::deque::push_back and std::map::insert) can be manipulated to achieve a powerful arbitrary memory write primitive. This could bypass Control-Flow Integrity (CFI) protections and potentially lead to Remote Code Execution (RCE) within the sandboxed Renderer process.
Recommended Fix
Ensure that FreeBuffers correctly resets range_for_next_append_ whenever the range it points to is removed, regardless of the value of last_appended_buffer_timestamp_. A safer approach would be to check if range_for_next_append_->get() == current_range and reset it explicitly before the range is popped, similar to the logic used in SourceBufferStream::DeleteAndRemoveRange.
Evaluated with Chrome root at commit: ff3d2b74fa39431785bd60e51463b08fcc71ee33
Results from so far have been promising, but there can be wrong deductions. If this proves to be a false positive, please close as WAI; 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 FreeBuffers cleanup only resets the next-append iterator when the deleted range's end timestamp matches the last appended timestamp, so an unset timestamp skips the reset and leaves the iterator dangling.
Impact
With heap spraying an attacker could forge the object pointer and build an arbitrary memory write primitive that may bypass Control-Flow Integrity and potentially lead to code execution, though only within the sandboxed renderer process.
What the attacker needed
Victim loads attacker-controlled media; renderer process only (sandboxed); heap spraying to shape freed memory
The fix
FreeBuffers should reset the next-append iterator whenever the range it points to is removed, regardless of the last appended timestamp, for example by comparing the pointed-to range directly before popping it.
How it was found
- Append an initialisation segment and a muxed audio/video segment to create disjoint buffered ranges.
- Call SourceBuffer.abort() to reset the parser and end the current coded frame group.
- Append a video-only segment so a new coded frame group starts and the audio stream resets its last appended state.
- Append enough video data to exceed the memory limit, triggering garbage collection on the audio stream.
- The protective check is bypassed and the range is removed while the iterator is left dangling.
- Append an audio segment without calling abort() so the dangling iterator is dereferenced.
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.
When a program frees a piece of memory but keeps a pointer to it, that pointer is called dangling, and using it later is a use-after-free. Here a media playback component kept such a pointer after cleaning up old buffered data, and a later append step used it. An attacker who controls what lands in the freed memory could steer that use into writing to memory of their choosing.
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.