Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Issue 14949017: Implementation of W3C compliant CSP script-src nonce. (Closed)

Created:
7 years, 7 months ago by jww
Modified:
7 years, 7 months ago
CC:
blink-reviews, Nate Chapin, gavinp+loader_chromium.org, mkwst+watchlist_chromium.org
Base URL:
https://chromium.googlesource.com/chromium/blink.git@master
Visibility:
Public.

Description

Implementation of W3C compliant CSP script-src nonce. Removes the old 'script-nonce' implementation. See section 3.2.2 of https://dvcs.w3.org/hg/content-security-policy/raw-file/tip/csp-specification.dev.html BUG=236669 NOTRY=true Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=150541

Patch Set 1 #

Total comments: 32

Patch Set 2 : Fixes from comments and nits from Adam and Mike. #

Total comments: 8

Patch Set 3 : Fixed broken nonce behavior on script redirects. Added test for redirects as well. #

Total comments: 22

Patch Set 4 : Factored script nonce checks to point of resource request creation, plus nits from Adam #

Total comments: 10

Patch Set 5 : Minor fixes based on Adam's comments #

Total comments: 1
Unified diffs Side-by-side diffs Delta from patch set Stats (+189 lines, -234 lines) Patch
M LayoutTests/http/tests/security/contentSecurityPolicy/1.1/scriptnonce-allowed.html View 1 chunk +1 line, -1 line 0 comments Download
A + LayoutTests/http/tests/security/contentSecurityPolicy/1.1/scriptnonce-basic-blocked.html View 1 chunk +1 line, -1 line 0 comments Download
A LayoutTests/http/tests/security/contentSecurityPolicy/1.1/scriptnonce-basic-blocked-expected.txt View 1 chunk +9 lines, -0 lines 0 comments Download
M LayoutTests/http/tests/security/contentSecurityPolicy/1.1/scriptnonce-blocked.html View 1 chunk +15 lines, -28 lines 0 comments Download
M LayoutTests/http/tests/security/contentSecurityPolicy/1.1/scriptnonce-blocked-expected.txt View 1 chunk +24 lines, -6 lines 0 comments Download
M LayoutTests/http/tests/security/contentSecurityPolicy/1.1/scriptnonce-invalidnonce.html View 1 chunk +6 lines, -4 lines 0 comments Download
M LayoutTests/http/tests/security/contentSecurityPolicy/1.1/scriptnonce-invalidnonce-expected.txt View 2 chunks +25 lines, -10 lines 0 comments Download
A LayoutTests/http/tests/security/contentSecurityPolicy/1.1/scriptnonce-redirect.html View 1 2 3 1 chunk +14 lines, -0 lines 0 comments Download
A LayoutTests/http/tests/security/contentSecurityPolicy/1.1/scriptnonce-redirect-expected.txt View 1 2 3 1 chunk +2 lines, -0 lines 0 comments Download
D LayoutTests/http/tests/security/contentSecurityPolicy/1.1/scriptnonce-scriptsrc-blocked.html View 1 chunk +0 lines, -17 lines 0 comments Download
D LayoutTests/http/tests/security/contentSecurityPolicy/1.1/scriptnonce-scriptsrc-blocked-expected.txt View 1 chunk +0 lines, -27 lines 0 comments Download
D LayoutTests/http/tests/security/contentSecurityPolicy/1.1/scriptnonce-separators-allowed.html View 1 chunk +0 lines, -16 lines 0 comments Download
D LayoutTests/http/tests/security/contentSecurityPolicy/1.1/scriptnonce-separators-allowed-expected.txt View 1 chunk +0 lines, -18 lines 0 comments Download
A LayoutTests/http/tests/security/contentSecurityPolicy/resources/alert-pass.js View 1 2 1 chunk +1 line, -0 lines 0 comments Download
M Source/core/dom/ScriptElement.cpp View 1 2 3 4 3 chunks +5 lines, -5 lines 1 comment Download
M Source/core/loader/DocumentLoader.cpp View 1 2 3 1 chunk +1 line, -1 line 0 comments Download
M Source/core/loader/ResourceLoader.cpp View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download
M Source/core/loader/ResourceLoaderOptions.h View 1 2 3 4 5 chunks +11 lines, -2 lines 0 comments Download
M Source/core/loader/cache/CachedResourceLoader.h View 1 2 3 1 chunk +1 line, -1 line 0 comments Download
M Source/core/loader/cache/CachedResourceLoader.cpp View 1 2 3 4 6 chunks +6 lines, -6 lines 0 comments Download
M Source/core/loader/cache/CachedResourceRequest.h View 1 2 3 4 1 chunk +1 line, -0 lines 0 comments Download
M Source/core/page/ContentSecurityPolicy.h View 1 2 3 2 chunks +1 line, -1 line 0 comments Download
M Source/core/page/ContentSecurityPolicy.cpp View 1 2 3 27 chunks +64 lines, -89 lines 0 comments Download

