<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>17150</bug_id>
          
          <creation_ts>2008-02-02 02:27:21 -0800</creation_ts>
          <short_desc>safe &lt;img src=data:...&gt; should not mark &lt;canvas&gt; unsafe</short_desc>
          <delta_ts>2009-09-19 10:19:38 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Layout and Rendering</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>PC</rep_platform>
          <op_sys>OS X 10.5</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>DUPLICATE</resolution>
          <dup_id>29305</dup_id>
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>0</everconfirmed>
          <reporter name="Anne van Kesteren">annevk</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>abarth</cc>
    
    <cc>grahamperrin</cc>
    
    <cc>mihai.sucan</cc>
    
    <cc>oliver</cc>
    
    <cc>sam</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>69162</commentid>
    <comment_count>0</comment_count>
    <who name="Anne van Kesteren">annevk</who>
    <bug_when>2008-02-02 02:27:21 -0800</bug_when>
    <thetext>There are two types of &lt;img&gt; elements that represent a data: URI. Those that are safe, and those that are unsafe. Safe &lt;img&gt; elements loading a data: URI are all images represented by a data: URI that did not have their redirection chain go cross-site first.

The HTML5 origin policy is currently unclear on this matter as it does not distinguish these image types.

This bug is important to fix as it will allow sites to export the &lt;canvas&gt; using toDataURL(), safe it somewhere, and then later import it again, and export it, et cetera (round tripping).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>84639</commentid>
    <comment_count>1</comment_count>
    <who name="Oliver Hunt">oliver</who>
    <bug_when>2008-06-28 00:55:55 -0700</bug_when>
    <thetext>Anne, the issue is how you identify a safe vs. unsafe data uri when all you have is a string &quot;data:....&quot; which is the case when the src is set on an image.  How is it possible to work around this?

You can achieve the goal of storage relatively simply through the use of ImageData, although you would unfortunately need to do your own serialisation :-/</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>84797</commentid>
    <comment_count>2</comment_count>
    <who name="Anne van Kesteren">annevk</who>
    <bug_when>2008-06-30 16:08:18 -0700</bug_when>
    <thetext>The string &quot;data:...&quot; is always safe. (Consider that the author can do anything with it.)

(ImageData doesn&apos;t really work well, as it varies based on device resolution, etc. It&apos;s not really fit for storage.)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>84798</commentid>
    <comment_count>3</comment_count>
    <who name="Oliver Hunt">oliver</who>
    <bug_when>2008-06-30 16:23:49 -0700</bug_when>
    <thetext>But what happens if i have a data uri that is the result of a redirect?  eg. img src=&quot;example.com/redirectToDataURI&quot; ?

I&apos;ll admit i really don&apos;t know how this should effect the model, as this is much more towards Sam&apos;s area of expertise.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>84832</commentid>
    <comment_count>4</comment_count>
    <who name="Sam Weinig">sam</who>
    <bug_when>2008-07-01 01:38:56 -0700</bug_when>
    <thetext>I agree with Anne on this.  data: urls are safe and should not taint the canvas.  The redirection should not be an issue as we will not be basing our tainting policy on the resolved url, but rather the provided one.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>84834</commentid>
    <comment_count>5</comment_count>
    <who name="Adam Barth">abarth</who>
    <bug_when>2008-07-01 01:50:27 -0700</bug_when>
    <thetext>&gt; The redirection should not be an issue as we will not be basing our
&gt; tainting policy on the resolved url, but rather the provided one.

It seems like both URLs are important to consider.  Maybe I&apos;m misunderstanding, but suppose site A includes an image from itself, but the URL actually redirects to site B.  Shouldn&apos;t that taint the canvas as cross-origin even though the provided URL matched the original site?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>84886</commentid>
    <comment_count>6</comment_count>
    <who name="Sam Weinig">sam</who>
    <bug_when>2008-07-01 09:24:31 -0700</bug_when>
    <thetext>I was only referring to the data: url case.  In general, I believe we need to base our tainting policy on the resolved URL.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>84889</commentid>
    <comment_count>7</comment_count>
    <who name="Collin Jackson">collinj</who>
    <bug_when>2008-07-01 10:12:12 -0700</bug_when>
    <thetext>(In reply to comment #6)
&gt; I was only referring to the data: url case.  In general, I believe we need to
&gt; base our tainting policy on the resolved URL.

For data: URLs, since the resolved URL has ambiguous taint, would it be possible to use the second-to-last URL in the redirect chain? (the one that provided a redirect to the ambiguous data: URL) Are there any cases where the second-to-last URL would also be ambiguous?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>146211</commentid>
    <comment_count>8</comment_count>
    <who name="Mihai Sucan">mihai.sucan</who>
    <bug_when>2009-09-10 08:59:47 -0700</bug_when>
    <thetext>I bumped into this bug working on my Web application which uses Canvas.

In Gecko 1.9.0 images with a data URL did mark the canvas as unsafe. Gecko 1.9.1 fixes this issue and now we can draw images with data URLs in Opera and Firefox as well. I would suggest that Webkit does the same.

With regards to the redirection problem I&apos;d say just mark the canvas as unsafe if the data URL comes from a redirection.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>148506</commentid>
    <comment_count>9</comment_count>
    <who name="Adam Barth">abarth</who>
    <bug_when>2009-09-19 10:19:38 -0700</bug_when>
    <thetext>I forgot about this bug and fixed the issue in Bug 29305.  I didn&apos;t add a test for the redirect case.  If you think that&apos;s important, please file a bug for adding a test case and CC me.

*** This bug has been marked as a duplicate of bug 29305 ***</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>