Heap buffer overflow in WebRTC (CVE-2026-12447)
An off-by-one error in libvpx's multi-resolution encoding logic causes a heap out-of-bounds write when the first encoding iteration fails. An attacker could potentially trigger this via WebRTC VP8 simulcast in the Chromium renderer, leading to memory corruption.
Google Chrome
Originally disclosed on Chrome VRP
- Fix shipped in 33 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. Please see https://chromium.googlesource.com/chromium/src/+/main/docs/security/ai-generated-security-bugs-faq.md for more information.
Overview: An off-by-one error in the multi-resolution encoding logic of libvpx's vpx_codec_encode allows for a potential heap-based out-of-bounds write. If the first iteration of the encoding loop fails, the context pointer is incorrectly advanced beyond the allocated buffer before saving the error status. This path is reachable in the renderer process via WebRTC VP8 simulcast.
Affected files:
third_party/libvpx/source/libvpx/vpx/src/vpx_encoder.cthird_party/webrtc/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.cc
Estimated timestamp from git blame: 2012-11-05
Summary
A potential heap-based out-of-bounds (OOB) write exists in libvpx within the vpx_codec_encode() function. When processing multi-resolution encodings (such as VP8 simulcast in WebRTC), the function fails to correctly manage the encoder context pointer if the first encoding iteration returns an error. This results in an error status being written to memory immediately following the allocated array of codec contexts.
Technical Details
In third_party/libvpx/source/libvpx/vpx/src/vpx_encoder.c, the multi-resolution branch of vpx_codec_encode handles multiple encoder contexts. The logic for iterating through these contexts is as follows:
// third_party/libvpx/source/libvpx/vpx/src/vpx_encoder.c:220
else {
int i;
ctx += num_enc - 1; // [1] ctx starts at last element
if (img) img += num_enc - 1;
for (i = num_enc - 1; i >= 0; i--) {
if ((res = ctx->iface->enc.encode(get_alg_priv(ctx), img, pts, duration,
flags, deadline)))
break; // [2] Break if first iteration fails
ctx--;
if (img) img--;
}
ctx++; // [3] ctx unconditionally incremented
}
FLOATING_POINT_RESTORE();
}
return SAVE_STATUS(ctx, res); // [4] Writes (ctx)->err = res
- At
[1],ctxis advanced to the last element of the context array (num_enc - 1). - If the very first call to
encodefails, thebreakstatement at[2]is executed. Since the break occurs beforectx--,ctxstill points to the last valid element. - At
[3], the code unconditionally executesctx++. This advances the pointer one element past the end of the allocated array (&arr[num_enc]). - Finally, the
SAVE_STATUSmacro at[4](defined as((ctx) ? ((ctx)->err = (var)) : (var))) writes the 4-byte error code to theerrmember of the now OOB context.
On 64-bit systems, vpx_codec_ctx_t is 56 bytes, and the err field is at an offset of 16 bytes. This results in a 4-byte write 16 bytes beyond the end of the heap allocation.
Potential Reachability
This code path is reachable in the Chromium renderer via WebRTC when using VP8 simulcast. webrtc::LibvpxVp8Encoder allocates a contiguous vector of vpx_codec_ctx_t structures (encoders_) and calls vpx_codec_encode with the base of this vector. A failure in the first encoder iteration (representing the lowest resolution stream) would trigger the OOB write.
Suggested Attack Steps
- Use a malicious website to initiate an
RTCPeerConnectionwith VP8 simulcast (e.g., 3 active encodings). - Attempt to induce a failure in the first encoding iteration (e.g., by creating memory pressure to cause internal allocation failures within the encoder).
- Leverage heap grooming to place a sensitive object adjacent to the
encoders_allocation to exploit the 4-byte OOB write.
Recommended Fix
The ctx++ increment should only occur if the loop has actually performed at least one successful iteration (i.e., ctx was decremented). Alternatively, the pointer logic could be restructured to avoid unconditional post-loop increments.
for (i = num_enc - 1; i >= 0; i--) {
if ((res = ctx->iface->enc.encode(get_alg_priv(ctx), img, pts, duration,
flags, deadline)))
break;
if (i > 0) {
ctx--;
if (img) img--;
}
}
Evaluated with Chrome root at commit: b3153093eb3c78c3e88ccf562bcbc20437a04b0e
Results so far have been promising, but there can be wrong deductions. Feel free to adjust as follows:
- If you are familiar with the severity guidelines, you may adjust the severity.
- If this is a false positive, and there's no work to be done, please close as WAI.
- If there is work to do here but not a vulnerability, please change the issue type to Task/Bug/FR.
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 code unconditionally increments the context pointer after the encoding loop, even when the loop breaks on the first iteration without decrementing, causing the pointer to point one element past the allocated array.
Impact
A 4-byte out-of-bounds write could potentially lead to memory corruption, but the report does not demonstrate full exploitation and notes that inducing the failure may require memory pressure.
What the attacker needed
Victim visits malicious website; WebRTC VP8 simulcast enabled; memory pressure to cause failure
The fix
The ctx++ increment should only occur if the loop has actually performed at least one successful iteration (i.e., ctx was decremented).
How it was found
- Use a malicious website to initiate an RTCPeerConnection with VP8 simulcast (e.g., 3 active encodings).
- Attempt to induce a failure in the first encoding iteration (e.g., by creating memory pressure to cause internal allocation failures within the encoder).
- Leverage heap grooming to place a sensitive object adjacent to the encoders_ allocation to exploit the 4-byte OOB 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.
A heap buffer overflow is when a program writes data past the end of a reserved memory area, which can corrupt other data or crash the program. Here, a small mistake in a video encoding library means that if the first attempt to encode a video frame fails, the code writes an error code just outside the allocated memory. This could be triggered by a malicious website using a video call feature, potentially allowing an attacker to corrupt memory.
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.