Use after free in Codecs (CVE-2026-6318)
The video frame pool in WebRTC frees pooled backing allocations that no longer match the requested size or format, while AV1 encoder row-worker threads still hold raw pointers into that memory. An attacker could trigger a use-after-free, leading to a crash and potentially memory corruption.
- Fix shipped in 22 days
Summary
VideoFramePool::PoolImpl::CreateFrame drops non-matching pooled backing allocations while AV1 encoder row-worker threads still hold raw pointers into the freed memory, leading to the UAF in webrtc.
Details
When the WebRTC encoder needs a mapped I420 buffer, the call chain ConvertToWebRtcVideoFrameBuffer → WebRtcVideoFrameAdapter::AdaptBestFrame → SharedResources::CreateFrame delegates to VideoFramePool::PoolImpl::CreateFrame for allocation. SharedResources::CreateFrame is a direct passthrough:
scoped_refptr<media::VideoFrame>
WebRtcVideoFrameAdapter::SharedResources::CreateFrame(
media::VideoPixelFormat format,
const gfx::Size& coded_size,
const gfx::Rect& visible_rect,
const gfx::Size& natural_size,
base::TimeDelta timestamp) {
return pool_.CreateFrame(format, coded_size, visible_rect, natural_size,
timestamp);
}
Inside VideoFramePool::PoolImpl::CreateFrame, the pool iterates over cached frames looking for a size/format match. Non-matching frames are popped and their backing memory is freed immediately when the scoped_refptr goes out of scope:
while (!frames_.empty()) {
scoped_refptr<VideoFrame> pool_frame = std::move(frames_.back().frame);
frames_.pop_back();
if (pool_frame->IsSameAllocation(format, coded_size, visible_rect,
natural_size)) {
frame = pool_frame;
frame->set_timestamp(timestamp);
frame->clear_metadata();
break;
}
}
When a matching frame is found (or a new one allocated), it is returned wrapped. The wrapper's destruction observer reinserts the backing frame into the pool:
scoped_refptr<VideoFrame> wrapped_frame = VideoFrame::WrapVideoFrame(
frame, frame->format(), frame->visible_rect(), frame->natural_size());
wrapped_frame->AddDestructionObserver(base::BindOnce(
&VideoFramePool::PoolImpl::FrameReleased, this, std::move(frame)));
return wrapped_frame;
The converted frame is surfaced to the encoder through I420FrameAdapter, whose accessors return raw pointers into the underlying media::VideoFrame data:
const uint8_t* DataY() const override {
return frame_->visible_data(media::VideoFrame::Plane::kY);
}
The AV1 encoder (LibaomAv1Encoder::Encode) calls GetMappedFrameBuffer, which triggers AdaptBestFrame → ConvertToWebRtcVideoFrameBuffer → CreateFrame.
This invokes VideoFramePool::PoolImpl::CreateFrame on the encoder thread. If a previous frame's wrapper has already been returned to the pool, and the new CreateFrame call encounters a size change, it drops that pooled backing. However, the AV1 encoder dispatches encoding work to CodecWorker threads via enc_row_mt_worker_hook, and those workers read frame plane data through the raw pointers obtained from I420FrameAdapter. There is no synchronization that prevents a subsequent CreateFrame call from reclaiming the backing while row workers from a prior encode are still reading from those pointers, leading to the UAF.
Reproduction
Run chromium (e.g., https://storage.googleapis.com/chromium-browser-asan/linux-release/asan-linux-release-1603396.zip) with:
./chrome --no-sandbox poc.html
You would observe the stack-use-after-return crash shown in asan.txt
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 frame pool frees non-matching pooled backing allocations without synchronising with AV1 row-worker threads that still hold raw pointers into that memory.
Impact
A use-after-free in the encoder could crash the browser and may allow memory corruption, though the text only demonstrates a crash under the address sanitiser.
What the attacker needed
Victim loads a crafted page; AV1 encoding is used
How it was found
- Run the Chromium build with the provided proof-of-concept page.
- Observe the stack-use-after-return crash reported by the address sanitiser.
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 video frame is encoded, the encoder hands parts of the frame to several worker threads that read the pixel data directly through pointers. The frame pool can free that same memory when a new frame of a different size arrives, so the workers end up reading memory that has already been released. This is called a use-after-free and can crash the browser or, in the worst case, let an attacker run their own 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.