<?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>248462</bug_id>
          
          <creation_ts>2022-11-29 01:05:52 -0800</creation_ts>
          <short_desc>Canvas check for painting videos is incorrect.</short_desc>
          <delta_ts>2023-01-19 13:20:06 -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>Media</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=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>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Jean-Yves Avenard [:jya]">jean-yves.avenard</reporter>
          <assigned_to name="Matt Woodrow">mattwoodrow</assigned_to>
          <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1915247</commentid>
    <comment_count>0</comment_count>
    <who name="Jean-Yves Avenard [:jya]">jean-yves.avenard</who>
    <bug_when>2022-11-29 01:05:52 -0800</bug_when>
    <thetext>Similar to bug 242889, that cause the same end result but for a slightly different reason.


Canvas&apos; security should not take into account Single Origin (for videos and images)

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.

The definition for CORS-cross-origin is:
https://html.spec.whatwg.org/multipage/urls-and-fetching.html#cors-cross-origin
&quot;A response whose type is &quot;opaque&quot; or &quot;opaqueredirect&quot; is CORS-cross-origin.&quot;

However, the `bool CanvasRenderingContext::wouldTaintOrigin(const HTMLVideoElement* video)` method to perform this check does:
```
    if (!video-&gt;didPassCORSAccessCheck() &amp;&amp; video-&gt;wouldTaintOrigin(*m_canvas.securityOrigin()))
        return true;
```

When a video is decoded via AVFoundation; the method wouldTaintOrigin does the following in WebCoreNSURLSession:
```
- (BOOL)wouldTaintOrigin:(const WebCore::SecurityOrigin &amp;)origin
{
    for (auto&amp; responseOrigin : _origins) {
        if (!origin.isSameOriginDomain(*responseOrigin))
            return true;
    }
    return false;
}
```

so it only checks that the origin is the same across all responses.

This isn&apos;t per spec, the origin should be ignored and instead we should rely on the CORS cross-origin data.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1915248</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2022-11-29 01:06:12 -0800</bug_when>
    <thetext>&lt;rdar://problem/102754474&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1925716</commentid>
    <comment_count>2</comment_count>
    <who name="Matt Woodrow">mattwoodrow</who>
    <bug_when>2023-01-15 16:38:30 -0800</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/8603</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1926700</commentid>
    <comment_count>3</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2023-01-19 13:19:51 -0800</bug_when>
    <thetext>Committed 259108@main (ec3e1edcb9e5): &lt;https://commits.webkit.org/259108@main&gt;

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

    </bug>

</bugzilla>