<?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>248437</bug_id>
          
          <creation_ts>2022-11-28 15:57:09 -0800</creation_ts>
          <short_desc>Canvas&apos; security should not take into account Single Origin for SVG images</short_desc>
          <delta_ts>2022-11-28 16:19:07 -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>NEW</bug_status>
          <resolution></resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=242889</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>
          
          <blocked>119639</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Jean-Yves Avenard [:jya]">jean-yves.avenard</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>dino</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1915146</commentid>
    <comment_count>0</comment_count>
    <who name="Jean-Yves Avenard [:jya]">jean-yves.avenard</who>
    <bug_when>2022-11-28 15:57:09 -0800</bug_when>
    <thetext>This is similar to bug 242889, but requires a more extensive solution.

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.

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;
```

The requirement that the SVG be of a single security origin is incorrect. It was introduced in https://trac.webkit.org/changeset/195614/webkit which made foreignObject regardless of their cross-origin data to taint the image.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1915157</commentid>
    <comment_count>1</comment_count>
    <who name="Jean-Yves Avenard [:jya]">jean-yves.avenard</who>
    <bug_when>2022-11-28 16:18:58 -0800</bug_when>
    <thetext>rdar://102738351</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>