Skip to content

Commit db9fbcd

Browse files
committed
# This is a combination of 2 commits.
# This is the 1st commit message: # This is a combination of 23 commits. # This is the 1st commit message: Integrate CORP and COEP This is part of the introduction of COEP (whatwg/html#5454). The CORP check now takes COEP into account. Also, responses coming from service workers are checked. # This is the commit message #2: Update fetch.bs Co-authored-by: Domenic Denicola <[email protected]> # This is the commit message #3: Update fetch.bs Co-authored-by: Domenic Denicola <[email protected]> # This is the commit message #4: fix # This is the commit message #5: fix # This is the commit message #6: fix # This is the commit message #7: fix # This is the commit message #8: fix # This is the commit message #9: fix # This is the commit message #10: fix # This is the commit message #11: fix # This is the commit message #12: fix # This is the commit message #13: fix # This is the commit message #14: fix # This is the commit message #15: fix # This is the commit message #16: fix # This is the commit message #17: fix # This is the commit message #18: Update fetch.bs Co-authored-by: Anne van Kesteren <[email protected]> # This is the commit message #19: Update fetch.bs Co-authored-by: Anne van Kesteren <[email protected]> # This is the commit message #20: fix # This is the commit message #21: fix # This is the commit message #22: fix # This is the commit message #23: fix # This is the commit message #2: fix
1 parent f083f8c commit db9fbcd

File tree

1 file changed

+139
-59
lines changed

1 file changed

+139
-59
lines changed

fetch.bs

Lines changed: 139 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1751,14 +1751,17 @@ source of security bugs. Please seek security review for features that deal with
17511751

17521752
<hr>
17531753

1754-
<p>To <dfn export>serialize a request URL for reporting</dfn>, given a <a for=/>request</a>
1755-
<var>request</var>, run these steps:
1754+
<p>To <dfn export>serialize a response URL for reporting</dfn>, given a <a for=/>response</a>
1755+
<var>response</var>, run these steps:
17561756

17571757
<ol>
1758+
<li><p>Assert: <var>response</var>'s <a for=response>URL list</a> <a for=list>is not empty</a>.
1759+
17581760
<li>
1759-
<p>Let <var>url</var> be a copy of <var>request</var>'s <a for=request>URL</a>.
1761+
<p>Let <var>url</var> be a copy of <var>response</var>'s <a for=response>URL list</a>'s first
1762+
element.
17601763

1761-
<p class="note">This is not <var>request</var>'s <a for=request>current URL</a> in order to avoid
1764+
<p class="note">This is not <var>response</var>'s <a for=response>URL</a> in order to avoid
17621765
leaking information about redirect targets (see
17631766
<a href="https://w3c.github.io/webappsec-csp/#security-violation-reports">similar considerations for CSP reporting</a>
17641767
too). [[CSP]]
@@ -1772,26 +1775,6 @@ source of security bugs. Please seek security review for features that deal with
17721775
</ol>
17731776

17741777

1775-
<p>To <dfn export for=request id=concept-request-serialize-url-for-reporting>serialize a request URL
1776-
for reporting</dfn>, given a <a for=/>request</a> <var>request</var>, run these steps:
1777-
1778-
<ol>
1779-
<li>
1780-
<p>Let <var>url</var> be a copy of <var>request</var>'s <a for=request>URL</a>.
1781-
1782-
<p class="note">This is not <var>request</var>'s <a for=request>current URL</a> in order to avoid
1783-
leaking information about redirect targets (see
1784-
<a href="https://w3c.github.io/webappsec-csp/#security-violation-reports">similar considerations
1785-
for CSP reporting</a> too).
1786-
1787-
<li><p><a>Set the username</a> given <var>url</var> and the empty string.
1788-
1789-
<li><p><a>Set the password</a> given <var>url</var> and the empty string.
1790-
1791-
<li><p>Return <var>url</var> <a lt="url serializer">serialized</a>with the
1792-
<i>exclude fragment flag</i> set.
1793-
</ol>
1794-
17951778
<h4 id=responses>Responses</h4>
17961779

17971780
<p>The result of <a for=/>fetch</a> is a
@@ -3167,57 +3150,145 @@ response <a for=/>header</a> can be used to require checking a <a for=/>request<
31673150
Cross-Origin-Resource-Policy = %s"same-origin" / %s"same-site" / %s"cross-origin" ; case-sensitive
31683151
</code></pre>
31693152

