-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Add HTML global attribute nonce #8764
Conversation
Marking as ready, I'm not sure what the story for initial |
This was enabled in Chromium 36. Longer version: I failed to determine when support for the content attribute was shipped from source code archeology, and the tests in WPT didn't run going back to very old Chrome, so I wrote this test: <meta http-equiv="Content-Security-Policy" content="script-src 'self' 'nonce-abc'">
<pre>nonce test passes if one PASS and no FAIL logged:
</pre>
<script nonce=abc>
function log(msg) {
document.querySelector('pre').textContent += '\n' + msg;
}
log('PASS script with correct nonce ran');
</script>
<script nonce=xyz>log('FAIL script with wrong nonce ran');</script> Using that I bisected support to introduced in Chrome 36. In Chrome 35 there's a console message saying that the nonce-abc bit isn't recognized, so I'm pretty confident. Chrome 36 was shipped on 2014-07-16 so the timing matched Intent to Ship: CSP 1.1 [script/style]-[hash/nonce], but I couldn't pinpoint the commit. |
As for Safari, it was implemented in WebKit in https://trac.webkit.org/changeset/197944/webkit, behavior and reflected IDL attributes at the same time. (The content attribute was already in the code, probably left over after https://trac.webkit.org/changeset/121883/webkit.) That was WebKit trunk 602.1.22 which would be Safari 10, matching api.HTMLElement.nonce. Testing Safari 9.1 and 10.1 on BrowserStack is consistent with this, it's not supported in Safari 9.1 but is in 10.1. |
One more thing came up when looking at WebKit. WebKit also has |
I see whatwg/html#1820 added |
aha — grrr, I really wish we didn’t split stuff across specs like that
yeah I can — I’ll post a comment after trying it |
OK, after walking through the following:
…I find that I can’t actually locate a call site where that Does nonce match source list? algorithm gets called for To put it in other terms, it’s clear that steps 1 to 4 above — the HTML spec and Fetch spec steps — cause the right “cryptographic nonce metadata” from the (P.S. I’ve still not actually tested browsers for |
Hmm, sounds like there might be some dead code in the spec here. The code I found in WebKit also strikes me as unlikely to ever cause a request to be blocked, so maybe this feature was only ever half finished? Testing the behavior would be great too, that's what I couldn't figure out how to do. |
I couldn't find much in WPT on I believe the |
I've read this through this a couple of times and I admit I'm still a bit confused. What questions remain to be answered to make this ready to be merged? |
I think we were figuring out if we need additional notes but actually I think we should merge this as is and follow up if needed. |
I agree. I’ve been planning to test but I’ve not managed to make time to do that yet — but I don’t think that should block this from being merged. I’ve opened #8919 to track that task. |
Forced pushed so CI runs and allows me to merge. |
…icture * upstream/master: (1123 commits) Remove Chromium 89 from String.at / Array.at / TypedArray.at (mdn#8869) Add worker_support info for CacheStorage (mdn#8783) Remove several needless "Enabled by default" notes (mdn#8899) Add HTML global attribute nonce (mdn#8764) api.Navigator.vibrate - Firefox for Android doesn't vibrate (mdn#7172) Mark MediaSource's onsourceclose as not supported in Firefox (mdn#8881) Update Florian's ownership (mdn#8893) Mention fix for Chrome's broken PDF loading (mdn#8867) Fill out Chrome data for html.elements.source.{sizes,srcset} (mdn#8889) Weekly data release for 2021-01-28 Add text-decoration-thickness for Opera 73+ (mdn#8872) Update :is and :where pseudo-classes for Chrome (mdn#7375) Add note re Safari <9 partial srcset/sizes support (mdn#7353) Update data for when href (not xlink:href) can be used in SVG (mdn#6603) Add top-level await (mdn#8807) TouchList: Add Safari Desktop and Safari iOS versions (mdn#8848) Update Firefox versions to account for Firefox 85 release (mdn#8864) Fix page_action.show_matches support for Android (mdn#8844) Update Safari support for devicechange_event (mdn#8863) Add HTTPS-only to privacy.network (mdn#8830) ...
Helping out on #7303 by adding the global attribute
nonce
.mdn/content PR: mdn/content#1318