diff --git a/index.bs b/index.bs index aca382d6f7..636595db68 100644 --- a/index.bs +++ b/index.bs @@ -392,7 +392,12 @@ spec:SRI; urlPrefix: https://w3c.github.io/webappsec-subresource-integrity metadata which is listed in the current policy. Details in [[#external-hash]]. - 11. Reports generated for inline violations will contain a sample + 11. Hash-based source expressions may now match scripts based on their URL hashes. + + 12. Hash-based source expressions may now allow `eval()` execution based on the hash of + the content of the eval. + + 13. Reports generated for inline violations will contain a sample attribute if the relevant directive contains the `'report-sample'` expression. @@ -692,7 +697,7 @@ spec:SRI; urlPrefix: https://w3c.github.io/webappsec-subresource-integrity ; Keywords: keyword-source = "'self'" / "'unsafe-inline'" / "'unsafe-eval'" - / "'strict-dynamic'" / "'unsafe-hashes'" + / "'strict-dynamic'" / "'strict-dynamic-url'" / "'unsafe-hashes'" / "'report-sample'" / "'unsafe-allow-redirects'" / "'wasm-unsafe-eval'" / "'trusted-types-eval'" / "'report-sha256'" / "'report-sha384'" @@ -705,6 +710,8 @@ spec:SRI; urlPrefix: https://w3c.github.io/webappsec-subresource-integrity base64-value = 1*( ALPHA / DIGIT / "+" / "/" / "-" / "_" )*2( "=" ) ; Digests: 'sha256-[digest goes here]' + url-hash-source = "'url-" hash-algorithm "-" base64-value "'" + eval-hash-source = "'eval-" hash-algorithm "-" base64-value "'" hash-source = "'" hash-algorithm "-" base64-value "'" hash-algorithm = "sha256" / "sha384" / "sha512" @@ -1546,8 +1553,13 @@ spec:SRI; urlPrefix: https://w3c.github.io/webappsec-subresource-integrity [=ASCII case-insensitive=] match for the string "`'trusted-types-eval'`", then skip the following steps. - 1. If |source-list| contains a [=source expression=] which is an [=ASCII case-insensitive=] match for the - string "`'unsafe-eval'`", then skip the following steps. + 1. If the result of executing [[#match-eval-hash-to-source-list]] on |source-list| and |sourceString| + is "`Matches`", then skip the following steps. + + 1. If |source-list| does not contain a [=source expression=] that is a match for the + "`'eval-hash-source'`" grammar and |source-list| contains a [=source expression=] which is an + [=ASCII case-insensitive=] match for the string "`'unsafe-eval'`", then skip the + following steps. 1. Let |violation| be the result of executing [[#create-violation-for-global]] on |global|, |policy|, and "`script-src`". @@ -1813,13 +1825,23 @@ Content-Type: application/reports+json 1. If |url|'s scheme is not an HTTP(S) scheme, then return |url|'s scheme. + 2. Let |result| be the result of executing [[#strip-https-url]] on |url|. + + 3. Return the result of executing the URL serializer on |result|. + +
'unsafe-inline' 'strict-dynamic' + 'unsafe-inline' 'strict-dynamic-url' + http://example.com 'strict-dynamic' 'unsafe-inline'+
+ Content-Security-Policy: script-src https: 'unsafe-inline' ++ + And serves the following HTML with that policy active: + +
+ ... + <script src="https://example.com/script.js" ></script> + ... ++ + MegaCorp, Inc. now wants to deploy a more strict policy using `url-hash-source`s: + +
+ Content-Security-Policy: script-src https: 'unsafe-inline' 'strict-dynamic-url' 'url-hash-EAaArVRs5qV39C9S3zO0z9ynVoWeZkuNfeMpsVDQnOk=' ++ + User agents that understand `url-hash-source`s will allow + the script and any non-parser inserted scripts it loads. + + User agents that don't understand `url-hash-source`s will + see the policy as "`https: 'unsafe-inline'`". This lax policy will also + allow the script to be loaded. + + Note: This policy can't use "`'strict-dynamic'`" because + older user agents that need to receive a lax fallback policy will ignore the + `https:` source expression due to "`'strict-dynamic'`". +