Messages

Total messages: 26 (0 generated)
jww
7 years, 7 months ago (2013-05-14 04:27:38 UTC) #1
abarth-chromium
Great start! Just a few minor comments below. Thanks for the CL. https://codereview.chromium.org/14949017/diff/1/Source/core/loader/cache/CachedResourceLoader.cpp File Source/core/loader/cache/CachedResourceLoader.cpp ...
7 years, 7 months ago (2013-05-14 05:58:16 UTC) #2
Mike West
Just a few bits in addition to Adam's comments. Thanks for working on this! https://codereview.chromium.org/14949017/diff/1/Source/core/dom/ScriptElement.cpp ...
7 years, 7 months ago (2013-05-14 08:07:38 UTC) #3
jww
Response to comments. I'll upload the listed fixes. https://codereview.chromium.org/14949017/diff/1/Source/core/dom/ScriptElement.cpp File Source/core/dom/ScriptElement.cpp (right): https://codereview.chromium.org/14949017/diff/1/Source/core/dom/ScriptElement.cpp#newcode296 Source/core/dom/ScriptElement.cpp:296: if ...
7 years, 7 months ago (2013-05-14 20:49:30 UTC) #4
abarth-chromium
https://codereview.chromium.org/14949017/diff/13001/Source/core/loader/ResourceLoader.cpp File Source/core/loader/ResourceLoader.cpp (right): https://codereview.chromium.org/14949017/diff/13001/Source/core/loader/ResourceLoader.cpp#newcode327 Source/core/loader/ResourceLoader.cpp:327: (!m_documentLoader->cachedResourceLoader()->canRequest(m_resource->type(), request.url(), NULL)) { These two lines should be ...
7 years, 7 months ago (2013-05-14 21:11:08 UTC) #5
jww
Responded to comments from Adam. https://codereview.chromium.org/14949017/diff/13001/Source/core/loader/ResourceLoader.cpp File Source/core/loader/ResourceLoader.cpp (right): https://codereview.chromium.org/14949017/diff/13001/Source/core/loader/ResourceLoader.cpp#newcode327 Source/core/loader/ResourceLoader.cpp:327: (!m_documentLoader->cachedResourceLoader()->canRequest(m_resource->type(), request.url(), NULL)) { ...
7 years, 7 months ago (2013-05-14 22:55:30 UTC) #6
abarth-chromium
Sure. Content-Security-Policy: script-src 'nonce-foo' <script nonce="foo" src="bar.php"> where bar.php does an HTTP redirect to qux.js.
7 years, 7 months ago (2013-05-14 23:03:08 UTC) #7
jww
Test written and confirmed that this is a problem. I think I have an idea ...
7 years, 7 months ago (2013-05-15 00:01:38 UTC) #8
abarth-chromium
We only want to read the nonce off the element once. If we grab the ...
7 years, 7 months ago (2013-05-15 00:07:37 UTC) #9
abarth-chromium
We can also ask japhet for help.
7 years, 7 months ago (2013-05-15 00:08:57 UTC) #10
jww
On 2013/05/15 00:08:57, abarth wrote: > We can also ask japhet for help. Maybe japhet ...
7 years, 7 months ago (2013-05-15 00:39:46 UTC) #11
abarth-chromium
Rather than putting the nonce here, what if we put an enum similar to enum ...
7 years, 7 months ago (2013-05-15 01:06:57 UTC) #12
do-not-use-jww
I'm not sure we can do that because we can't do the rest of the ...
7 years, 7 months ago (2013-05-15 01:19:13 UTC) #13
jww
I just uploaded a patch that includes a test for nonce behavior of redirects in ...
7 years, 7 months ago (2013-05-16 00:44:31 UTC) #14
abarth-chromium
https://codereview.chromium.org/14949017/diff/25001/Source/core/dom/ScriptElement.cpp File Source/core/dom/ScriptElement.cpp (right): https://codereview.chromium.org/14949017/diff/25001/Source/core/dom/ScriptElement.cpp#newcode295 Source/core/dom/ScriptElement.cpp:295: bool validNonce = document->contentSecurityPolicy()->allowNonce(m_element->fastGetAttribute(HTMLNames::nonceAttr)); Maybe isValidNonceForScript? Different types of ...
7 years, 7 months ago (2013-05-16 00:59:27 UTC) #15
jww
I *think* I've made the changes you've requested, although I have a couple of questions ...
7 years, 7 months ago (2013-05-16 20:58:59 UTC) #16
abarth-chromium
LGTM modulo some style nits. Thanks for working on this CL! https://codereview.chromium.org/14949017/diff/40001/Source/core/dom/ScriptElement.cpp File Source/core/dom/ScriptElement.cpp (right): ...
7 years, 7 months ago (2013-05-16 21:09:16 UTC) #17
jww
https://codereview.chromium.org/14949017/diff/40001/Source/core/dom/ScriptElement.cpp File Source/core/dom/ScriptElement.cpp (right): https://codereview.chromium.org/14949017/diff/40001/Source/core/dom/ScriptElement.cpp#newcode271 Source/core/dom/ScriptElement.cpp:271: bool isValidScriptNonce = m_element->document()->contentSecurityPolicy()->allowScriptNonce(request.initiatorElement()->fastGetAttribute(HTMLNames::nonceAttr)); On 2013/05/16 21:09:16, abarth wrote: ...
7 years, 7 months ago (2013-05-16 21:37:46 UTC) #18
abarth-chromium
https://codereview.chromium.org/14949017/diff/48001/Source/core/dom/ScriptElement.cpp File Source/core/dom/ScriptElement.cpp (right): https://codereview.chromium.org/14949017/diff/48001/Source/core/dom/ScriptElement.cpp#newcode299 Source/core/dom/ScriptElement.cpp:299: if (!m_isExternalScript && (!shouldBypassMainWorldContentSecurityPolicy && !document->contentSecurityPolicy()->allowInlineScript(document->url(), m_startLineNumber))) I actually ...
7 years, 7 months ago (2013-05-16 22:01:20 UTC) #19
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/jww@chromium.org/14949017/48001
7 years, 7 months ago (2013-05-16 22:01:35 UTC) #20
commit-bot: I haz the power
Retried try job too often on linux_layout_rel for step(s) webkit_tests http://build.chromium.org/p/tryserver.chromium/buildstatus?builder=linux_layout_rel&number=8379
7 years, 7 months ago (2013-05-16 22:43:07 UTC) #21
abarth-chromium
Those errors are in the tree, not with your CL. The other boxes are green.
7 years, 7 months ago (2013-05-16 22:44:25 UTC) #22
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/jww@chromium.org/14949017/48001
7 years, 7 months ago (2013-05-16 22:44:45 UTC) #23
commit-bot: I haz the power
Retried try job too often on linux_layout_rel for step(s) webkit_tests http://build.chromium.org/p/tryserver.chromium/buildstatus?builder=linux_layout_rel&number=8390
7 years, 7 months ago (2013-05-16 23:22:27 UTC) #24
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/jww@chromium.org/14949017/48001
7 years, 7 months ago (2013-05-16 23:24:14 UTC) #25
commit-bot: I haz the power
7 years, 7 months ago (2013-05-16 23:24:42 UTC) #26
Message was sent while issue was closed.
Change committed as 150541

Powered by Google App Engine
This is Rietveld 408576698