<html>
    <head>
      <base href="https://bugs.webkit.org/" />
    </head>
    <body>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - CSP Wildcard support"
   href="https://bugs.webkit.org/show_bug.cgi?id=160656#c1">Comment # 1</a>
              on <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - CSP Wildcard support"
   href="https://bugs.webkit.org/show_bug.cgi?id=160656">bug 160656</a>
              from <span class="vcard"><a class="email" href="mailto:dbates&#64;webkit.org" title="Daniel Bates &lt;dbates&#64;webkit.org&gt;"> <span class="fn">Daniel Bates</span></a>
</span></b>
        <pre>(In reply to <a href="show_bug.cgi?id=160656#c0">comment #0</a>)
<span class="quote">&gt; In regards to &quot;More restrictive wildcard&quot; on:
&gt; 
&gt; <a href="https://webkit.org/blog/6830/a-refined-content-security-policy/">https://webkit.org/blog/6830/a-refined-content-security-policy/</a>
&gt; 
&gt; Where you are suggesting allowing &quot;data:&quot; for image and &quot;data:, blob:&quot; for
&gt; media (the heading should really be &quot;less restrictive&quot;).
&gt; </span >

As the blog post explains we are intentionally &quot;less restrictive&quot; with respect to images and media for web compatibility. In general the behavior of * in WebKit is more restrictive than the behavior of * as described in the CSP Level 2 standard, which allows * to match an arbitrary scheme except those in {data:, blob:, and filesystem:}. The table in the blog post describes the matching criterion used by WebKit.

Additional remarks:

At the time this decision was made we observed some popular native apps and popular web sites that assumed * would allow data URLs for images. These observations were consistent with Mozilla's experience of breaking popular sites when they implemented the CSP Level 2 spec.-compliant behavior for * (see <a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED FIXED - CSP: Source '*' should not match URLs with schemes blob, data, or filesystem"
   href="show_bug.cgi?id=154122#c2">bug #154122, comment 2</a> for more details). It is likely that Mozilla's implementation of * has since changed. We should further investigate. Regardless, we should evaluate whether we can remove the exemptions we have for * to match data: for images, and data: and blob: for media while minimizing compatibility issues. We will need to consider the amount of app/site breakage together with an evangelism effort to get app writers and site owners to explicitly add data: and/or blob: schemes to their CSP policy.

<span class="quote">&gt; Please can you follow the spec instead:
&gt; 
&gt; <a href="https://www.w3.org/TR/CSP2/#match-source-expression">https://www.w3.org/TR/CSP2/#match-source-expression</a>
&gt; 
&gt; &quot;If the source expression a consists of a single U+002A ASTERISK character
&gt; (*), and url’s scheme is not one of blob, data, filesystem, then return does
&gt; match.&quot;
&gt; 
&gt; This means is that websites that want to use &quot;data:&quot; for their images just
&gt; add it to their directive (img-src * data:;), whereas websites that really
&gt; don't use &quot;data:&quot; urls, can continue to use a wildcard without worrying
&gt; about images that use this scheme (e.g. a malicious resource, delivered
&gt; inline, which means there is no need to find somewhere to host it).
&gt; </span >

Notice that this definition allows * to match an arbitrary scheme that is not blob:, data:, or filesystem:. For example, * will match a custom protocol, say app:.

<span class="quote">&gt; Keeping in mind that images, like TIFF's, can have buffer overflows ;-)
&gt; </span >

Obviously there are disadvantages with allowing * to match data: for images, and data: and blob: for media. At the time we made the decision to allow * match these schemes we felt that the risks of a data/blob URL exploiting a image/media decoder bug were less than the web compatibility risks of * not matching these schemes. We should evaluate whether this trade off still makes sense.

<span class="quote">&gt; Might be related to Issue 153090.</span >

Can you elaborate?</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>