3170-
<p>To perform a <dfn>cross-origin resource policy check</dfn>, given a <var>request</var> and
3171-
<var>response</var>, run these steps:</p>
3153+
<p>To perform a <dfn export>cross-origin resource policy check</dfn>, given an <a for=url>origin</a>
3154+
<var>origin</var>, an <a for=/>environment settings object</a> <var>settingsObject</var>, a
3155+
<a for=/>response</a> <var>response</var>, and an optional boolean <var>forNavigation</var>, run
3156+
these steps:
31723157

31733158
<ol>
3174-
<li><p>If <var>request</var>'s <a for=request>mode</a> is not "<code>no-cors</code>", then return
3175-
<b>allowed</b>.
3159+
<li><p>Set <var>forNavigation</var> to false if it is not given.
3160+
3161+
<li><p>Let <var>embedderPolicy</var> be <var>settingsObject</var>'s embedder policy.
31763162

31773163
<li>
3178-
<p>If <var>request</var>'s <a for=request>origin</a> is <a>same origin</a> with
3179-
<var>request</var>'s <a for=request>current URL</a>'s <a for=url>origin</a>, then return
3180-
<b>allowed</b>.
3164+
<p>If the <a>cross-origin resource policy internal check</a> with <var>origin</var>,
3165+
"<code>unsafe-none</code>", <var>response</var>, and <var>forNavigation</var> returns
3166+
<b>blocked</b>, then return <b>blocked</b>.
31813167

3182-
<p class="note no-backref">While redirects that carry a
3183-
`<a http-header><code>Cross-Origin-Resource-Policy</code></a>` header are checked, redirects
3184-
without such a header resulting in <var>response</var> do not affect the outcome as the default is
3185-
<b>allowed</b>.
3186-
<!-- This changes with COEP's cross-origin value. -->
3168+
<p class="note">This step is needed because we don't want to report violations not related to
3169+
Cross-Origin Embedder Policy below.
3170+
3171+
<li><p>If the <a>cross-origin resource policy internal check</a> with <var>origin</var>,
3172+
<var>embedderPolicy</var>'s report only value, <var>response</var>, and <var>forNavigation</var>
3173+
returns <b>blocked</b>, then <a>queue a cross-origin embedder policy CORP violation report</a>
3174+
with <var>response</var>, <var>settingsObject</var>, and true.
3175+
3176+
<li><p>If the <a>cross-origin resource policy internal check</a> with <var>origin</var>,
3177+
<var>embedderPolicy</var>'s value, <var>response</var>, and <var>forNavigation</var> returns
3178+
<b>allowed</b>, then return <b>allowed</b>.
3179+
3180+
<li><p><a>Queue a cross-origin embedder policy CORP violation report</a> with <var>response</var>,
3181+
<var>settingsObject</var>, and false.
3182+
3183+
<li><p>Return <b>blocked</b>.
3184+
</ol>
3185+
3186+
<p class="note no-backref">Only HTML's navigate algorithm uses this check with
3187+
<var>forNavigation</var> set to true, and it's always for nested navigations. Otherwise,
3188+
<var>response</var> is either the <a for=internal>internal response</a> of an
3189+
<a>opaque filtered response</a> or a <a for=/>response</a> which will be the
3190+
<a for=internal>internal response</a> of an
3191+
<a>opaque filtered response</a>. [[HTML]]
3192+
3193+
<p>To perform a <dfn>cross-origin resource policy internal check</dfn>, given an
3194+
<a for=url>origin</a> <var>origin</var>, an embedder policy value <var>embedderPolicyValue</var>,
3195+
a <a for=/>response</a> <var>response</var>, and a boolean <var>forNavigation</var>, run these
3196+
steps:
3197+
3198+
<ol>
3199+
<li><p>If <var>forNavigation</var> is true and <var>embedderPolicyValue</var> is
3200+
"<code>unsafe-none</code>", then return <b>allowed</b>.
31873201

31883202
<li>
31893203
<p>Let <var>policy</var> be the result of <a for="header list">getting</a>
31903204
`<a http-header><code>Cross-Origin-Resource-Policy</code></a>` from <var>response</var>'s
31913205
<a for=response>header list</a>.
31923206

