Skip to content

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

Closed
wants to merge 3 commits into from
Closed

Hide nonce content attribute values from non-script sources. #436

wants to merge 3 commits into from

Conversation

mikewest
Copy link
Member

@mikewest mikewest commented Apr 10, 2017

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.


Preview | Diff

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.
@mikewest
Copy link
Member Author

mikewest commented Apr 10, 2017

Is this more or less what you were thinking, @annevk / @zcorpan?

@mikewest
Copy link
Member Author

(If so, I'll update the HTML patch to rely on this one. If not, we should chat a bit. :) )

Copy link
Member

@annevk annevk left a 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
Copy link
Member

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?

Copy link
Member Author

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.

@annevk annevk requested a review from domenic April 10, 2017 14:44
@mikewest
Copy link
Member Author

Small meta-concern about when to use HTMLElement and SVGElement and when to use Element.

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>
Copy link
Member

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trying again in 78db5fb. :)

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants