Skip to content
Memory corruption Disclosed report Advanced CVE-2026-2757

Out-of-bounds write/read in WebrtcGmpVideoDecoder::Decode_g on undersized EncodedImage buffers

The WebRTC GMP H.264 decoder only rejected zero-length frames, so 1–3 byte EncodedImage buffers reached Decode_g, which writes a 4-byte header into a buffer sized to the input and then copies size minus 4 bytes. A malicious WebRTC peer could send such frames over H.264 to cause out-of-bounds read and write in the GMP process.

disclosure Follow

Originally disclosed on Mozilla

  • Fixed in 3 months
  • Paid in 3 months
  • Disclosed after 3 months

Created attachment 9528364 index.html

Hello team,

We have identified a potential issue in the WebRTC GMP H.264 video decoder when handling very small EncodedImage buffers.

Summary:

  • WebrtcGmpVideoDecoder::Decode only rejects zero-length frames, allowing 1–3 byte EncodedImage buffers to proceed to Decode_g.
  • Decode_g allocates a buffer of size aDecodeData->mImage.size() and then unconditionally writes a 4‑byte header (*(uint32_t*)frame->Buffer() = frame->Size()) and copies frame->Size() - 4 bytes.
  • For 1–3 byte inputs, the 4‑byte header write overruns the allocation and the size - 4 subtraction underflows, causing out‑of‑bounds read/write in the GMP process.
  • A malicious WebRTC peer can deliver such frames over H.264 when using the GMP decoder path.

Relevant code:

C++
// dom/media/webrtc/libwebrtcglue/WebrtcGmpVideoCodec.cpp
int32_t WebrtcGmpVideoDecoder::Decode(const webrtc::EncodedImage& aInputImage,
                                      bool aMissingFrames,
                                      int64_t aRenderTimeMs) {
  ...
  if (!aInputImage.size()) {
    return WEBRTC_VIDEO_CODEC_ERROR;
  }
  ...
  auto decodeData =
      MakeUnique<GMPDecodeData>(aInputImage, aMissingFrames, aRenderTimeMs);
  ...
}

void WebrtcGmpVideoDecoder::Decode_g(UniquePtr<GMPDecodeData>&& aDecodeData) {
  ...
  GMPUniquePtr<GMPVideoEncodedFrame> frame(
      static_cast<GMPVideoEncodedFrame*>(ftmp));
  err = frame->CreateEmptyFrame(aDecodeData->mImage.size());
  ...
  *(reinterpret_cast<uint32_t*>(frame->Buffer())) = frame->Size();
  memcpy(frame->Buffer() + 4, aDecodeData->mImage.data() + 4,
         frame->Size() - 4);
  ...
}

Minimal reproduction:

  1. Build with ASan and OpenH264 GMP
  2. Configure browser to use GMP H.264 for WebRTC:
    • Set media.navigator.mediadatadecoder_h264_enabled=false (forces GMP decoder path).
    • Set media.navigator.mediadatadecoder_vpx_enabled=false (avoids codec fallback).
    • Enable fake camera and script transforms: media.navigator.streams.fake=true, media.peerconnection.scripttransform.enabled=true.
  3. Load the attached PoC (index.html + encoded-transform-worker.js), which creates a local WebRTC loopback, negotiates H.264, and uses RTCRtpScriptTransform on the receiver to truncate frames to 3 bytes before decode.
  4. ASan reports an out-of-bounds write in WebrtcGmpVideoDecoder::Decode_g within a few frames.

Proposed fix:

Diff
diff --git a/dom/media/webrtc/libwebrtcglue/WebrtcGmpVideoCodec.cpp b/dom/media/webrtc/libwebrtcglue/WebrtcGmpVideoCodec.cpp
@@
-  if (!aInputImage.size()) {
+  if (aInputImage.size() < 4) {
     return WEBRTC_VIDEO_CODEC_ERROR;
   }
@@
-  err = frame->CreateEmptyFrame(aDecodeData->mImage.size());
+  const size_t imageSize = aDecodeData->mImage.size();
+  if (imageSize < 4) {
+    GMP_LOG_ERROR("GMP Decode: EncodedImage too small (%zu bytes)", imageSize);
+    mDecoderStatus = GMPDecodeErr;
+    return;
+  }
+  err = frame->CreateEmptyFrame(imageSize);
@@
-  *(reinterpret_cast<uint32_t*>(frame->Buffer())) = frame->Size();
+  *(reinterpret_cast<uint32_t*>(frame->Buffer())) =
+      static_cast<uint32_t>(imageSize);
@@
-  memcpy(frame->Buffer() + 4, aDecodeData->mImage.data() + 4,
-         frame->Size() - 4);
+  memcpy(frame->Buffer() + 4, aDecodeData->mImage.data() + 4,
+         imageSize - 4);

Tested on:

  • Mozilla Firefox 147.0a1

Please let us know how we can assist further, including validation of any fixes.

Best wishes, Igor Morgenstern Aisle Research

The original report as published on Mozilla's Bugzilla, by disclosure. Images and videos are our own copies; raw HTML is shown as text. View it on Mozilla's Bugzilla.

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 size check only rejected empty frames, so the fixed 4-byte header write and the size-minus-4 copy were performed on buffers smaller than 4 bytes.

Impact

A malicious WebRTC peer could cause out-of-bounds read and write in the GMP process when the GMP H.264 decoder path is used.

What the attacker needed

GMP H.264 decoder path enabled; attacker controls a WebRTC peer

The fix

The decoder should reject frames smaller than 4 bytes both in Decode and in Decode_g, and use the checked image size for the header and copy.

How it was found

  1. Build with ASan and the OpenH264 GMP decoder.
  2. Set the preferences that force the GMP H.264 decoder path and enable fake camera and script transforms.
  3. Load the proof-of-concept page, which sets up a local WebRTC loopback and negotiates H.264.
  4. Use a script transform on the receiver to truncate frames to 3 bytes before decoding.
  5. Observe the ASan out-of-bounds write in Decode_g within a few frames.

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 video decoder receives frames of compressed video data and copies them into a buffer before decoding. The code assumed every frame was at least four bytes long, but it only checked for zero bytes, so a tiny frame made it write past the end of a small buffer. A remote caller could send such tiny frames to corrupt memory in the process that handles video decoding.

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 by disclosure

View all

3 more disclosed reports, best first.

More from Mozilla

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.