Uninitialized Use in WebCodecs (CVE-2026-7982)
A logic flaw in Chromium's WebCodecs OpenH264 encoder allows an oversized VideoFrame with matching aspect ratio to bypass manual resizing, causing OpenH264 to silently fail preprocessing and compress uninitialized heap memory into an H.264 bitstream. An attacker can decode this bitstream to leak renderer heap contents and defeat ASLR.
Google Chrome
Originally disclosed on Chrome VRP
- Fix shipped in 37 days
Project Fortify, an experimental security project, has identified the following potential security issue.
Overview: A vulnerability in Chromium's OpenH264VideoEncoder allows oversized VideoFrames to bypass manual resizing logic when using WebCodecs. This causes silent failures in OpenH264's preprocessing stage, resulting in the encoder compressing uninitialized heap memory into a valid H.264 bitstream. An attacker can decode this bitstream to systematically leak renderer heap contents, defeating ASLR.
Affected files:
media/video/openh264_video_encoder.ccthird_party/openh264/src/codec/encoder/core/src/wels_preprocess.cppthird_party/openh264/src/codec/processing/src/common/WelsFrameWork.cppthird_party/openh264/src/codec/encoder/core/src/picture_handle.cppthird_party/openh264/src/codec/common/src/memory_align.cppthird_party/openh264/src/codec/encoder/core/src/encoder_ext.cpp
Estimated timestamp from git blame: 2026-03-12
Summary
A critical information disclosure vulnerability exists in the integration between Chromium's WebCodecs API and the software OpenH264 encoder. By providing an oversized VideoFrame that maintains the exact aspect ratio of the configured target resolution, an attacker can bypass Chromium's manual resizing checks. The oversized frame is passed directly to OpenH264, which silently fails during preprocessing due to internal maximum macroblock limits. Consequently, the encoder uses an uninitialized heap buffer allocated via malloc as the source picture for compression. The resulting H.264 bitstream, containing raw renderer heap data, is then delivered to the calling JavaScript context.
Root Cause Analysis
1. Chromium Resizing Bypass (media/video/openh264_video_encoder.cc)
The Encode() method determines if a frame requires manual resizing before being passed to OpenH264 by calling NeedsManualResizing(). This function contains a logical flaw:
// media/video/openh264_video_encoder.cc:154-165
bool NeedsManualResizing(const gfx::Size& src, const gfx::Size& dst) {
// ...
if (dst.width() > src.width() || dst.height() > src.height()) {
return true;
}
return VideoAspectRatio::PAR(src.width(), src.height()) !=
VideoAspectRatio::PAR(dst.width(), dst.height());
}
If an attacker configures the encoder for a 1024x1024 resolution (dst) and provides a 4096x4096 VideoFrame (src), dst > src evaluates to false (bypassing the upscaling check), and the aspect ratios match perfectly (1:1). The function incorrectly returns false, causing the oversized frame to be passed directly to codec_->EncodeFrame() without being downscaled.
2. OpenH264 Silent Preprocessing Failures (third_party/openh264/...)
When OpenH264 receives the oversized 4096x4096 frame, it detects a dimension mismatch against its 1024x1024 configuration and triggers a preprocessing reset (WelsPreprocessReset).
- Uninitialized Allocation:
WelsInitScaledPicallocates a newpScaledInputPicturebuffer usingWelsMalloc(memory_align.cpp:72). Crucially,WelsMallocwraps the standard Cmallocfunction and does not zero-initialize the memory. The buffer contains raw heap data. - Silent Failure in Memory Copy:
SingleLayerPreprocesscallsWelsMoveMemoryWrapper(wels_preprocess.cpp:383) to copy the oversized input frame into the pre-processing pipeline. InsideWelsMoveMemoryWrapper(wels_preprocess.cpp:1425), a safety check evaluates:if (iSrcWidth * iSrcHeight > (MAX_MBS_PER_FRAME << 8)) return;. The total pixels (4096 * 4096 = 16,777,216) exceed the maximum threshold (36864 * 256 = 9,437,184). The function silently returnsvoidearly without copying any pixel data. - Silent Error in Downsampling:
SingleLayerPreprocessthen attempts to downsample the frame by callingDownsamplePadding(wels_preprocess.cpp:398). This invokesm_pInterfaceVp->Process, which maps toCVpFrameWork::Process(WelsFrameWork.cpp:169). This function callsCheckValid, which evaluates a similar pixel count limit check:if ((iRectWidth * iRectHeight) > (MAX_MBS_PER_FRAME << 8)) return RET_INVALIDPARAM;. This check also fails for the 4096x4096 dimensions, returning the errorRET_INVALIDPARAMback toDownsamplePadding. - Error Discarded:
DownsamplePaddingreturns this error code, butSingleLayerPreprocessexplicitly discards it (wels_preprocess.cpp:398).
3. Data Leakage
As a result of both preprocessing steps failing silently, the output spatial layer destination buffer (pDstPic) remains completely uninitialized. SingleLayerPreprocess assigns this uninitialized buffer as the spatial layer's source (pSrc). The core encoder (WelsCodeOneSlice) then compresses this raw heap data as if it were valid YUV pixel data. The resulting H.264 bitstream is passed back to the attacker's JavaScript via the WebCodecs EncodedVideoChunk output callback.
By systematically alternating the colorSpace property of the VideoFrame between encode calls, an attacker can force media::OpenH264VideoEncoder::Encode to call UpdateEncoderColorSpace() (openh264_video_encoder.cc:464). This triggers a full OpenH264 codec re-initialization and fresh WelsMalloc allocations, allowing the attacker to continuously leak new, distinct regions of the renderer heap.
Suggested Exploitation Steps
(Note: These are potential steps based on code analysis; a working PoC has not been executed yet.)
- In a malicious web page, instantiate a
VideoEncoderusing the WebCodecs API, forcing the OpenH264 software implementation. - Configure the encoder with a standard target resolution, e.g., 1024x1024.
- Create a
VideoFramewith dimensions significantly larger than the configuration (e.g., 4096x4096) that maintains the exact same aspect ratio. - Call
encode()on the oversized frame. - In the
outputcallback, receive theEncodedVideoChunkcontaining the H.264 bitstream. - Decode the bitstream using a standard H.264 decoder to retrieve the uninitialized renderer heap memory (pixel data).
- To leak continuous memory regions, alternate the
colorSpaceof the inputVideoFramebetween encodes to force codec re-initialization.
Suggested Fix
- Chromium: Update
NeedsManualResizinginmedia/video/openh264_video_encoder.ccto ensure that frames larger than the target resolution in either dimension (downscaling) are manually resized if OpenH264's internal downscaler is deemed unsafe for extremely large frames. Alternatively, add explicit bounds checking (e.g., againstMAX_MBS_PER_FRAME) before passing frames toEncodeFrame(). - OpenH264:
- Modify
WelsMallocto usecallocor explicitlymemsetthe allocated memory to zero to prevent uninitialized memory disclosures. - Update
SingleLayerPreprocessinwels_preprocess.cppto properly handle and propagate the error codes returned byDownsamplePaddingandWelsMoveMemoryWrapperinstead of silently ignoring them.
- Modify
Evaluated with Chrome root at commit: a9cbf6e8b275fe4147435aa905f3b7f5a656f5f0
Results from so far have been promising, but there can be wrong deductions. If this proves to be a false positive, please close as WAI; 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
Likely the resizing check in NeedsManualResizing only rejects frames smaller than the target and mismatched aspect ratios, not oversized frames with matching aspect ratio, and OpenH264 silently ignores preprocessing errors and uses uninitialized memory.
Impact
An attacker could leak renderer heap contents, defeating ASLR; the text notes a working proof-of-concept has not been executed yet.
What the attacker needed
Victim visits a malicious web page; browser supports WebCodecs with OpenH264
The fix
Chromium should add explicit bounds checking before passing frames to EncodeFrame, and OpenH264 should zero-initialize allocations and propagate preprocessing errors instead of ignoring them.
How it was found
- Instantiate a VideoEncoder using the WebCodecs API, forcing the OpenH264 software implementation.
- Configure the encoder with a standard target resolution, e.g., 1024x1024.
- Create a VideoFrame with dimensions significantly larger than the configuration (e.g., 4096x4096) that maintains the exact same aspect ratio.
- Call encode() on the oversized frame.
- In the output callback, receive the EncodedVideoChunk containing the H.264 bitstream.
- Decode the bitstream using a standard H.264 decoder to retrieve the uninitialized renderer heap memory (pixel data).
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.
When a web page uses the WebCodecs API to encode video, Chromium sometimes passes the frame to a software encoder called OpenH264. A mistake in Chromium's size check lets a much larger frame through without resizing it. OpenH264 then fails to copy the pixel data but still encodes whatever was left in memory, so the resulting video contains secret memory contents that the attacker can read.
What is Info disclosure?
Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.