@@ -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]]
@@ -3147,55 +3150,150 @@ response <a for=/>header</a> can be used to require checking a <a for=/>request<
3147
3150
Cross-Origin-Resource-Policy = %s"same-origin" / %s"same-site" / %s"cross-origin" ; case-sensitive
3148
3151
</code></pre>
3149
3152
3150
- <p> To perform a <dfn>cross-origin resource policy check</dfn> , given a <var> request</var> and
3151
- <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:
3152
3157
3153
3158
<ol>
3154
- <li><p> If <var> request</var> 's <a for=request>mode</a> is not "<code> no-cors</code> ", then return
3155
- <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
3162
+ <a for="environment settings object">embedder policy</a> .
3156
3163
3157
3164
<li>
3158
- <p> If <var> request </var> 's <a for=request> origin</a> is <a>same origin</a> with
3159
- <var> request </var> 's < a for=request>current URL </a>' s <a for=url>origin</a > , then return
3160
- <b> allowed </b> .
3165
+ <p> If the <a>cross- origin resource policy internal check </a> with <var> origin</var> ,
3166
+ " <code> < a for="embedder policy value">unsafe-none </a></code> ", <var> response </var > , and
3167
+ <var> forNavigation </var> returns <b> blocked </b> , then return <b> blocked </b> .
3161
3168
3162
- <p class="note no-backref"> While redirects that carry a
3163
- `<a http-header><code>Cross-Origin-Resource-Policy</code></a> ` header are checked, redirects
3164
- without such a header resulting in <var> response</var> do not affect the outcome as the default is
3165
- <b> allowed</b> .
3166
- <!-- This changes with COEP's cross-origin value. -->
3169
+ <p class="note"> This step is needed because we don't want to report violations not related to
3170
+ Cross-Origin Embedder Policy below.
3171
+
3172
+ <li><p> If the <a>cross-origin resource policy internal check</a> with <var> origin</var> ,
3173
+ <var> embedderPolicy</var> 's <a for="embedder policy">report only value</a> , <var> response</var> ,
3174
+ and <var> forNavigation</var> returns <b> blocked</b> , then
3175
+ <a>queue a cross-origin embedder policy CORP violation report</a> with <var> response</var> ,
3176
+ <var> settingsObject</var> , and true.
3177
+
3178
+ <li><p> If the <a>cross-origin resource policy internal check</a> with <var> origin</var> ,
3179
+ <var> embedderPolicy</var> 's <a for="embedder policy">value</a> , <var> response</var> , and
3180
+ <var> forNavigation</var> returns <b> allowed</b> , then return <b> allowed</b> .
3181
+
3182
+ <li><p> <a>Queue a cross-origin embedder policy CORP violation report</a> with <var> response</var> ,
3183
+ <var> settingsObject</var> , and false.
3184
+
3185
+ <li><p> Return <b> blocked</b> .
3186
+ </ol>
3187
+
3188
+ <p class="note no-backref"> Only HTML's navigate algorithm uses this check with
3189
+ <var> forNavigation</var> set to true, and it's always for nested navigations. Otherwise,
3190
+ <var> response</var> is either the <a for=internal>internal response</a> of an
3191
+ <a>opaque filtered response</a> or a <a for=/>response</a> which will be the
3192
+ <a for=internal>internal response</a> of an
3193
+ <a>opaque filtered response</a> . [[HTML]]
3194
+
3195
+ <p> To perform a <dfn>cross-origin resource policy internal check</dfn> , given an
3196
+ <a for=url>origin</a> <var> origin</var> , an <a for=/>embedder policy value</a>
3197
+ <var> embedderPolicyValue</var> , a <a for=/>response</a> <var> response</var> , and a boolean
3198
+ <var> forNavigation</var> , run these steps:
3199
+
3200
+ <ol>
3201
+ <li><p> If <var> forNavigation</var> is true and <var> embedderPolicyValue</var> is
3202
+ "<code> <a for="embedder policy value">unsafe-none</a> </code> ", then return <b> allowed</b> .
3167
3203
3168
3204
<li>
3169
3205
<p> Let <var> policy</var> be the result of <a for="header list">getting</a>
3170
3206
`<a http-header><code>Cross-Origin-Resource-Policy</code></a> ` from <var> response</var> 's
3171
3207
<a for=response>header list</a> .
3172
3208
3173
3209
<p class=note> This means that `<code> Cross-Origin-Resource-Policy: same-site, same-origin</code> `
3174
- ends up as <b> allowed</b> below as it will never match anything. Two or more
3175
- `<a http-header><code>Cross-Origin-Resource-Policy</code></a> ` headers will have the same effect.
3210
+ ends up as <b> allowed</b> below as it will never match anything, as long as
3211
+ <var> embedderPolicyValue</var> is "<code> <a for="embedder policy value">unsafe-none</a> </code> ".
3212
+ Two or more `<a http-header><code>Cross-Origin-Resource-Policy</code></a> ` headers will have the
3213
+ same effect.
3214
+
3215
+ <li><p> If <var> policy</var> is neither `<code> same-origin</code> `, `<code> same-site</code> `, nor
3216
+ `<code> cross-origin</code> `, then set <var> policy</var> to null.
3176
3217
3177
- <li><p> If <var> policy</var> is `<code> same-origin</code> `, then return <b> blocked</b> .
3218
+ <li><p> If <var> policy</var> is null and <var> embedderPolicyValue</var> is
3219
+ "<code> <a for="embedder policy value">require-corp</a> </code> ", then set <var> policy</var> to
3220
+ `<code> same-origin</code> `.
3178
3221
3179
3222
<li>
3180
- <p> If the following are true
3223
+ <p> Switch on <var> policy </var> :
3181
3224
3182
- <ul class=brief>
3183
- <li><var> request</var> 's <a for=request>origin</a> is <a>schemelessly same site</a> with
3184
- <var> request</var> 's <a for=request>current URL</a>' s <a for=url>origin</a>
3185
- <li><var> request</var> 's <a for=request>origin</a>' s <a for=url>scheme</a> is
3186
- "<code> https</code> " or <var> response</var> 's <a for=response>HTTPS state</a> is
3187
- "<code> none</code> "
3188
- </ul>
3225
+ <dl class=switch>
3226
+ <dt> null
3227
+ <dt> `<code> cross-origin</code> `
3228
+ <dd><p> Return <b> allowed</b> .
3189
3229
3190
- <p> then return <b> allowed</b> .
3230
+ <dt> `<code> same-origin</code> `
3231
+ <dd>
3232
+ <p> If <var> origin</var> is <a>same origin</a> with <var> response</var> 's <a for=response>URL</a>' s
3233
+ <a for=url>origin</a> , then return <b> allowed</b> .
3191
3234
3192
- <p class=note> This prevents HTTPS responses with
3193
- `<code> Cross-Origin-Resource-Policy: same-site</code> ` from being accessed without secure
3194
- transport.
3235
+ <p> Otherwise, return <b> blocked</b> .
3195
3236
3196
- <li><p> If <var> policy</var> is `<code> same-site</code> `, then return <b> blocked</b> .
3237
+ <dt> `<code> same-site</code> `
3238
+ <dd>
3239
+ <p> If the following are true
3197
3240
3198
- <li><p> Return <b> allowed</b> .
3241
+ <ul class=brief>
3242
+ <li><p><var> origin</var> is <a>schemelessly same site</a> with <var> response</var> 's
3243
+ <a for=response>URL</a> 's <a for=url>origin</a>
3244
+
3245
+ <li><p><var> origin</var> 's <a for=url>scheme</a> is "<code> https</code> " or
3246
+ <var> response</var> 's <a for=response>HTTPS state</a> is "<code> none</code> "
3247
+ </ul>
3248
+
3249
+ <p> then return <b> allowed</b> .
3250
+
3251
+ <p> Otherwise, return <b> blocked</b> .
3252
+
3253
+ <p class=note> `<code> Cross-Origin-Resource-Policy: same-site</code> ` does not consider a
3254
+ response delivered via a secure transport to match a non-secure requesting origin,
3255
+ even if their hosts are otherwise same site. Securely-transported responses will only
3256
+ match a securely-transported initiator.
3257
+ </dl>
3258
+ </ol>
3259
+
3260
+ <p> To <dfn>queue a cross-origin embedder policy CORP violation report</dfn> , given a
3261
+ <a for=/>response</a> <var> response</var> , an <a for=/>environment settings object</a>
3262
+ <var> settingsObject</var> , and a boolean <var> reportOnly</var> , run these steps:
3263
+
3264
+ <ol>
3265
+ <li><p> Let <var> endpoint</var> be <var> settingsObject</var> 's
3266
+ <a for="environment settings object">embedder policy</a> 's
3267
+ <a for="embedder policy">report only reporting endpoint</a> if <var> reportOnly</var> is true and
3268
+ <var> settingsObject</var> 's <a for="environment settings object">embedder policy</a>' s
3269
+ <a for="embedder policy">reporting endpoint</a> otherwise.
3270
+
3271
+ <li><p> Let <var> serialized url</var> be the result of
3272
+ <a lt="serialize a response URL for reporting">serializing a response URL for reporting</a> with
3273
+ <var> response</var> .
3274
+
3275
+ <li>
3276
+ <p> Let <var> body</var> be a new object containing the following properties:
3277
+
3278
+ <table>
3279
+ <thead>
3280
+ <th> key
3281
+ <th> value
3282
+ </thead>
3283
+ <tbody>
3284
+ <tr>
3285
+ <td> "<code> type</code> "
3286
+ <td> "<code> corp</code> "
3287
+ </tr>
3288
+ <tr>
3289
+ <td> "<code> blocked-url</code> "
3290
+ <td><var> serialized url</var>
3291
+ </tr>
3292
+ </tbody>
3293
+ </table>
3294
+
3295
+ <li><p> <a for="reporting">Queue</a> <var> body</var> as the <a>"<code>coep</code>" report type</a> for
3296
+ <var> endpoint</var> on <var> settingsObject</var> . [[!REPORTING]]
3199
3297
</ol>
3200
3298
3201
3299
@@ -3589,9 +3687,8 @@ optionally with a <i>recursive flag</i>, run these steps:
3589
3687
<p> If <var> internalResponse</var> 's <a for=response>URL list</a> <a for=list>is empty</a> , then
3590
3688
set it to a <a for=list>clone</a> of <var> request</var> 's <a for=request>URL list</a> .
3591
3689
3592
- <p class=note> A <a for=/>response</a> 's <a for=response>URL list</a> will typically be empty at
3593
- this point, unless it came from a service worker, in which case it will only be empty if it was
3594
- created through <a lt="Response()" constructor><code>new Response()</code></a> .
3690
+ <p class=note> A <a for=/>response</a> 's <a for=response>URL list</a> can be empty (for example,
3691
+ when the response represents an <code> about</code> URL).
3595
3692
<!-- If you are ever tempted to move this around, carefully consider responses from about URLs,
3596
3693
blob URLs, service workers, HTTP cache, HTTP network, etc. -->
3597
3694
@@ -3961,6 +4058,18 @@ optional <i>CORS-preflight flag</i>, run these steps:
3961
4058
then set <var> request</var> 's <a for=request>timing allow failed flag</a> .
3962
4059
</ol>
3963
4060
4061
+ <li>
4062
+ <p> If either <var> request</var> 's <a for=request>response tainting</a> or <var>response</var>' s
4063
+ <a for=response>type</a> is "<code> opaque</code> ", and the
4064
+ <a>cross-origin resource policy check</a> with <var> request</var> 's <a for=request>origin</a> ,
4065
+ <var> request</var> 's <a for=request>client</a> , and <var> actualResponse</var> returns
4066
+ <b> blocked</b> , then return a <a>network error</a> .
4067
+
4068
+ <p class=note> The <a>cross-origin resource policy check</a> runs for responses coming from the
4069
+ network and responses coming from the service worker. This is different from the
4070
+ <a>CORS check</a> , as <var> request</var> 's <a for=request>client</a> and the service worker can
4071
+ have different embedder policies.
4072
+
3964
4073
<li>
3965
4074
<p> If <var> actualResponse</var> 's <a for=response>status</a> is a <a>redirect status</a> , then:
3966
4075
@@ -4513,13 +4622,12 @@ Range Requests</cite>. [[HTTP-RANGE]] However, this is not widely supported by b
4513
4622
</ol>
4514
4623
</ol>
4515
4624
4625
+ <li><p> Set <var> response</var> 's <a for=response>URL list</a> to a <a for=list>clone</a> of
4626
+ <var> httpRequest</var> 's <a for=request>URL list</a> .
4627
+
4516
4628
<li><p> If <var> httpRequest</var> 's <a for=request>header list</a> <a for="header list">contains</a>
4517
4629
`<code> Range</code> `, then set <var> response</var> 's <a for=response>range-requested flag</a> .
4518
4630
4519
- <li><p> If <var> httpRequest</var> 's <a for=request>response tainting</a> is not "<code> cors</code> "
4520
- and the <a>cross-origin resource policy check</a> with <var> request</var> and <var> response</var>
4521
- returns <b> blocked</b> , then return a <a>network error</a> .
4522
-
4523
4631
<li>
4524
4632
<p> If <var> response</var> 's <a for=response>status</a> is <code> 401</code> ,
4525
4633
<var> httpRequest</var> 's <a for=request>response tainting</a> is not "<code> cors</code> ", the
0 commit comments