-
Notifications
You must be signed in to change notification settings - Fork 306
Hide nonce
content attribute values from non-script sources.
#436
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Conversation
This patch extracts the `nonce` content attribute out to a generic definition in DOM, rather than an HTMLScriptElement-specific definition in HTML, and defines new behavior for insertion and cloning with the intent of reducing the risk of side-channel leakage of the nonce's value. The nonce value is extracted from the content attribute when the element is inserted into the DOM, and put into an internal property. The content attribute's value is set to the empty string. From then on, the property's value and the content attribute's value are disconnected; alterations to one have no effect on the other, and vice-versa. The nonce's value is available to script via the `nonce` IDL attribute, and so can be propagated just as today. Addresses whatwg/html#2369.
(If so, I'll update the HTML patch to rely on this one. If not, we should chat a bit. :) ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall this seems fine. Small meta-concern about when to use HTMLElement and SVGElement and when to use Element, but if everyone is happy that is good enough and this does follow the precedent we've established for a couple other attributes.
dom.bs
Outdated
|
||
<ol> | ||
<li> | ||
<p>If <var>inserted</var> is [=connected=], and it has a content attribute (<var>attr</var>) whose |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this actually name the attribute in question?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should indeed. Fixed in 3e4bffb.
I'd be fine moving this back to HTML (and finding someone to talk to about SVG) if y'all would prefer. It feels a little strange putting this in DOM, honestly, so that wouldn't make me terribly sad. |
dom.bs
Outdated
<p>If <var>inserted</var> is [=connected=], and it has a content attribute (<var>attr</var>) whose | ||
value is not the empty string, then:</p> | ||
<p>If <var>inserted</var> is [=connected=], and it has a content attribute (<var>attr</var>) named | ||
[=Attr/local name=] "<code>nonce</code>" whose [=Attr/value=] is not the empty string, then:</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You want to use https://dom.spec.whatwg.org/#concept-named-attribute since this is still not precise enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trying again in 78db5fb. :)
This patch extracts the
nonce
content attribute out to a genericdefinition in DOM, rather than an HTMLScriptElement-specific definition
in HTML, and defines new behavior for insertion and cloning with the
intent of reducing the risk of side-channel leakage of the nonce's
value.
The nonce value is extracted from the content attribute when the element
is inserted into the DOM, and put into an internal property. The
content attribute's value is set to the empty string.
From then on, the property's value and the content attribute's value are
disconnected; alterations to one have no effect on the other, and
vice-versa.
The nonce's value is available to script via the
nonce
IDL attribute,and so can be propagated just as today.
Addresses whatwg/html#2369.
Preview | Diff