31933207
<p class=note>This means that `<code>Cross-Origin-Resource-Policy: same-site, same-origin</code>`
3194-
ends up as <b>allowed</b> below as it will never match anything. Two or more
3208+
ends up as <b>allowed</b> below as it will never match anything, as long as
3209+
<var>embedderPolicyValue</var> is "<code>unsafe-none</code>". Two or more
31953210
`<a http-header><code>Cross-Origin-Resource-Policy</code></a>` headers will have the same effect.
31963211

3197-
<li><p>If <var>policy</var> is `<code>same-origin</code>`, then return <b>blocked</b>.
3212+
<li><p>If <var>policy</var> is neither `<code>same-origin</code>`, `<code>same-site</code>`, nor
3213+
`<code>cross-origin</code>`, then set <var>policy</var> to null.
3214+
3215+
<li><p>If <var>policy</var> is null and <var>embedderPolicyValue</var> is
3216+
"<code>require-corp</code>", then set <var>policy</var> to `<code>same-origin</code>`.
31983217

31993218
<li>
3200-
<p>If the following are true
3219+
<p>Switch on <var>policy</var>:
32013220

3202-
<ul class=brief>
3203-
<li><var>request</var>'s <a for=request>origin</a> is <a>schemelessly same site</a> with
3204-
<var>request</var>'s <a for=request>current URL</a>'s <a for=url>origin</a>
3205-
<li><var>request</var>'s <a for=request>origin</a>'s <a for=url>scheme</a> is
3206-
"<code>https</code>" or <var>response</var>'s <a for=response>HTTPS state</a> is
3207-
"<code>none</code>"
3208-
</ul>
3221+
<dl class=switch>
3222+
<dt>null
3223+
<dt>`<code>cross-origin</code>`
3224+
<dd><p>Return <b>allowed</b>.
3225+
3226+
<dt>`<code>same-origin</code>`
3227+
<dd>
3228+
<p>If <var>origin</var> is <a>same origin</a> with <var>response</var>'s <a for=response>URL</a>'s
3229+
<a for=url>origin</a>, then return <b>allowed</b>.
32093230

3210-
<p>then return <b>allowed</b>.
3231+
<p>Otherwise, return <b>blocked</b>.
32113232

3212-
<p class=note>This prevents HTTPS responses with
3213-
`<code>Cross-Origin-Resource-Policy: same-site</code>` from being accessed without secure
3214-
transport.
3233+
<dt>`<code>same-site</code>`
3234+
<dd>
3235+
<p>If the following are true
32153236

3216-
<li><p>If <var>policy</var> is `<code>same-site</code>`, then return <b>blocked</b>.
3237+
<ul class=brief>
3238+
<li><p><var>origin</var> is <a>schemelessly same site</a> with <var>response</var>'s
3239+
<a for=response>URL</a>'s <a for=url>origin</a>
32173240

3218-
<li><p>Return <b>allowed</b>.
3241+
<li><p><var>origin</var>'s <a for=url>scheme</a> is "<code>https</code>" or
3242+
<var>response</var>'s <a for=response>HTTPS state</a> is "<code>none</code>"
3243+
</ul>
3244+
3245+
<p>then return <b>allowed</b>.
3246+
3247+
<p>Otherwise, return <b>blocked</b>.
3248+
3249+
<p class=note>`<code>Cross-Origin-Resource-Policy: same-site</code>` does not consider a
3250+
response delivered via a secure transport to match a non-secure requesting origin,
3251+
even if their hosts are otherwise same site. Securely-transported responses will only
3252+
match a securely-transported initiator.
3253+
</dl>
32193254
</ol>
32203255

