Inappropriate implementation in Canvas (CVE-2026-7977)
Resizing an OffscreenCanvas with a bitmaprenderer context incorrectly resets its origin_clean_ flag to true without clearing the underlying image data. An attacker could exploit this to bypass the Same-Origin Policy and read cross-origin image data by transferring a tainted ImageBitmap, resizing the canvas, and then extracting the protected pixels.
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: Resizing an OffscreenCanvas with a bitmaprenderer context incorrectly resets its origin_clean_ flag to true without actually clearing the underlying image data. This state desynchronization potentially allows an attacker to bypass the Same-Origin Policy and read cross-origin image data. An attacker could exploit this by transferring a tainted ImageBitmap to the canvas, resizing it, and then extracting the protected pixels.
Affected files:
third_party/blink/renderer/core/offscreencanvas/offscreen_canvas.ccthird_party/blink/renderer/modules/canvas/imagebitmap/image_bitmap_rendering_context.cc
Estimated timestamp from git blame: 2025-07-08
Description
A potential Same-Origin Policy (SOP) bypass exists in Blink's OffscreenCanvas implementation when using the bitmaprenderer (ImageBitmap) rendering context. When an OffscreenCanvas is resized, its internal origin_clean_ flag is unconditionally reset to true if it uses a bitmaprenderer context. However, the actual image data stored in the rendering context is not cleared during this resize operation. This allows scripts to read back cross-origin pixel data that should be protected by the taint flag.
Note: The following steps and analysis are based on static code analysis; our tooling currently does not have the capability to run a live proof-of-concept.
Root Cause Analysis
The issue resides in OffscreenCanvas::SetSize within third_party/blink/renderer/core/offscreencanvas/offscreen_canvas.cc. During a resize, the following logic executes:
} else if (context_->IsRenderingContext2D() ||
context_->IsImageBitmapRenderingContext()) {
context_->Reset();
origin_clean_ = true;
}
While context_->Reset() is called, the implementation for ImageBitmapRenderingContext (third_party/blink/renderer/modules/canvas/imagebitmap/image_bitmap_rendering_context.cc) fails to clear the image stored in its ImageLayerBridge:
void ImageBitmapRenderingContext::Reset() {
CHECK(Host());
CHECK(Host()->IsOffscreenCanvas());
resource_provider_for_offscreen_canvas_.reset();
Host()->DiscardResources();
}
Because the image_layer_bridge_ is not cleared or disposed of, the OffscreenCanvas incorrectly reports its state as clean (OriginClean() == true) while the context still retains the tainted, cross-origin image pixels in memory.
Potential Attack Steps
An attacker could potentially trigger this vulnerability by following these steps:
- Load a cross-origin image (without CORS) from a victim site using an
HTMLImageElement(e.g., an authenticated avatar or private data). - Convert the cross-origin image into an
ImageBitmapusingcreateImageBitmap(img). This bitmap is correctly marked as not origin-clean (tainted). - Create an
OffscreenCanvasand obtain abitmaprenderercontext:const oc = new OffscreenCanvas(100, 100); const ctx = oc.getContext('bitmaprenderer'); - Transfer the tainted bitmap to the canvas via
ctx.transferFromImageBitmap(taintedBitmap). The canvas'sorigin_clean_flag is correctly set tofalse. - Resize the canvas to trigger the bug:
oc.width = 101;. This invokesSetSize, which incorrectly resetsorigin_clean_totruebut leaves the tainted pixels intact in the context. - Exfiltrate the pixel data by calling
await oc.convertToBlob(). SinceOriginClean()now incorrectly returnstrue, the security check passes, and the Blob is populated with the protected cross-origin pixels.
Suggested Fix
Modify ImageBitmapRenderingContext::Reset() to ensure the underlying image data is actually cleared. This can be done by replacing the image with a transparent black bitmap or dropping the reference in the layer bridge entirely. For example:
void ImageBitmapRenderingContext::Reset() {
CHECK(Host());
CHECK(Host()->IsOffscreenCanvas());
resource_provider_for_offscreen_canvas_.reset();
ResetInternalBitmapToBlackTransparent(Host()->width(), Host()->height()); // Clear the image
Host()->DiscardResources();
}
Alternatively, call image_layer_bridge_->Dispose() or image_layer_bridge_->SetImage(nullptr) if appropriate for the bridge's lifecycle.
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 ImageBitmapRenderingContext::Reset() method does not clear the stored image data, so the origin_clean_ flag is set to true while tainted pixels remain in memory.
Impact
An attacker could potentially bypass the Same-Origin Policy and read cross-origin image data, but the report is based on static analysis and no live proof-of-concept was run.
What the attacker needed
Victim site serves cross-origin image; no CORS headers on image; attacker can run JavaScript
The fix
The ImageBitmapRenderingContext::Reset() method should be modified to actually clear the underlying image data, for example by replacing the image with a transparent black bitmap or disposing the layer bridge.
How it was found
- Load a cross-origin image without CORS using an HTMLImageElement.
- Convert the image to an ImageBitmap with createImageBitmap, which marks it as tainted.
- Create an OffscreenCanvas and get a bitmaprenderer context.
- Transfer the tainted bitmap to the canvas, setting origin_clean_ to false.
- Resize the canvas, which resets origin_clean_ to true but leaves the pixels intact.
- Call convertToBlob to exfiltrate the protected 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.
Web pages can normally only read images from their own site, not from other sites, to protect private data. This bug lets a malicious page trick the browser into thinking an image is safe to read after resizing a special canvas, so it can steal pixels from another site's image. The report is based on reading the browser's code, not on actually running an attack.
What is Info disclosure?
Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.