Skip to content
Info disclosure Disclosed report Advanced CVE-2019-11742

Cross-origin image stealing using SVG filters and canvas

Cross-origin images loaded via SVG filters were not tainted until the server revalidated them, allowing an attacker to read the image data from a canvas on a second page load. This could let a malicious page steal images from other origins.

Paul Stone Follow

Originally disclosed on Mozilla

  • Fixed in 54 days
  • Paid in 3 months
  • Disclosed after 54 days
Text
Created attachment 9072463
proof of concept

User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:69.0) Gecko/20100101 Firefox/69.0

Steps to reproduce:

Cross-origin images introduce a 'taint' into things like canvas and SVG filters to prevent image stealing. However, images in SVG load slightly differently than normal <img> elements. Images in SVG documents will display from the cache first, then re-display after revalidating with the server. It seems that the taint isn't introduced until the server has responded (e.g. with a 304 Not Modified). Before this happens, it's possible to use the image in ways that would normally fail or cause a security exception. Normal HTML images don't seem to behave in this way - they don't display at all until they've been revalidated.

The attached testcase has an SVG filter that uses feImage to load a cross-origin image. It than uses CanvasRenderingContext2D.filter to apply the filter to a canvas and toDataURI to copy the image data. On first load  toDataURI call causes an error because the image isn't cached. If you refresh the page, toDataURI works and gets a copy of the cross-origin image, due to the tainting delay.


Actual results:

Can use a cross-origin image from SVG without triggering tainting


Expected results:

Taint should apply even when image is displayed from cache, before revalidation

The original report as published on Mozilla's Bugzilla, by Paul Stone. Images and videos are our own copies; raw HTML is shown as text. View it on Mozilla's Bugzilla.

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 browser applied the cross-origin taint to SVG filter images only after the server revalidated the cached image, leaving a window where the image was untainted.

Impact

An attacker could read pixel data from a cross-origin image, but only if the victim first loads the page and then refreshes it, and only in browsers that exhibit this caching behaviour.

What the attacker needed

Victim visits a malicious page; victim refreshes the page; target image is cacheable

The fix

The browser should apply the cross-origin taint even when an image is displayed from cache before revalidation.

How it was found

  1. Load a page containing an SVG filter that uses feImage to load a cross-origin image.
  2. On first load, the toDataURI call fails because the image is not cached.
  3. Refresh the page so the image is served from cache.
  4. The toDataURI call then succeeds and returns a copy of the cross-origin image.

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 browsers normally block scripts from reading pixels of images from other websites to prevent data theft. This report shows a timing gap where an image loaded through an SVG filter could be read before that protection kicked in, but only after the image was cached and the page was refreshed.

What is Info disclosure?

Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.

More by Paul Stone

View all

3 more disclosed reports, best first.

More from Mozilla

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Information disclosure

The lesson behind this report.

Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.