|
1001 | 1001 | <div class="head"> |
1002 | 1002 | <p data-fill-with="logo"><a class="logo" href="http://www.w3.org/"> <img alt="W3C" height="48" src="https://www.w3.org/Icons/w3c_home" width="72"> </a> </p> |
1003 | 1003 | <h1 class="p-name no-ref" id="title">Content Security Policy Level 3</h1> |
1004 | | - <h2 class="no-num no-toc no-ref heading settled" id="subtitle"><span class="content">Editor’s Draft, <time class="dt-updated" datetime="2015-10-21">21 October 2015</time></span></h2> |
| 1004 | + <h2 class="no-num no-toc no-ref heading settled" id="subtitle"><span class="content">Editor’s Draft, <time class="dt-updated" datetime="2015-10-28">28 October 2015</time></span></h2> |
1005 | 1005 | <div data-fill-with="spec-metadata"> |
1006 | 1006 | <dl> |
1007 | 1007 | <dt>This version: |
@@ -2429,34 +2429,46 @@ <h5 class="heading settled" data-algorithm="Does url match expression in origin |
2429 | 2429 | <li data-md=""> |
2430 | 2430 | <p>If <var>expression</var> is the string "*", and <var>url</var>'s <code class="idl"><a data-link-type="idl" href="https://url.spec.whatwg.org/#concept-url-scheme">scheme</a></code> is not a <a data-link-type="dfn" href="https://url.spec.whatwg.org/#local-scheme">local scheme</a>, return "<code>Matches</code>".</p> |
2431 | 2431 | <li data-md=""> |
2432 | | - <p>If <var>expression</var> matches the <a data-link-type="grammar" href="#grammardef-scheme-source"><code>scheme-source</code></a> grammar:</p> |
| 2432 | + <p>If <var>expression</var> matches the <a data-link-type="grammar" href="#grammardef-scheme-source"><code>scheme-source</code></a> or <a data-link-type="grammar" href="#grammardef-host-source"><code>host-source</code></a> grammar:</p> |
2433 | 2433 | <ol> |
2434 | 2434 | <li data-md=""> |
2435 | | - <p>If <var>url</var>'s <code class="idl"><a data-link-type="idl" href="https://url.spec.whatwg.org/#concept-url-scheme">scheme</a></code> is an <a data-link-type="dfn" href="http://www.w3.org/TR/html5/infrastructure.html#ascii-case-insensitive">ASCII case-insensitive match</a> for <var>expression</var>'s <a data-link-type="grammar" href="#grammardef-scheme-part"><code>scheme-part</code></a>, return "<code>Matches</code>".</p> |
| 2435 | + <p>If <var>expression</var> has a <a data-link-type="grammar" href="#grammardef-scheme-part"><code>scheme-part</code></a> that is not an <a data-link-type="dfn" href="http://www.w3.org/TR/html5/infrastructure.html#ascii-case-insensitive">ASCII case-insensitive match</a> for <var>url</var>'s <code class="idl"><a data-link-type="idl" href="https://url.spec.whatwg.org/#concept-url-scheme">scheme</a></code>, then |
| 2436 | + return "<code>Does Not Match</code>" unless one of the following conditions is |
| 2437 | + met:</p> |
| 2438 | + <ol> |
| 2439 | + <li data-md=""> |
| 2440 | + <p><var>expression</var>'s <a data-link-type="grammar" href="#grammardef-scheme-part"><code>scheme-part</code></a> is an <a data-link-type="dfn" href="http://www.w3.org/TR/html5/infrastructure.html#ascii-case-insensitive">ASCII |
| 2441 | + case-insensitive match</a> for "<code>http</code>" and <var>url</var>'s <code class="idl"><a data-link-type="idl" href="https://url.spec.whatwg.org/#concept-url-scheme">scheme</a></code> is "<code>https</code>"</p> |
| 2442 | + <li data-md=""> |
| 2443 | + <p><var>expression</var>'s <a data-link-type="grammar" href="#grammardef-scheme-part"><code>scheme-part</code></a> is an <a data-link-type="dfn" href="http://www.w3.org/TR/html5/infrastructure.html#ascii-case-insensitive">ASCII |
| 2444 | + case-insensitive match</a> for "<code>ws</code>" and <var>url</var>'s <code class="idl"><a data-link-type="idl" href="https://url.spec.whatwg.org/#concept-url-scheme">scheme</a></code> is "<code>wss</code>"</p> |
| 2445 | + </ol> |
2436 | 2446 | <li data-md=""> |
2437 | | - <p>Return "<code>Does Not Match</code>".</p> |
| 2447 | + <p>If <var>expression</var> matches the <a data-link-type="grammar" href="#grammardef-scheme-source"><code>scheme-source</code></a> grammar, |
| 2448 | + return "<code>Matches</code>".</p> |
2438 | 2449 | </ol> |
| 2450 | + <p class="note" role="note">Note: This logic effectively means that <code>script-src http:</code> is |
| 2451 | + equivalent to <code>script-src http: https:</code>, and <code>script-src http://example.com/</code> is equivalent to <code>script-src http://example.com https://example.com</code>. In short, we always allow a |
| 2452 | + secure upgrade from an explicitly insecure expression.</p> |
2439 | 2453 | <li data-md=""> |
2440 | 2454 | <p>If <var>expression</var> matches the <a data-link-type="grammar" href="#grammardef-host-source"><code>host-source</code></a> grammar:</p> |
2441 | 2455 | <ol> |
2442 | 2456 | <li data-md=""> |
2443 | 2457 | <p>If <var>url</var>'s <code class="idl"><a data-link-type="idl" href="https://url.spec.whatwg.org/#concept-url-host">host</a></code> is <code>null</code>, return "<code>Does Not Match</code>".</p> |
2444 | | - <li data-md=""> |
2445 | | - <p>If <var>expression</var> has a <a data-link-type="grammar" href="#grammardef-scheme-part"><code>scheme-part</code></a> that is not an <a data-link-type="dfn" href="http://www.w3.org/TR/html5/infrastructure.html#ascii-case-insensitive">ASCII case-insensitive match</a> for <var>url</var>'s <code class="idl"><a data-link-type="idl" href="https://url.spec.whatwg.org/#concept-url-scheme">scheme</a></code>, return |
2446 | | - "<code>Does Not Match</code>".</p> |
2447 | 2458 | <li data-md=""> |
2448 | 2459 | <p>If <var>expression</var> does not have a <a data-link-type="grammar" href="#grammardef-scheme-part"><code>scheme-part</code></a>, then |
2449 | 2460 | return "<code>Does Not Match</code>" unless one of the following conditions is |
2450 | 2461 | met:</p> |
2451 | 2462 | <ol> |
2452 | 2463 | <li data-md=""> |
2453 | | - <p><var>origin</var>'s <code class="idl"><a data-link-type="idl" href="https://url.spec.whatwg.org/#concept-url-scheme">scheme</a></code> is an <a data-link-type="dfn" href="http://www.w3.org/TR/html5/infrastructure.html#ascii-case-insensitive">ASCII case-insensitive |
2454 | | - match</a> for "<code>HTTP</code>", and <var>url</var>'s <code class="idl"><a data-link-type="idl" href="https://url.spec.whatwg.org/#concept-url-scheme">scheme</a></code> is an <a data-link-type="dfn" href="http://www.w3.org/TR/html5/infrastructure.html#ascii-case-insensitive">ASCII |
2455 | | - case-insensitive match</a> for either "<code>HTTP</code>" or "<code>HTTPS</code>".</p> |
| 2464 | + <p><var>origin</var>'s <code class="idl"><a data-link-type="idl" href="https://url.spec.whatwg.org/#concept-url-scheme">scheme</a></code> is <var>url</var>'s <code class="idl"><a data-link-type="idl" href="https://url.spec.whatwg.org/#concept-url-scheme">scheme</a></code></p> |
| 2465 | + <li data-md=""> |
| 2466 | + <p><var>origin</var>'s <code class="idl"><a data-link-type="idl" href="https://url.spec.whatwg.org/#concept-url-scheme">scheme</a></code> is "<code>http</code>", and <var>url</var>'s <code class="idl"><a data-link-type="idl" href="https://url.spec.whatwg.org/#concept-url-scheme">scheme</a></code> one of "<code>https</code>", "<code>ws</code>", or "<code>wss</code>".</p> |
2456 | 2467 | <li data-md=""> |
2457 | | - <p><var>origin</var>'s <code class="idl"><a data-link-type="idl" href="https://url.spec.whatwg.org/#concept-url-scheme">scheme</a></code> is an <a data-link-type="dfn" href="http://www.w3.org/TR/html5/infrastructure.html#ascii-case-insensitive">ASCII case-insensitive |
2458 | | - match</a> for <var>url</var>'s <code class="idl"><a data-link-type="idl" href="https://url.spec.whatwg.org/#concept-url-scheme">scheme</a></code>.</p> |
| 2468 | + <p><var>origin</var>'s <code class="idl"><a data-link-type="idl" href="https://url.spec.whatwg.org/#concept-url-scheme">scheme</a></code> is "<code>https</code>", and <var>url</var>'s <code class="idl"><a data-link-type="idl" href="https://url.spec.whatwg.org/#concept-url-scheme">scheme</a></code> is "<code>wss</code>".</p> |
2459 | 2469 | </ol> |
| 2470 | + <p class="note" role="note">Note: As with <a data-link-type="grammar" href="#grammardef-scheme-part"><code>scheme-part</code></a> above, we allow schemeless <a data-link-type="grammar" href="#grammardef-host-source"><code>host-source</code></a> expressions to be upgraded from insecure |
| 2471 | + schemes to secure schemes.</p> |
2460 | 2472 | <li data-md=""> |
2461 | 2473 | <p>If the first character of <var>expression</var>'s <a data-link-type="grammar" href="#grammardef-host-part"><code>host-part</code></a> is an U+002A ASTERISK character (<code>*</code>):</p> |
2462 | 2474 | <ol> |
@@ -2520,7 +2532,27 @@ <h5 class="heading settled" data-algorithm="Does url match expression in origin |
2520 | 2532 | </ol> |
2521 | 2533 | <li data-md=""> |
2522 | 2534 | <p>If <var>expression</var> is an <a data-link-type="dfn" href="http://www.w3.org/TR/html5/infrastructure.html#ascii-case-insensitive">ASCII case-insensitive match</a> for "<code>'self'</code>", |
2523 | | - and <var>origin</var> is the same as <var>url</var>'s <code class="idl"><a data-link-type="idl" href="https://url.spec.whatwg.org/#concept-url-origin">origin</a></code>, return "<code>Matches</code>".</p> |
| 2535 | + return "<code>Matches</code>" if one or more of the following conditions is met:</p> |
| 2536 | + <ol> |
| 2537 | + <li data-md=""> |
| 2538 | + <p><var>origin</var> is the same as <var>url</var>'s <code class="idl"><a data-link-type="idl" href="https://url.spec.whatwg.org/#concept-url-origin">origin</a></code></p> |
| 2539 | + <li data-md=""> |
| 2540 | + <p><var>origin</var>'s <code class="idl"><a data-link-type="idl" href="https://url.spec.whatwg.org/#concept-url-host">host</a></code> is the same as <var>url</var>'s <code class="idl"><a data-link-type="idl" href="https://url.spec.whatwg.org/#concept-url-host">host</a></code>, <var>origin</var>'s <code class="idl"><a data-link-type="idl" href="https://url.spec.whatwg.org/#concept-url-port">port</a></code> and <var>url</var>'s {{URL/port} are either the same |
| 2541 | + or the <a data-link-type="dfn" href="https://url.spec.whatwg.org/#default-port">default ports</a> for their respective <code class="idl"><a data-link-type="idl" href="https://url.spec.whatwg.org/#concept-url-scheme">scheme</a></code>s, and |
| 2542 | + one or more of the following conditions is met:</p> |
| 2543 | + <ol> |
| 2544 | + <li data-md=""> |
| 2545 | + <p><var>url</var>'s <code class="idl"><a data-link-type="idl" href="https://url.spec.whatwg.org/#concept-url-scheme">scheme</a></code> is "<code>https</code>" or "<code>wss</code>"</p> |
| 2546 | + <li data-md=""> |
| 2547 | + <p><var>origin</var>'s <code class="idl"><a data-link-type="idl" href="https://url.spec.whatwg.org/#concept-url-scheme">scheme</a></code> is "<code>http</code>"</p> |
| 2548 | + </ol> |
| 2549 | + </ol> |
| 2550 | + <p class="note" role="note">Note: Like the <a data-link-type="grammar" href="#grammardef-scheme-part"><code>scheme-part</code></a> logic above, the "<code>'self'</code>" |
| 2551 | + matching algorithm allows upgrades to secure schemes when it is safe to do |
| 2552 | + so. We limit these upgrades to endpoints running on the default port for a |
| 2553 | + particular scheme or a port that matches the origin of the protected |
| 2554 | + resource, as this seems sufficient to deal with upgrades that can be |
| 2555 | + reasonably expected to succeed.</p> |
2524 | 2556 | <li data-md=""> |
2525 | 2557 | <p>Return "<code>Does Not Match</code>".</p> |
2526 | 2558 | </ol> |
|
0 commit comments