Uninitialized resource in Codecs (CVE-2026-87497)
A flaw in libjpeg-turbo's lossless decoder combined with Blink's progressive image decoding allows uninitialized heap memory to be leaked to a canvas. An attacker could use this to defeat ASLR by reading leaked memory via getImageData.
Google Chrome
Originally disclosed on Chrome VRP
- Fix shipped in 5 months
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 without the Chrome Security team. Please see https://chromium.googlesource.com/chromium/src/+/main/docs/security/ai-generated-security-bugs-faq.md for more information.
Overview: A potential uninitialized heap disclosure exists in libjpeg-turbo's lossless decoder when combined with Blink's progressive image decoding. A premature watermark advancement in libjpeg-turbo's memory manager, coupled with a flaw in Blink's JPEGImageDecoder::all_components_seen(), allows an attacker to leak uninitialized PartitionAlloc heap memory to a canvas. This can be used as an ASLR-defeat primitive.
Affected files:
third_party/libjpeg_turbo/src/jddiffct.cthird_party/libjpeg_turbo/src/jmemmgr.cthird_party/blink/renderer/platform/image-decoders/jpeg/jpeg_image_decoder.ccthird_party/libjpeg_turbo/src/jdlhuff.cthird_party/libjpeg_turbo/src/jdcolor.c
Estimated timestamp from git blame: 2025-08-07
Summary
A potential uninitialized heap disclosure vulnerability exists in the libjpeg-turbo lossless decoder (used for SOF3 JPEGs) when combined with Blink's progressive image decoding. A Time-of-Check Time-of-Use (TOCTOU) flaw in libjpeg-turbo's memory management, combined with incomplete state tracking in Blink's JPEGImageDecoder, allows an attacker to read renderer process PartitionAlloc heap memory via a <canvas> element.
Technical Details
The vulnerability arises from the interaction between libjpeg-turbo's virtual array management and Blink's progressive display logic:
- Premature Watermark Advancement: In
jddiffct.c, the lossless difference controller allocates virtual sample arrays withpre_zero=FALSE. When processing a scan,consume_data()callsaccess_virt_sarraywithwritable=TRUE. Insidejmemmgr.c:987, the memory manager immediately advances thefirst_undef_rowwatermark before any data is written to the buffer. - Suspension: If the input stream is truncated or stalls mid-row,
decompress_data()returnsJPEG_SUSPENDED. The current row is left completely unwritten, but is incorrectly marked as 'defined' by the memory manager because the watermark was already advanced. - Progressive Display Bypass: Back in Blink,
JPEGImageDecoder::Decodechecks if the partial image can be displayed progressively using theall_components_seenlambda (jpeg_image_decoder.cc:592). This lambda checksinfo.coef_bits. Because lossless JPEGs do not use DCT,coef_bitsis NULL. The lambda immediately returnstrue, causing Blink to bypass the check and force output of the incomplete scan viajpeg_start_output. - Uninitialized Read: During output generation,
output_data()(jddiffct.c:315) callsaccess_virt_sarraywithwritable=FALSEto read the stalled row. Because thefirst_undef_rowwatermark was advanced in Step 1, the memory manager does not throw aJERR_BAD_VIRTUAL_ACCESSerror. - Leak to Canvas:
output_datacopies the uninitialized PartitionAlloc heap memory into the output buffer. Blink'sOutputScanlinesthen writes this data into theImageFrame. An attacker can subsequently draw the partially decoded image to a canvas and usegetImageData()to read the leaked heap data.
Potential Attacker Steps to Trigger
Note: These are suggested steps based on code analysis; a working Proof of Concept has not been run.
- Serve a crafted, multi-scan 3-component SOF3 (lossless) JPEG.
- Provide full entropy for the first two scans.
- For the third scan, provide valid entropy for the first
Rrows, then artificially stall the TCP connection mid-way through rowR+1. - In the victim's browser, load the image and draw it to a
<canvas>usingctx.drawImage(). - Call
ctx.getImageData()and inspect the color channels corresponding to the stalled scan of rowR+1. The resulting bytes will contain uninitialized heap memory.
Suggested Fix
- Blink: Fix the logic in
all_components_seen(jpeg_image_decoder.cc:592) so that it accurately tracks component availability for lossless JPEGs, rather than defaulting totruewheninfo.coef_bitsis NULL. - libjpeg-turbo: Either initialize the virtual arrays by setting
pre_zero=TRUEwhen allocating them injddiffct.c:392, or delay advancingfirst_undef_rowinjmemmgr.cuntil the caller signals that the write has actually completed.
Evaluated with Chrome root at commit: 7353d249d9cacf9c7218e1d7b8a39cf39c72d646
Results 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 a TOCTOU flaw where libjpeg-turbo advances its 'defined' watermark before data is written, and Blink's all_components_seen incorrectly returns true for lossless JPEGs because coef_bits is NULL.
Impact
An attacker could leak uninitialized heap memory to a canvas, potentially defeating ASLR; however, the report notes that a working proof of concept has not been run.
What the attacker needed
Victim loads a crafted image; attacker can stall the connection; victim draws image to canvas
The fix
The fix should correct Blink's all_components_seen logic for lossless JPEGs and either pre-zero the virtual arrays or delay advancing the watermark in libjpeg-turbo.
How it was found
- Serve a crafted, multi-scan 3-component SOF3 (lossless) JPEG.
- Provide full entropy for the first two scans.
- For the third scan, provide valid entropy for the first R rows, then artificially stall the TCP connection mid-way through row R+1.
- In the victim's browser, load the image and draw it to a <canvas> using ctx.drawImage().
- Call ctx.getImageData() and inspect the color channels corresponding to the stalled scan of row R+1.
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 browser decodes an image, it sometimes shows a partial version before the whole file arrives. A bug in how the image library marks parts of the image as 'ready' means that a stalled download can cause the browser to display memory that was never written, which may contain leftover data from other parts of the program. An attacker who can make a victim load a specially crafted image and then read pixels from it could see that leftover memory.
What is Info disclosure?
Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.