3256+
<p>To <dfn>queue a cross-origin embedder policy CORP violation report</dfn>, given a
3257+
<a for=/>response</a> <var>response</var>, an <a for=/>environment settings object</a>
3258+
<var>settingsObject</var>, and a boolean <var>reportOnly</var>, run these steps:
3259+
3260+
<ol>
3261+
<li><p>Let <var>endpoint</var> be <var>settingsObject</var>'s embedder policy's
3262+
report only reporting endpoint if the <var>reportOnly</var> is true and
3263+
<var>settingsObject</var>'s embedder policy's reporting endpoint otherwise.
3264+
3265+
<li><p>Let <var>serialized url</var> be the result of
3266+
<a lt="serialize a response URL for reporting">serializing a response URL for reporting</a> with
3267+
<var>response</var>.
3268+
3269+
<li>
3270+
<p>Let <var>body</var> be a new object containing the following properties:
3271+
3272+
<table>
3273+
<thead>
3274+
<th>key
3275+
<th>value
3276+
</thead>
3277+
<tbody>
3278+
<tr>
3279+
<td>"<code>type</code>"
3280+
<td>"<code>corp</code>"
3281+
</tr>
3282+
<tr>
3283+
<td>"<code>blocked-url</code>"
3284+
<td><var>serialized url</var>
3285+
</tr>
3286+
</tbody>
3287+
</table>
3288+
3289+
<li><p><a for="reporting">Queue</a> <var>body</var> as the "<code>coep</code>"report type for
3290+
<var>endpoint</var> on <var>settingsObject</var>. [[!REPORTING]]
3291+
</ol>
32213292

32223293

32233294
<h2 id=fetching>Fetching</h2>
@@ -3609,9 +3680,8 @@ optionally with a <i>recursive flag</i>, run these steps:
36093680
<p>If <var>internalResponse</var>'s <a for=response>URL list</a> <a for=list>is empty</a>, then
36103681
set it to a <a for=list>clone</a> of <var>request</var>'s <a for=request>URL list</a>.
36113682

3612-
<p class=note>A <a for=/>response</a>'s <a for=response>URL list</a> will typically be empty at
3613-
this point, unless it came from a service worker, in which case it will only be empty if it was
3614-
created through <a lt="Response()" constructor><code>new Response()</code></a>.
3683+
<p class=note>A <a for=/>response</a>'s <a for=response>URL list</a> can be empty when it's for
3684+
"<code>about</code>" URLs for example.
36153685
<!-- If you are ever tempted to move this around, carefully consider responses from about URLs,
36163686
blob URLs, service workers, HTTP cache, HTTP network, etc. -->
36173687

@@ -3981,6 +4051,17 @@ optional <i>CORS-preflight flag</i>, run these steps:
39814051
then set <var>request</var>'s <a for=request>timing allow failed flag</a>.
39824052
</ol>
39834053

4054+
<li>
4055+
<p>If <var>request</var>'s <a for=request>response tainting</a> is "<code>opaque</code>"
4056+
and the <a>cross-origin resource policy check</a> with <var>request</var>'s
4057+
<a for=request>origin</a>, <var>request</var>'s <a for=request>client</a>, and
4058+
<var>actualResponse</var> returns <b>blocked</b>, then return a <a>network error</a>.
4059+
4060+
<p class=note>The <a>cross-origin resource policy check</a> runs for responses coming from the
4061+
network and responses coming from the service worker. This is different from the
4062+
<a>CORS check</a>. This is because <var>request</var>'s <a for=request>client</a> and the
4063+
service worker can have different embedder policies.
4064+
39844065
<li>
39854066
<p>If <var>actualResponse</var>'s <a for=response>status</a> is a <a>redirect status</a>, then:
39864067

@@ -4533,13 +4614,12 @@ Range Requests</cite>. [[HTTP-RANGE]] However, this is not widely supported by b
45334614
</ol>
45344615
</ol>
45354616

4617+
<li><p>Set <var>response</var>'s <a for=response>URL list</a> to a <a for=list>clone</a> of
4618+
<var>httpRequest</var>'s <a for=request>URL list</a>.
4619+
45364620
<li><p>If <var>httpRequest</var>'s <a for=request>header list</a> <a for="header list">contains</a>
45374621
`<code>Range</code>`, then set <var>response</var>'s <a for=response>range-requested flag</a>.
45384622

4539-
<li><p>If <var>httpRequest</var>'s <a for=request>response tainting</a> is not "<code>cors</code>"
4540-
and the <a>cross-origin resource policy check</a> with <var>request</var> and <var>response</var>
4541-
returns <b>blocked</b>, then return a <a>network error</a>.
4542-
45434623
<li>
45444624
<p>If <var>response</var>'s <a for=response>status</a> is <code>401</code>,
45454625
<var>httpRequest</var>'s <a for=request>response tainting</a> is not "<code>cors</code>", the

0 commit comments

Comments
 (0)