@@ -1751,14 +1751,17 @@ source of security bugs. Please seek security review for features that deal with
1751
1751
1752
1752
<hr>
1753
1753
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:
1756
1756
1757
1757
<ol>
1758
+ <li><p> Assert: <var> response</var> 's <a for=response>URL list</a> <a for=list>is not empty</a> .
1759
+
1758
1760
<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.
1760
1763
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
1762
1765
leaking information about redirect targets (see
1763
1766
<a href="https://w3c.github.io/webappsec-csp/#security-violation-reports">similar considerations for CSP reporting</a>
1764
1767
too). [[CSP]]
@@ -1772,26 +1775,6 @@ source of security bugs. Please seek security review for features that deal with
1772
1775
</ol>
1773
1776
1774
1777
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
-
1795
1778
<h4 id=responses>Responses</h4>
1796
1779
1797
1780
<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<
3167
3150
Cross-Origin-Resource-Policy = %s"same-origin" / %s"same-site" / %s"cross-origin" ; case-sensitive
3168
3151
</code></pre>
3169
3152
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:
3172
3157
3173
3158
<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.
3176
3162
3177
3163
<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> .
3181
3167
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> .
3187
3201
3188
3202
<li>
3189
3203
<p> Let <var> policy</var> be the result of <a for="header list">getting</a>
3190
3204
`<a http-header><code>Cross-Origin-Resource-Policy</code></a> ` from <var> response</var> 's
3191
3205
<a for=response>header list</a> .
3192
3206
3193
3207
<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
3195
3210
`<a http-header><code>Cross-Origin-Resource-Policy</code></a> ` headers will have the same effect.
3196
3211
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> `.
3198
3217
3199
3218
<li>
3200
- <p> If the following are true
3219
+ <p> Switch on <var> policy </var> :
3201
3220
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> .
3209
3230
3210
- <p> then return <b> allowed </b> .
3231
+ <p> Otherwise, return <b> blocked </b> .
3211
3232
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
3215
3236
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>
3217
3240
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>
3219
3254
</ol>
3220
3255
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>
3221
3292
3222
3293
3223
3294
<h2 id=fetching>Fetching</h2>
@@ -3609,9 +3680,8 @@ optionally with a <i>recursive flag</i>, run these steps:
3609
3680
<p> If <var> internalResponse</var> 's <a for=response>URL list</a> <a for=list>is empty</a> , then
3610
3681
set it to a <a for=list>clone</a> of <var> request</var> 's <a for=request>URL list</a> .
3611
3682
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.
3615
3685
<!-- If you are ever tempted to move this around, carefully consider responses from about URLs,
3616
3686
blob URLs, service workers, HTTP cache, HTTP network, etc. -->
3617
3687
@@ -3981,6 +4051,17 @@ optional <i>CORS-preflight flag</i>, run these steps:
3981
4051
then set <var> request</var> 's <a for=request>timing allow failed flag</a> .
3982
4052
</ol>
3983
4053
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
+
3984
4065
<li>
3985
4066
<p> If <var> actualResponse</var> 's <a for=response>status</a> is a <a>redirect status</a> , then:
3986
4067
@@ -4533,13 +4614,12 @@ Range Requests</cite>. [[HTTP-RANGE]] However, this is not widely supported by b
4533
4614
</ol>
4534
4615
</ol>
4535
4616
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
+
4536
4620
<li><p> If <var> httpRequest</var> 's <a for=request>header list</a> <a for="header list">contains</a>
4537
4621
`<code> Range</code> `, then set <var> response</var> 's <a for=response>range-requested flag</a> .
4538
4622
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
-
4543
4623
<li>
4544
4624
<p> If <var> response</var> 's <a for=response>status</a> is <code> 401</code> ,
4545
4625
<var> httpRequest</var> 's <a for=request>response tainting</a> is not "<code> cors</code> ", the
0 commit comments