@@ -392,7 +392,12 @@ spec:SRI; urlPrefix: https://w3c.github.io/webappsec-subresource-integrity
392
392
metadata which is listed in the current policy. Details in
393
393
[[#external-hash]] .
394
394
395
- 11. Reports generated for inline violations will contain a <a for="violation">sample</a>
395
+ 11. Hash-based source expressions may now match scripts based on their URL hashes.
396
+
397
+ 12. Hash-based source expressions may now allow `eval()` execution based on the hash of
398
+ the content of the eval.
399
+
400
+ 13. Reports generated for inline violations will contain a <a for="violation">sample</a>
396
401
attribute if the relevant directive contains the <a grammar>`'report-sample'`</a>
397
402
expression.
398
403
</section>
@@ -692,7 +697,7 @@ spec:SRI; urlPrefix: https://w3c.github.io/webappsec-subresource-integrity
692
697
693
698
; Keywords:
694
699
<dfn>keyword-source</dfn> = "<dfn>'self'</dfn> " / "<dfn>'unsafe-inline'</dfn> " / "<dfn>'unsafe-eval'</dfn> "
695
- / "<dfn>'strict-dynamic'</dfn> " / "<dfn>'unsafe-hashes'</dfn> "
700
+ / "<dfn>'strict-dynamic'</dfn> " / "<dfn>'strict-dynamic-url'</dfn> " / " <dfn>' unsafe-hashes'</dfn> "
696
701
/ "<dfn>'report-sample'</dfn> " / "<dfn>'unsafe-allow-redirects'</dfn> "
697
702
/ "<dfn>'wasm-unsafe-eval'</dfn> " / "<dfn>'trusted-types-eval'</dfn> "
698
703
/ "<dfn>'report-sha256'</dfn> " / "<dfn>'report-sha384'</dfn> "
@@ -3796,12 +3801,16 @@ Content-Type: application/reports+json
3796
3801
3797
3802
5. If |directive|'s <a for="directive">value</a> does not contain a
3798
3803
<a>source expression</a> that is a match for the
3799
- "<a grammar>`' url-hash-source' `</a> " grammar:
3804
+ "<a grammar>`url-hash-source`</a> " grammar:
3800
3805
3801
3806
1. If the result of executing [[#match-request-to-source-list]] on
3802
3807
|request|, |directive|'s <a for="directive">value</a> , and
3803
3808
|policy|, is "`Does Not Match`", return "`Blocked`".
3804
3809
3810
+ Note: "<a grammar>`'strict-dynamic-url'`</a> " doesn't ignore <a grammar>`host-source`</a>
3811
+ and <a grammar>`scheme-source`</a> expressions, unlike "<a grammar>`'strict-dynamic'`</a> "
3812
+ and "<a grammar>`url-hash-source`</a> ".
3813
+
3805
3814
2. Return "`Allowed`".
3806
3815
3807
3816
<h5 algorithm id="script-post-request">
@@ -3834,7 +3843,8 @@ Content-Type: application/reports+json
3834
3843
3835
3844
1. If |directive|'s <a for="directive">value</a> contains a <a>source
3836
3845
expression</a> that is an <a>ASCII case-insensitive</a> match for
3837
- the "<a grammar>`'strict-dynamic'`</a> " <a grammar>keyword-source</a> :
3846
+ the "<a grammar>`'strict-dynamic'`</a> " or
3847
+ "<a grammar>`'strict-dynamic-url'`</a> " <a grammar>keyword-source</a> s:
3838
3848
3839
3849
1. If the |request|'s <a for="request">parser metadata</a> is
3840
3850
<a>"parser-inserted"</a> , return "`Blocked`".
@@ -4340,10 +4350,12 @@ Content-Type: application/reports+json
4340
4350
4341
4351
2. If |type| is "`script`", "`script attribute`" or "`navigation`"
4342
4352
and |expression| matches the <a grammar>keyword-source</a>
4343
- "<a grammar>`'strict-dynamic'`</a> ", return "`Does Not Allow`".
4353
+ "<a grammar>`'strict-dynamic'`</a> " or
4354
+ "<a grammar>`'strict-dynamic-url'`</a> ", return "`Does Not Allow`".
4344
4355
4345
- Note: `'strict-dynamic' ` only applies to scripts, not other resource
4346
- types. Usage is explained in more detail in [[#strict-dynamic-usage]] .
4356
+ Note: `'strict-dynamic' ` and `'strict-dynamic-url' ` only apply to
4357
+ scripts, not other resource types. Usage is explained in more detail
4358
+ in [[#strict-dynamic-usage]] .
4347
4359
4348
4360
3. If |expression| is an <a>ASCII case-insensitive</a> match for the
4349
4361
<a grammar>`keyword-source`</a> "<a grammar>`'unsafe-inline'`</a> ",
@@ -4373,13 +4385,17 @@ Content-Type: application/reports+json
4373
4385
<a>Source lists</a> that do not
4374
4386
<a for="source list">allow all inline behavior</a> when |type| is
4375
4387
'`script`' or '`script attribute`' due to the presence of
4376
- '`strict-dynamic`' , but <a for="source list">allow all inline behavior</a>
4388
+ '`strict-dynamic`' or '`strict-dynamic-url`' , but
4389
+ <a for="source list">allow all inline behavior</a>
4377
4390
otherwise:
4378
4391
4379
4392
<pre>
4380
4393
'unsafe-inline' 'strict-dynamic'
4394
+ 'unsafe-inline' 'strict-dynamic-url'
4395
+
4381
4396
http://example.com 'strict-dynamic' 'unsafe-inline'
4382
4397
</pre>
4398
+
4383
4399
</div>
4384
4400
4385
4401
<h5 id="match-element-to-source-list" algorithm>
@@ -5072,6 +5088,60 @@ Content-Type: application/reports+json
5072
5088
untrusted data. This includes applications or frameworks that tend to determine
5073
5089
script locations at runtime.
5074
5090
5091
+ Similarly, the "<a grammar>`'strict-dynamic-url'`</a> " source expression allows
5092
+ you to deploy a policy based on "<a grammar>`url-hash-source`</a> "s in a
5093
+ backwards compatible way.
5094
+
5095
+ If present in a <a>`script-src`</a> or <a>`default-src`</a> directive,
5096
+ "<a grammar>`'strict-dynamic-url'`</a> " has two main effects:
5097
+
5098
+ 1. "<a grammar>`'unsafe-inline'`</a> " <a grammar>keyword-source</a> will be
5099
+ ignored when loading script.
5100
+
5101
+ 2. Script requests which are triggered by non-<a>"parser-inserted"</a>
5102
+ <{script}> elements are allowed.
5103
+
5104
+ "<a grammar>`'strict-dynamic-url'`</a> " doesn't ignore
5105
+ <a grammar>host-source</a> , <a grammar>scheme-source</a> and
5106
+ <a grammar>`'self'`</a> . However, <a grammar>`url-hash-source`</a> s ignore
5107
+ these expressions.
5108
+
5109
+ This allows you to deploy <a grammar>`url-hash-source`</a> s in a
5110
+ backwards compatible way, without requiring user-agent sniffing.
5111
+
5112
+ <div class="example">
5113
+ Suppose MegaCorp, Inc. presently deploys the following lax policy:
5114
+
5115
+ <pre>
5116
+ <a http-header>Content-Security-Policy</a> : <a>script-src</a> https: 'unsafe-inline'
5117
+ </pre>
5118
+
5119
+ And serves the following HTML with that policy active:
5120
+
5121
+ <pre highlight="html">
5122
+ ...
5123
+ <script src="https://example.com/script.js" ></script>
5124
+ ...
5125
+ </pre>
5126
+
5127
+ MegaCorp, Inc. now wants to deploy a more strict policy using <a grammar>`url-hash-source`</a> s:
5128
+
5129
+ <pre>
5130
+ <a http-header>Content-Security-Policy</a> : <a>script-src</a> https: 'unsafe-inline' 'strict-dynamic-url' 'url-hash-EAaArVRs5qV39C9S3zO0z9ynVoWeZkuNfeMpsVDQnOk='
5131
+ </pre>
5132
+
5133
+ User agents that understand <a grammar>`url-hash-source`</a> s will allow
5134
+ the script and any non-parser inserted scripts it loads.
5135
+
5136
+ User agents that don't understand <a grammar>`url-hash-source`</a> s will
5137
+ see the policy as "`https: 'unsafe-inline' `". This lax policy will also
5138
+ allow the script to be loaded.
5139
+
5140
+ Note: This policy can't use "<a grammar>`'strict-dynamic'`</a> " because
5141
+ older user agents that need to receive a lax fallback policy will ignore the
5142
+ `https:` source expression due to "<a grammar>`'strict-dynamic'`</a> ".
5143
+ </div>
5144
+
5075
5145
<section>
5076
5146
<h3 id="unsafe-hashes-usage">
5077
5147
Usage of "`'unsafe-hashes'`"
0 commit comments