@@ -157,9 +157,9 @@ <h2 id="introduction">Introduction</h2>
157
157
and the < code > fetch()</ code > API with an < code > integrity</ code > attribute that contains a cryptographic hash
158
158
of the representation of the resource the author expects to load. For instance,
159
159
an author may wish to load some framework from a shared server rather than hosting it
160
- on their own origin. Specifying that the < em > expected</ em > SHA-256 hash of
160
+ on their own origin. Specifying that the < em > expected</ em > SHA-384 hash of
161
161
< code > https://example.com/example-framework.js</ code >
162
- is < code > C6CB9UYIS9UJeqinPHWTHVqh/E1uhG5Twh+Y5qFQmYg= </ code > means
162
+ is < code > Li9vy3DqF8tnTXuiaAJuML3ky+er10rcgNR/VqsVpcw+ThHmYcwiB1pbOxEbzJr7 </ code > means
163
163
that the user agent can verify that the data it loads from that URL matches
164
164
that expected hash before executing the JavaScript it contains. This
165
165
integrity verification significantly reduces the risk that an attacker can
@@ -169,11 +169,11 @@ <h2 id="introduction">Introduction</h2>
169
169
< code > script</ code > element, like so:</ p >
170
170
171
171
< pre > < code > <script src="https://example.com/example-framework.js"
172
- integrity="sha256-C6CB9UYIS9UJeqinPHWTHVqh/E1uhG5Twh+Y5qFQmYg= "
172
+ integrity="sha384-Li9vy3DqF8tnTXuiaAJuML3ky+er10rcgNR/VqsVpcw+ThHmYcwiB1pbOxEbzJr7 "
173
173
crossorigin="anonymous"></script>
174
174
</ code > </ pre >
175
175
176
- < p > Scripts, of course, are not the only response type which would benefit
176
+ < p class =" example " > Scripts, of course, are not the only response type which would benefit
177
177
from integrity validation. The scheme specified here also applies to < code > link</ code >
178
178
and future versions of the specification are likely to expand this coverage.</ p >
179
179
@@ -214,7 +214,7 @@ <h4 id="resource-integrity">Resource Integrity</h4>
214
214
< a href ="#dfn-integrity-metadata "> integrity metadata</ a > is added to the < code > link</ code > element included on the page:</ p >
215
215
216
216
< pre class ="example "> < code > <link rel="stylesheet" href="https://site53.example.net/style.css"
217
- integrity="sha256-vjnUh7+rXHH2lg/5vDY8032ftNVCIEC21vL6szrVw9M= "
217
+ integrity="sha384-+/M6kredJcxdsqkczBUjMLvqyHb1K/JThDXWsBVxMEeZHEaMKEOEct339VItX1zB "
218
218
crossorigin="anonymous">
219
219
</ code > </ pre >
220
220
</ li >
@@ -225,7 +225,7 @@ <h4 id="resource-integrity">Resource Integrity</h4>
225
225
the script, and adds it to the < code > script</ code > element:</ p >
226
226
227
227
< pre class ="example "> < code > <script src="https://analytics-r-us.example.com/v1.0/include.js"
228
- integrity="sha256-Rj/9XDU7F6pNSX8yBddiCIIS+XKDTtdq0//No0MH0AE= "
228
+ integrity="sha384-MBO5IDfYaE6c6Aao94oZrIOiC6CGiSN2n4QUbHNPhzk5Xhm0djZLQqTpL0HzTUxk "
229
229
crossorigin="anonymous"></script>
230
230
</ code > </ pre >
231
231
</ li >
@@ -271,7 +271,7 @@ <h3 id="key-concepts-and-terminology">Key Concepts and Terminology</h3>
271
271
is an origin whose scheme component is < code > HTTPS</ code > .</ p >
272
272
273
273
< p > The < dfn > message body</ dfn > and the < dfn > transfer encoding</ dfn > of a resource
274
- are defined by < a href ="http://tools.ietf.org/html/rfc7230#section-3 "> RFC7230, section 3</ a > . [[!RFC7230]] </ p >
274
+ are defined by < a href ="http://tools.ietf.org/html/rfc7230#section-3 "> RFC7230, section 3</ a > . [[!RFC7230]]</ p >
275
275
276
276
< p > The < dfn > representation data</ dfn > and < dfn > content encoding</ dfn > of a resource
277
277
are defined by < a href ="http://tools.ietf.org/html/rfc7231#section-3 "> RFC7231, section 3</ a > . [[!RFC7231]]</ p >
@@ -331,19 +331,19 @@ <h3 id="integrity-metadata">Integrity metadata</h3>
331
331
in < a href ="http://www.w3.org/TR/CSP11/#source-list-syntax "> section 4.2 of the Content Security Policy Level 2 specification</ a > .</ p >
332
332
333
333
< p > For example, given a script resource containing only the string "alert('Hello, world.');",
334
- an author might choose < a href ="#dfn-sha-2 "> SHA-256 </ a > as a hash function.
335
- < code > qznLcsROx4GACP2dm0UCKCzCG+HiZ1guq6ZZDob/Tng= </ code > is the base64-encoded
334
+ an author might choose [SHA-384 < a href ="#dfn-sha-2 "> sha2 </ a > as a hash function.
335
+ < code > H8BRh8j48O9oYatfu5AZzq6A9RINhZO5H16dQZngK7T62em8MUt1FLm52t+eX6xO </ code > is the base64-encoded
336
336
digest that results. This can be encoded as follows:</ p >
337
337
338
- < pre class ="example "> < code > sha256-qznLcsROx4GACP2dm0UCKCzCG+HiZ1guq6ZZDob/Tng=
338
+ < pre class ="example "> < code > sha384-H8BRh8j48O9oYatfu5AZzq6A9RINhZO5H16dQZngK7T62em8MUt1FLm52t+eX6xO
339
339
</ code > </ pre >
340
340
341
341
< div class ="note ">
342
342
< p > Digests may be generated using any number of utilities. < a href ="http://www.openssl.org/ "> OpenSSL</ a > , for
343
343
example, is quite commonly available. The example in this section is the
344
344
result of the following command line:</ p >
345
345
346
- < pre > < code > echo -n "alert('Hello, world.');" | openssl dgst -sha256 -binary | openssl enc -base64 -A
346
+ < pre > < code > echo -n "alert('Hello, world.');" | openssl dgst -sha384 -binary | openssl enc -base64 -A
347
347
</ code > </ pre >
348
348
349
349
</ div >
@@ -366,14 +366,14 @@ <h4 id="agility">Agility</h4>
366
366
For example, the resource described in the previous section may be described
367
367
by either of the following hash expressions:</ p >
368
368
369
- < pre > < code > sha256-qznLcsROx4GACP2dm0UCKCzCG+HiZ1guq6ZZDob/Tng=
369
+ < pre > < code > sha384-dOTZf16X8p34q2/kYyEFm0jh89uTjikhnzjeLeF0FHsEaYKb1A1cv+Lyv4Hk8vHd
370
370
sha512-Q2bFTOhEALkN8hOms2FKTDLy7eugP2zFZ1T8LCvX42Fp3WoNr3bjZSAHeOsHrbV1Fu9/A0EzCinRE7Af1ofPrw==
371
371
</ code > </ pre >
372
372
373
373
< p > Authors may choose to specify both, for example:</ p >
374
374
375
375
< pre > < code > <script src="hello_world.js"
376
- integrity="sha256-qznLcsROx4GACP2dm0UCKCzCG+HiZ1guq6ZZDob/Tng=
376
+ integrity="sha384-dOTZf16X8p34q2/kYyEFm0jh89uTjikhnzjeLeF0FHsEaYKb1A1cv+Lyv4Hk8vHd
377
377
sha512-Q2bFTOhEALkN8hOms2FKTDLy7eugP2zFZ1T8LCvX42Fp3WoNr3bjZSAHeOsHrbV1Fu9/A0EzCinRE7Af1ofPrw=="
378
378
crossorigin="anonymous"></script>
379
379
</ code > </ pre >
@@ -446,7 +446,7 @@ <h4 id="is-response-eligible-for-integrity-validation">Is <var>response</var> el
446
446
checks if they are same-origin or are the result of explicit access granted to
447
447
the loading origin via CORS. [[!CORS]]</ p >
448
448
449
- < p class ="note "> As noted in < a href ="http://tools.ietf.org/html/rfc6454#section-4 "> RFC6454, section 4</ a > , some user agents use
449
+ < p class ="note "> As noted in < a class =" note " href ="http://tools.ietf.org/html/rfc6454#section-4 "> RFC6454, section 4</ a > , some user agents use
450
450
globally unique identifiers for each file URI. This means that
451
451
resources accessed over a < code > file</ code > scheme URL are unlikely to be
452
452
eligible for integrity checks.</ p >
@@ -563,16 +563,16 @@ <h4 id="does-response-match-metadatalist">Does <var>response</var> match <var>me
563
563
functions. For example, a developer might write a < code > script</ code > element such as:</ p >
564
564
565
565
< pre > < code > <script src="https://example.com/example-framework.js"
566
- integrity="sha256-C6CB9UYIS9UJeqinPHWTHVqh/E1uhG5Twh+Y5qFQmYg=
567
- sha256-qznLcsROx4GACP2dm0UCKCzCG+HiZ1guq6ZZDob/Tng= "
566
+ integrity="sha384-Li9vy3DqF8tnTXuiaAJuML3ky+er10rcgNR/VqsVpcw+ThHmYcwiB1pbOxEbzJr7
567
+ sha384-+/M6kredJcxdsqkczBUjMLvqyHb1K/JThDXWsBVxMEeZHEaMKEOEct339VItX1zB "
568
568
crossorigin="anonymous"></script>
569
569
</ code > </ pre >
570
570
571
571
< p > which would allow the user agent to accept two different content payloads, one
572
- of which matches the first SHA256 hash value and the other matches the second
573
- SHA256 hash value.</ p >
572
+ of which matches the first SHA384 hash value and the other matches the second
573
+ SHA384 hash value.</ p >
574
574
575
- < p class ="note "> User agents may allow users to modify the result of this algorithm via user
575
+ < p class ="example note "> User agents may allow users to modify the result of this algorithm via user
576
576
preferences, bookmarklets, third-party additions to the user agent, and other
577
577
such mechanisms. For example, redirects generated by an extension like
578
578
< a href ="https://www.eff.org/https-everywhere "> HTTPSEverywhere</ a > could load and execute
@@ -754,7 +754,7 @@ <h5 id="elements">Elements</h5>
754
754
< section >
755
755
< h6 id ="the-link-element-for-stylesheets "> The < code > link</ code > element for stylesheets</ h6 >
756
756
757
- < p > Whenever a user agent attempts to < a href ="http://www.w3.org/TR/html5/document-metadata.html#concept-link-obtain "> obtain a resource</ a > pointed to by a
757
+ < p > Whenever a user agent attempts to < a start =" 4 " href ="http://www.w3.org/TR/html5/document-metadata.html#concept-link-obtain "> obtain a resource</ a > pointed to by a
758
758
< code > link</ code > element that has a < code > rel</ code > attribute with the keyword of < code > stylesheet</ code > ,
759
759
modify step 4 to read:</ p >
760
760
@@ -770,7 +770,7 @@ <h6 id="the-link-element-for-stylesheets">The <code>link</code> element for styl
770
770
< section >
771
771
< h6 id ="the-script-element "> The < code > script</ code > element</ h6 >
772
772
773
- < p > Replace step 14.1 of HTML5’s < a href ="http://www.w3.org/TR/html5/scripting-1.html#prepare-a-script "> “prepare a script” algorithm</ a > with:</ p >
773
+ < p > Replace step 14.1 of HTML5’s < a start =" 6 " href ="http://www.w3.org/TR/html5/scripting-1.html#prepare-a-script "> “prepare a script” algorithm</ a > with:</ p >
774
774
775
775
< ol >
776
776
< li > Let < var > src</ var > be the value of the element’s < code > src</ code > attribute and
@@ -834,7 +834,7 @@ <h3 id="hash-collision-attacks">Hash collision attacks</h3>
834
834
< p > Digests are only as strong as the hash function used to generate them. User
835
835
agents SHOULD refuse to support known-weak hashing functions like MD5 or SHA-1,
836
836
and SHOULD restrict supported hashing functions to those known to be
837
- collision-resistant. At the time of writing, SHA-256 is a good baseline.
837
+ collision-resistant. At the time of writing, SHA-384 is a good baseline.
838
838
Moreover, user agents SHOULD re-evaluate their supported hash functions
839
839
on a regular basis, and deprecate support for those functions shown to be
840
840
insecure.</ p >
0 commit comments