Skip to content
Memory corruption Advisory Advanced CVE-2026-12447

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.c
  • third_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:

C
// 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
  1. At [1], ctx is advanced to the last element of the context array (num_enc - 1).
  2. If the very first call to encode fails, the break statement at [2] is executed. Since the break occurs before ctx--, ctx still points to the last valid element.
  3. At [3], the code unconditionally executes ctx++. This advances the pointer one element past the end of the allocated array (&arr[num_enc]).
  4. Finally, the SAVE_STATUS macro at [4] (defined as ((ctx) ? ((ctx)->err = (var)) : (var))) writes the 4-byte error code to the err member 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

  1. Use a malicious website to initiate an RTCPeerConnection with VP8 simulcast (e.g., 3 active encodings).
  2. Attempt to induce a failure in the first encoding iteration (e.g., by creating memory pressure to cause internal allocation failures within the encoder).
  3. 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.

C
      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.

The original report as published on the Chromium issue tracker. Images and videos are our own copies; raw HTML is shown as text. View it on Chromium issue tracker.

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

  1. Use a malicious website to initiate an RTCPeerConnection with VP8 simulcast (e.g., 3 active encodings).
  2. Attempt to induce a failure in the first encoding iteration (e.g., by creating memory pressure to cause internal allocation failures within the encoder).
  3. 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.

More from Google Chrome

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Memory corruption

The lesson behind this report.

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.