Heap buffer overflow in WebCodecs (CVE-2026-9939)
A heap buffer overflow write exists in libaom's scene detection when using SVC temporal layers via WebCodecs. By shrinking then growing the encoder resolution, an attacker can cause a small buffer to be reused for a larger frame, leading to an out-of-bounds write of SAD values in the renderer process.
Google Chrome
Originally disclosed on Chrome VRP
- Fix shipped in 43 days
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 without the Chrome Security team. Please see go/chrome-ai-generated-security-bugs-faq for more information.
Overview: A potential heap-buffer-overflow WRITE exists in libaom's scene detection logic when using SVC temporal layers via the WebCodecs API. By dynamically shrinking and then growing the encoder resolution, an attacker can desynchronize libaom's internal state, causing it to reuse a small buffer for a large frame's data. This bypasses size checks and leads to an out-of-bounds write of SAD (Sum of Absolute Differences) values in the renderer process.
Affected files:
third_party/libaom/source/libaom/av1/encoder/ratectrl.cthird_party/libaom/source/libaom/av1/encoder/svc_layercontext.cthird_party/libaom/source/libaom/av1/encoder/encoder.cmedia/video/av1_video_encoder.cc
Estimated timestamp from git blame: 2025-05-06
Summary
A potential linear heap-buffer-overflow WRITE exists in libaom's scene detection logic when using Scalable Video Coding (SVC) temporal layers (e.g., scalabilityMode: 'L1T2') via the WebCodecs API. A specific sequence of resolution reconfigurations (shrink-then-grow) causes the encoder to erroneously reuse a stale, smaller buffer (cpi->src_sad_blk_64x64) for a larger frame's data, bypassing dimension-mismatch safety checks. This allows an attacker to write partially controlled values beyond the buffer's bounds in the renderer process.
Root Cause Analysis
The buffer cpi->src_sad_blk_64x64 is used to store block-wise Sum of Absolute Differences (SAD) during one-pass real-time rate control. It is allocated in av1_rc_scene_detection_onepass_rt based on the superblock grid size of the current frame.
To ensure the buffer matches the current frame dimensions, a check compares the current frame (frame_input->source) against the previous reference frame (frame_input->last_source). If they differ, the buffer is safely freed and nulled so it can be reallocated correctly.
// ratectrl.c:3309
if (src_width != last_src_width || src_height != last_src_height) {
aom_free(cpi->src_sad_blk_64x64);
cpi->src_sad_blk_64x64 = NULL;
return;
}
When SVC temporal layers are enabled, if the encoder believes a base layer (TL0) frame was dropped, it redirects frame_input->last_source to cpi->svc.source_last_TL0. This specific fallback buffer is allocated once at the start of encoding (frame_number == 0) and is never resized during subsequent dynamic resolution reconfigurations (aom_codec_enc_config_set).
Potential Trigger Sequence:
- Initial Configuration (Large): WebCodecs is configured with a large resolution (e.g., 256x512) and
scalabilityMode: 'L1T2'.source_last_TL0is allocated at 256x512. - Reconfigure Down (Small): The resolution is reconfigured to a smaller size (e.g., 256x64). The next frame (TL1) encounters a dimension mismatch, causing
src_sad_blk_64x64to be safely freed and reallocated for the smaller size (e.g., 4 elements). Because it's a TL1 frame, it does not update the time index for the TL0 reference buffer. - Reconfigure Up (Large): The resolution is restored to the large size (256x512). The next frame is encoded as a TL0 frame.
- State Desync: Because the previous TL1 frame did not update the TL0 reference time index,
av1_svc_set_last_sourceincorrectly concludes that the previous base layer frame was dropped. It forcesframe_input->last_sourceto point to the fallbacksource_last_TL0buffer. - Bypass & Overflow: In
av1_rc_scene_detection_onepass_rt, the code compares the current frame (256x512) againstsource_last_TL0(which is still 256x512 from step 1). The safety check passes, failing to free the smallsrc_sad_blk_64x64buffer allocated in step 2. The subsequent loop iterates over the large frame's grid, writing out of bounds into the small buffer.
Impact
- Type: Heap-buffer-overflow WRITE.
- Process: Renderer process.
- Controllability: The attacker can control the size of the initial small allocation to place the victim buffer in a specific PartitionAlloc bucket. By providing crafted
VideoFrameluma data, an attacker controls the low 20 bits of the writtenuint64_tSAD values, which can be used to corrupt adjacent heap object metadata (e.g., length or capacity fields), potentially leading to arbitrary read/write and remote code execution. - Note: This is a spatial overflow on a raw C pointer, so it is not mitigated by MiraclePtr.
Suggested Fix
The primary issue is that cpi->svc.source_last_TL0 holds stale dimensions across reconfigurations. The fix should involve either:
- Reallocating or invalidating
cpi->svc.source_last_TL0insideav1_change_config(or related configuration change handlers) when the frame dimensions change. - In
av1_rc_scene_detection_onepass_rt, validating the dimensions ofcpi->src_sad_blk_64x64directly against the current frame dimensions instead of relying solely on the comparison betweenframe_input->sourceandframe_input->last_source.
Evaluated with Chrome root at commit: c0eb5541aebfa4ea08806eaf6e94bcc69f87ab2f
Results 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
The fallback buffer `cpi->svc.source_last_TL0` is allocated once and never resized during dynamic resolution changes, so a dimension check passes incorrectly and a stale small buffer is used for a larger frame.
Impact
An attacker could corrupt adjacent heap metadata and potentially achieve arbitrary read/write and remote code execution, though this is a potential issue and not yet confirmed.
What the attacker needed
Attacker controls video encoding parameters; victim uses WebCodecs with SVC temporal layers
The fix
The fix should involve reallocating or invalidating the fallback buffer when frame dimensions change, or validating the SAD buffer dimensions directly against the current frame.
How it was found
- Configure WebCodecs with a large resolution and SVC temporal layers.
- Reconfigure to a smaller resolution, causing the SAD buffer to be reallocated small.
- Reconfigure back to the large resolution.
- The encoder incorrectly uses the small SAD buffer for the large frame, causing an out-of-bounds write.
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.
This report describes a memory safety bug in a video encoding library. When the video size is changed quickly, the encoder can mistakenly use a small memory buffer for a larger frame, writing data past the end of the buffer. This can crash the program or, in theory, 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.