<?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>242889</bug_id>
          
          <creation_ts>2022-07-19 01:14:29 -0700</creation_ts>
          <short_desc>Canvas&apos; security should not take into account Single Origin (for videos and images)</short_desc>
          <delta_ts>2022-11-30 17:23:51 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Canvas</component>
          <version>Other</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=248437</see_also>
    
    <see_also>https://bugs.webkit.org/show_bug.cgi?id=248462</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Jean-Yves Avenard [:jya]">jean-yves.avenard</reporter>
          <assigned_to name="Jean-Yves Avenard [:jya]">jean-yves.avenard</assigned_to>
          <cc>bfulgham</cc>
    
    <cc>dino</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>wilander</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1885039</commentid>
    <comment_count>0</comment_count>
    <who name="Jean-Yves Avenard [:jya]">jean-yves.avenard</who>
    <bug_when>2022-07-19 01:14:29 -0700</bug_when>
    <thetext>Per canvas&apos; spec:
https://html.spec.whatwg.org/multipage/canvas.html#the-image-argument-is-not-origin-clean

an object image is not origin-clean if:
HTMLOrSVGImageElement
    image&apos;s current request&apos;s image data is CORS-cross-origin.
HTMLVideoElement
    image&apos;s media data is CORS-cross-origin.
HTMLCanvasElement
ImageBitmap
    image&apos;s bitmap&apos;s origin-clean flag is false.

And as per the security&apos;s policy:
https://html.spec.whatwg.org/multipage/canvas.html#security-with-canvas-elements

&quot;To mitigate this, bitmaps used with canvas elements and ImageBitmap objects are defined to have a flag indicating whether they are origin-clean. All bitmaps start with their origin-clean set to true. The flag is set to false when cross-origin images are used.&quot;

And various methods will reject their promise according to this origin-clean flag.
Such as getImageData: https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-getimagedata
2. If the CanvasRenderingContext2D&apos;s origin-clean flag is set to false, then throw a &quot;SecurityError&quot; DOMException.

`CanvasRenderingContext::wouldTaintOrigin` is the method used to determine if a particular object can be used with a canvas.
Image:
https://searchfox.org/wubkat/rev/3c7828ddd50109debe235dded88a94e66d33e879/Source/WebCore/html/canvas/CanvasRenderingContext.cpp#132-133
```
   if (!image-&gt;hasSingleSecurityOrigin())
        return true;
```

Videos:
https://searchfox.org/wubkat/rev/3c7828ddd50109debe235dded88a94e66d33e879/Source/WebCore/html/canvas/CanvasRenderingContext.cpp#154-155
```
    if (!video-&gt;hasSingleSecurityOrigin())
        return true;
```

This requirement that an object used with a canvas has a single origin isn&apos;t found in the canvas spec ; only that the data is CORS-cross-origin

The current implementation prevents drawing into a canvas a video that was served across multiple mirrors as is commonly found in the media world.

The check that hasSingleSecurityOrigin must be true should be removed.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1885040</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2022-07-19 01:14:53 -0700</bug_when>
    <thetext>&lt;rdar://problem/97245327&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1914872</commentid>
    <comment_count>2</comment_count>
    <who name="Jean-Yves Avenard [:jya]">jean-yves.avenard</who>
    <bug_when>2022-11-27 16:50:37 -0800</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/6844</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1915785</commentid>
    <comment_count>3</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2022-11-30 17:23:49 -0800</bug_when>
    <thetext>Committed 257207@main (2c5193d0471c): &lt;https://commits.webkit.org/257207@main&gt;

Reviewed commits have been landed. Closing PR #6844 and removing active labels.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>