From 931ecf4395893c19e99d5a68f6329652e30d987b Mon Sep 17 00:00:00 2001 From: Anne van Kesteren Date: Thu, 20 Feb 2020 10:51:02 +0100 Subject: [PATCH] Prevent [[CryptographicNonce]] from being emptied Also clarify some prose around the nonce content attribute, including that it does in fact update the slot upon removal. Tests: https://github.com/web-platform-tests/wpt/pull/21853. Fixes #5288. --- source | 49 +++++++++++++++++++++++++++++++++++++------------ 1 file changed, 37 insertions(+), 12 deletions(-) diff --git a/source b/source index f8035642ae6..d030c6e0e8d 100644 --- a/source +++ b/source @@ -2824,6 +2824,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
  • legacy platform object
  • primary interface
  • interface object
  • +
  • include
  • interface prototype object
  • [[Realm]] field of a platform object
  • callback context
  • @@ -7118,11 +7119,11 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute

    Elements that have a nonce content attribute ensure that the crytographic nonce is only exposed to script (and not to side-channels like CSS attribute - selectors) by extracting the value from the content attribute, moving it into an internal slot + selectors) by taking the value from the content attribute, moving it into an internal slot named [[CryptographicNonce]], and exposing it to script via the - HTMLOrSVGElement interface mixin. Unless otherwise specified, the slot's value - is the empty string.

    + data-dfn-type="attribute">[[CryptographicNonce]], exposing it to script via the + HTMLOrSVGElement interface mixin, and setting the content attribute to the empty + string. Unless otherwise specified, the slot's value is the empty string.

    element . nonce
    @@ -7147,12 +7148,26 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute issue #2369, where this behavior was introduced.

    -

    Whenever an element including HTMLOrSVGElement has its nonce attribute is set or changed, set this element's - [[CryptographicNonce]] to the given value.

    +

    The following attribute change + steps are used for the nonce content attribute: + +

      +
    1. If element does not include HTMLOrSVGElement, then + return.

    2. + +
    3. If localName is not nonce or + namespace is not null, then return.

    4. -

      Whenever an element including HTMLOrSVGElement becomes browsing-context - connected, the user agent must execute the following steps on the element:

      +
    5. If value is null, then set element's + [[CryptographicNonce]] to the empty string.

    6. + +
    7. Otherwise, set element's [[CryptographicNonce]] to + value.

    8. +
    + +

    Whenever an element including HTMLOrSVGElement + becomes browsing-context connected, the user agent must execute the following steps + on the element:

    1. Let CSP list be element's Set an attribute value for element using "nonce" and the empty string.

    2. + +
    3. Set element's [[CryptographicNonce]] to + nonce.

    + +

    If element's [[CryptographicNonce]] were not restored it + would be the empty string at this point.

    @@ -7178,9 +7202,10 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute set during Document creation and initialization.

    -

    The cloning steps for elements that include - HTMLOrSVGElement must set the [[CryptographicNonce]] slot on the copy - to the value of the slot on the element being cloned.

    +

    The cloning steps for elements that + include HTMLOrSVGElement must set the + [[CryptographicNonce]] slot on the copy to the value of the slot on the element being + cloned.

    Lazy loading attributes