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

Issue 2628733005: Experiment with hiding <script>'s 'nonce' content attribute. (Closed)

Created:
3 years, 11 months ago by Mike West
Modified:
3 years, 11 months ago
CC:
blink-reviews, blink-reviews-dom_chromium.org, blink-reviews-html_chromium.org, chromium-reviews, dglazkov+blink, krit, eae+blinkwatch, f(malita), fs, gyuyoung2, kinuko+watch, kouhei+svg_chromium.org, pdr+svgwatchlist_chromium.org, rwlbuis, Stephen Chennney, sof
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Experiment with hiding <script>'s 'nonce' content attribute. Nonces are valuable, as they allow script execution. It would be lovely if we could raise the bar on exfiltration to reduce the effectiveness of some of the attacks noted at http://sebastian-lekies.de/csp/bypasses.php. One mechanism that might be effective against some kinds of exfiltration is to stop treating the 'nonce' content attribute as the source of truth, instead pulling the nonce value into an internal slot on the HTMLScriptElement at parse-time. That prevents exfiltration via attribute leakage, mitigating the effect of vectors like `[nonce^=ab]` and `content: attr(nonce)` (http://cspnonce-test.appspot.com/exploit?reset=1 and http://sebastian-lekies.de/csp/social_engineering.php, respectively). We also clear the nonce after use ("number used _once_", right?) which mitigates the style of attack hinted at in https://sirdarckcat.github.io/csp/fakexss.html (though that specific issue is also resolved by fixing the browser bug in https://codereview.chromium.org/2618323002). Here, we're replacing the nonce content attribute with '[Replaced]', as that gives developers a hint at what's going on (e.g. in devtools), but we could pretty easily drop that in the future and just make it a devtools feature entirely. Not sure what the right thing to do is.. This prototype just effects `<script>`; once we decide on reasonable behavior, we can extend it to `<link>` and `<style>`. BUG=680419 Review-Url: https://codereview.chromium.org/2628733005 Cr-Commit-Position: refs/heads/master@{#443252} Committed: https://chromium.googlesource.com/chromium/src/+/d6fffa909e840af681a223f53a2c19dd80942a2d

Patch Set 1 #

Patch Set 2 : Rebase. #

Patch Set 3 : Tests. #

Patch Set 4 : Clear. #

Patch Set 5 : Write. #

Patch Set 6 : Rebase. #

Patch Set 7 : Skip a W3C test. #

Patch Set 8 : Ugh. #

Total comments: 1
Unified diffs Side-by-side diffs Delta from patch set Stats (+113 lines, -12 lines) Patch
M third_party/WebKit/LayoutTests/TestExpectations View 1 2 3 4 5 6 7 1 chunk +3 lines, -0 lines 0 comments Download
M third_party/WebKit/LayoutTests/W3CImportExpectations View 1 2 3 4 5 6 1 chunk +3 lines, -0 lines 1 comment Download
M third_party/WebKit/LayoutTests/fast/dom/element-attribute-js-null.html View 1 2 1 chunk +1 line, -2 lines 0 comments Download
M third_party/WebKit/LayoutTests/fast/dom/element-attribute-js-null-expected.txt View 1 2 1 chunk +0 lines, -1 line 0 comments Download
A third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/nonces/script-nonces-hidden.php View 1 2 3 4 1 chunk +55 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/core/dom/ScriptLoader.cpp View 1 2 3 3 chunks +8 lines, -6 lines 0 comments Download
M third_party/WebKit/Source/core/dom/ScriptLoaderClient.h View 1 2 3 4 2 chunks +5 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/core/frame/csp/ContentSecurityPolicy.h View 1 chunk +1 line, -0 lines 0 comments Download
M third_party/WebKit/Source/core/frame/csp/ContentSecurityPolicy.cpp View 2 chunks +7 lines, -1 line 0 comments Download
M third_party/WebKit/Source/core/html/HTMLScriptElement.h View 1 2 3 4 2 chunks +6 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/core/html/HTMLScriptElement.cpp View 1 2 chunks +9 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/core/html/HTMLScriptElement.idl View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download
M third_party/WebKit/Source/core/svg/SVGScriptElement.h View 1 2 3 4 2 chunks +6 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/core/svg/SVGScriptElement.cpp View 1 1 chunk +7 lines, -1 line 0 comments Download
M third_party/WebKit/Source/platform/RuntimeEnabledFeatures.in View 1 2 3 4 5 1 chunk +1 line, -0 lines 0 comments Download

Messages

Total messages: 37 (30 generated)
Mike West
WDYT about this direction?
3 years, 11 months ago (2017-01-11 15:50:00 UTC) #3
lwe
On 2017/01/11 15:50:00, Mike West (sloooooow) wrote: > WDYT about this direction? Will s.nonce in ...
3 years, 11 months ago (2017-01-11 16:10:54 UTC) #7
Mike West
On 2017/01/11 at 16:10:54, lwe wrote: > On 2017/01/11 15:50:00, Mike West (sloooooow) wrote: > ...
3 years, 11 months ago (2017-01-11 20:42:56 UTC) #12
jochen (gone - plz use gerrit)
the second sentence of the CL description is incomplete otherwise, this lgtm
3 years, 11 months ago (2017-01-12 08:42:17 UTC) #14
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2628733005/140001
3 years, 11 months ago (2017-01-12 14:32:41 UTC) #32
commit-bot: I haz the power
Committed patchset #8 (id:140001) as https://chromium.googlesource.com/chromium/src/+/d6fffa909e840af681a223f53a2c19dd80942a2d
3 years, 11 months ago (2017-01-12 16:16:25 UTC) #35
tkent
3 years, 11 months ago (2017-01-17 23:07:18 UTC) #37
Message was sent while issue was closed.
https://codereview.chromium.org/2628733005/diff/140001/third_party/WebKit/Lay...
File third_party/WebKit/LayoutTests/W3CImportExpectations (right):

https://codereview.chromium.org/2628733005/diff/140001/third_party/WebKit/Lay...
third_party/WebKit/LayoutTests/W3CImportExpectations:722:
imported/wpt/html/dom/reflection-misc.html [ Skip ]
Please do not skip this test, and please check in new -expected.txt.  WPT
importer removed the test, and we lost test coverage.

Powered by Google App Engine
This is Rietveld 408576698