Skip to content
CORS Disclosed report Intermediate CVE-2018-18511

Tainted canvases can be rendered in a bitmap context

A browser security flaw allowed JavaScript to read pixel data from images loaded from other origins without CORS permission, by rendering them in a bitmap canvas context. An attacker could steal images that are otherwise protected by cookies or IP whitelisting, using cross-site request forgery.

AaylaSecura Follow

Originally disclosed on Mozilla

  • Fixed in 4 days
  • Paid in 11 days
  • Disclosed after 4 days
Text
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.96 Safari/537.36

Steps to reproduce:

If the crossorigin attribute is not specified for an image, the image may be
rendered in a bitmap canvas; the data can be accessced by JavaScript.
A proof of concept is shown below.
'''
<html><body>
  <script charset="utf-8">
    function getData() {
      createImageBitmap(this, 0, 0, this.naturalWidth,
        this.naturalHeight).then(function(bmap) {
        var can = document.createElement('canvas');
        var ctx = can.getContext('bitmaprenderer');
        ctx.transferFromImageBitmap(bmap);
        document.getElementById('result').textContent = can.toDataURL();
      }); }
  </script>
  <img src="https://duckduckgo.com/assets/logo_homepage_mobile.normal.v107.png" onload="getData.call(this)"/>
  <br/><textarea readonly style="width:100%;height:10em" id="result"></textarea>
</body></html>
'''

Actual results:

The image, which should not be accessible to JavaScript from origins other than
https://duckduckgo.com is in fact rendered in the tainted canvas and its
base64-encoded contents are displayed.

Images on external domains protected by cookies or IP whitelisting can
therefore be stolen using Cross-site Request Forgery even if the target server
does not give CORS access to other domains.


Expected results:

An error should have been thrown similar to the error shown when rendering tainted canvases in a 2D context:
  "The operation is insecure."

The original report as published on Mozilla's Bugzilla, by AaylaSecura. 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 bitmap renderer context did not enforce the same cross-origin taint checks as the 2D canvas context, allowing pixel data to be read from cross-origin images.

Impact

Images on external domains protected by cookies or IP whitelisting could be stolen using cross-site request forgery, even if the target server does not give CORS access to other domains.

What the attacker needed

Victim visits a malicious page; target image accessible via GET

How it was found

  1. Create an image element with a cross-origin source and an onload handler.
  2. In the handler, use createImageBitmap to convert the image to a bitmap.
  3. Create a canvas and get a bitmaprenderer context.
  4. Transfer the bitmap to the canvas using transferFromImageBitmap.
  5. Read the canvas data with toDataURL and display it.

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.

Normally, a web page cannot read the pixels of an image from another website unless that website explicitly allows it. This is to stop one site from stealing private images. The report shows a way to bypass that rule using a special canvas mode, so the image data could be read and stolen.

What is CORS?

A permissive cross-origin policy lets another site read responses with the user's credentials.

More from Mozilla

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

CORS misconfiguration

The lesson behind this report.

A permissive cross-origin policy lets another site read responses with the user's credentials.