Out of bounds read in WebCodecs (CVE-2026-5282)
OpenH264's encoder preprocessing uses the U plane's stride for both U and V chroma plane copies, causing an out-of-bounds read when the U stride is larger than the V stride. An attacker can trigger this via the WebCodecs VideoEncoder API by constructing an I420 VideoFrame with custom per-plane strides, crashing the renderer process.
c6eed09fc8b174b0f3eebedcceb1e792 Follow
Originally disclosed on Chrome VRP
- Fix shipped in 21 days
Heap Buffer Over-Read in OpenH264 Encoder Due to U/V Stride Mismatch
Summary
OpenH264's encoder preprocessing copies the V chroma plane using the U plane's stride instead of the V plane's own stride. When an I420 frame has a U stride that is significantly larger than its V stride, the V plane copy reads far beyond the allocated buffer. This is reachable from the web via the WebCodecs VideoEncoder API by constructing an I420 VideoFrame from an ArrayBuffer with custom per-plane strides and using the transfer option to preserve them. The resulting out-of-bounds read crashes the renderer process. The crash reproduces on both ASAN builds and standard release Chrome. Affected platforms: all platforms where OpenH264 is enabled (Linux, Windows, macOS, Android, ChromeOS).
Bisect
Introducing Commit: 70e5e62f3dbd19f0e9300fa7bba670c7ee93dcd2 (OpenH264 repository)
- Date: 2013-12-09
- Author: Ethan Hugg [email protected]
- Note: This is the initial commit of the OpenH264 repository. The bug has existed since OpenH264's first public release.
Root Cause
The SSourcePicture structure used by OpenH264's public API declares per-plane strides:
// third_party/openh264/src/codec/api/wels/codec_app_def.h
typedef struct Source_Picture_s {
int iColorFormat;
int iStride[4]; // stride for each plane pData
unsigned char* pData[4]; // plane pData
int iPicWidth;
int iPicHeight;
// ...
} SSourcePicture;
Chromium's OpenH264 encoder wrapper correctly populates all three strides from the incoming VideoFrame:
// https://source.chromium.org/chromium/chromium/src/+/main:media/video/openh264_video_encoder.cc;l=473
picture_stride[0] = frame->stride(VideoFrame::Plane::kY);
picture_stride[1] = frame->stride(VideoFrame::Plane::kU);
picture_stride[2] = frame->stride(VideoFrame::Plane::kV);
However, inside OpenH264, WelsMoveMemoryWrapper reads only iStride[1] (the U stride) and uses it as the shared stride for both U and V plane copies:
// https://source.chromium.org/chromium/chromium/src/+/main:third_party/openh264/src/codec/encoder/core/src/wels_preprocess.cpp;l=1416
const int32_t kiSrcStrideUV = kpSrc->iStride[1]; // BUG: ignores iStride[2]
This single kiSrcStrideUV value is then passed to WelsMoveMemory_c, which uses it to advance both pSrcU and pSrcV pointers between rows:
// https://source.chromium.org/chromium/chromium/src/+/main:third_party/openh264/src/codec/encoder/core/src/wels_preprocess.cpp;l=1364
for (j = iHeight2; j; j--) {
WelsMemcpy (pDstU, pSrcU, iWidth2);
WelsMemcpy (pDstV, pSrcV, iWidth2);
pDstU += iDstStrideUV;
pDstV += iDstStrideUV;
pSrcU += iSrcStrideUV; // uses U stride for both
pSrcV += iSrcStrideUV; // should use V stride here
}
When U stride is much larger than V stride, the V plane copy reads far beyond the V plane's allocation. In the PoC, a 64x64 I420 frame is constructed with U stride=65536 and V stride=32. The V plane occupies 1024 bytes, but the copy routine advances by 65536 bytes per row, requiring approximately 2MB of readable memory from the V plane start. This produces an out-of-bounds read of approximately 1.94MB.
The WebCodecs VideoFrame constructor allows creating frames from an ArrayBuffer with custom per-plane layout. When the transfer option is used, the frame wraps the original ArrayBuffer memory directly via VideoFrame::WrapExternalDataWithLayout, preserving the caller-supplied strides without normalization. The WebCodecs stride validation in video_frame_layout.cc checks per-plane minimum stride constraints but does not enforce any relationship between U and V strides.
The out-of-bounds read offset and length are fully attacker-controlled. The attacker chooses the U stride value via the layout parameter, which directly determines how far past the V plane allocation each row read advances:
layout: [
{ offset: offsetY, stride: strideY }, // Y plane
{ offset: offsetU, stride: 65536 }, // U plane — this stride is used for V copy too
{ offset: offsetV, stride: 32 }, // V plane — actual stride ignored by OpenH264
]
The attached PoC uses a U stride of 65536 producing a ~1.94MB over-read, but any stride value is accepted.
chrome://crashes id
e325cfe035f61694
Reproduce
Do NOT use ClusterFuzz to reproduce this bug. ClusterFuzz builds do not include proprietary_codecs and will not have OpenH264 compiled in, so the vulnerable code path is unreachable. As an alternative, a crash ID from standard release Chrome is provided in the "chrome://crashes id" section above.
This crash reproduces on standard release Chrome (tested on Chrome 146.0.7680.71 on macOS), where it manifests as an "Aw, Snap!" renderer crash (SIGBUS, error code 10).
The open-source Chromium build defaults proprietary_codecs to false to avoid distributing patent-encumbered codecs (H.264, AAC, etc.) without a license. Google Chrome ships with proprietary_codecs = true and ffmpeg_branding = "Chrome" under its own patent licensing agreements. To reproduce with an ASAN build, these flags must be set to match the production Chrome configuration.
Tested on commit f51a685e768b632262beaf8bd95387fffe096655. No source modifications are required. Open poc.html in Chrome to trigger the crash.
The args.gn:
is_asan = true
is_debug = false
dcheck_always_on = false
target_cpu = "x64"
is_component_build = true
proprietary_codecs = true
rtc_use_h264 = true
media_use_openh264 = true
ffmpeg_branding = "Chrome"
autoninja -C ~/chromium/src/out/asan-release chrome
cd ~/chromium/src
ASAN_OPTIONS=detect_odr_violation=0 out/asan-release/chrome --user-data-dir=/tmp/poc-$(date +%s) poc.html
Crash log:
Received signal 11 SEGV_ACCERR 7a3c00215000
#5 0x7f8c738c4881 memcpy (libc.so.6+0xc4880)
#6 0x561eff6e945c __asan_memcpy (chrome+0x67e945b)
#7 0x7f8ccf90f911 WelsMoveMemoryWrapper (wels_preprocess.cpp)
#8 0x7f8ccf90b487 SingleLayerPreprocess (wels_preprocess.cpp)
#9 0x7f8ccf868ee1 WelsEncoderEncodeExt (encoder_ext.cpp)
#10 0x7f8ccf923bc3 CWelsH264SVCEncoder::EncodeFrameInternal (welsEncoderExt.cpp)
#11 0x7f8ccf9238a4 CWelsH264SVCEncoder::EncodeFrame (welsEncoderExt.cpp)
#12 0x7f8ccf2feb49 OpenH264VideoEncoder::Encode (openh264_video_encoder.cc)
The crash manifests as SEGV rather than a standard ASAN heap-buffer-overflow report because V8 sandbox allocates ArrayBuffer backing stores via PartitionAlloc with kNoMemoryToolOverride, which disables ASAN shadow memory tracking for these allocations.
Credit
Please use c6eed09fc8b174b0f3eebedcceb1e792 as the credit for this vulnerability. Thank you.
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
Likely the encoder's preprocessing code uses the U plane's stride for both U and V plane copies, ignoring the V plane's own stride.
Impact
The out-of-bounds read crashes the renderer process, as demonstrated on standard release Chrome.
What the attacker needed
Chrome with OpenH264 enabled; Victim visits a malicious page
How it was found
- Create an I420 VideoFrame from an ArrayBuffer with custom per-plane strides, setting U stride much larger than V stride.
- Use the transfer option to preserve the custom strides.
- Pass the frame to the WebCodecs VideoEncoder API.
- The encoder's preprocessing copies the V plane using the U stride, reading out of bounds and crashing the renderer.
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 frame is stored as separate blocks of colour data, each with a 'stride' that says how many bytes to skip between rows. The encoder mistakenly used the same stride for two different colour blocks, so when one block's stride was much larger, it read past the end of the other block's memory. This caused the browser tab to crash.
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.