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

Issue 2563843002: Restrict app sandbox's CSP to disallow loading web content in them. (Closed)

Created:
4 years ago by lazyboy
Modified:
3 years, 9 months ago
CC:
chromium-reviews, chromium-apps-reviews_chromium.org, extensions-reviews_chromium.org
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Restrict app sandbox's CSP to disallow loading web content in them. The CL restricts loading subframes and scripts inside chrome app sandbox pages (https://developer.chrome.com/apps/manifest/sandbox). The restriction would only allow loading these resources from 'self', i.e. the app's resources. 1) scripts Two CSP directives can affect subframe restriction: script-src or default-src fallback when script-src is not present. 2) subframes Three possible CSP directives can affect script restriction: frame-src or (deprecated) child-src or default-src fallback when none of frame-src/child-src is present. This CL adds a GetEffectiveSandboxedPageCSP function, which returns the effective CSP chrome will use when a certain sandbox CSP (sandbox.content_security_policy key) is specified in app's manifest. The effective CSP is a restricted CSP that strips out any remote hosts from #1 and #2. Any directive source value that is not surrounded by single quotes are considered remote hosts. The approach is to add 'self' as source value by default if 'none' was not specified. TODO: Update sandbox documentation page. BUG=615585 Test=Loading a remote script from foo.com inside a chrome apps sandbox page should not be possible, even with setting the following "sandbox.content_security_policy" key in the manifest: script-src: foo.com Same would go with loading <iframe> elements. It should not be possible to load web content <iframe>s inside apps. Committed: https://crrev.com/c0304f6696623d76672a4c8fbefa16378c3137b8 Cr-Commit-Position: refs/heads/master@{#441208}

Patch Set 1 #

Total comments: 10

Patch Set 2 : update parsing code, generalize for extensions and sandbox pages #

Patch Set 3 : fix unit_tests #

Patch Set 4 : sync #

Patch Set 5 : sync #

Total comments: 10

Patch Set 6 : address comments + rework CL + StringPieces #

Total comments: 42

Patch Set 7 : address comments #

Patch Set 8 : more commetns #

Total comments: 16

Patch Set 9 : address comments #

Patch Set 10 : address comments #

Patch Set 11 : comments #

Total comments: 2

Patch Set 12 : address comments + update doc #

Total comments: 6

Patch Set 13 : comments #

Patch Set 14 : sync @tott #

Unified diffs Side-by-side diffs Delta from patch set Stats (+776 lines, -315 lines) Patch
M chrome/browser/extensions/chrome_content_browser_client_extensions_part.cc View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +4 lines, -10 lines 0 comments Download
M chrome/browser/extensions/sandboxed_pages_apitest.cc View 1 1 chunk +11 lines, -0 lines 0 comments Download
M chrome/common/extensions/docs/templates/articles/manifest/sandbox.html View 1 2 3 4 5 6 7 8 9 10 11 12 3 chunks +14 lines, -4 lines 0 comments Download
A chrome/test/data/extensions/api_test/sandboxed_pages_csp/local_frame.html View 1 2 3 4 5 6 7 8 1 chunk +3 lines, -0 lines 0 comments Download
A chrome/test/data/extensions/api_test/sandboxed_pages_csp/local_frame.js View 1 2 3 4 5 6 7 8 1 chunk +11 lines, -0 lines 0 comments Download
A chrome/test/data/extensions/api_test/sandboxed_pages_csp/main.html View 1 1 chunk +1 line, -0 lines 0 comments Download
A chrome/test/data/extensions/api_test/sandboxed_pages_csp/main.js View 1 2 3 4 5 6 1 chunk +36 lines, -0 lines 0 comments Download
A chrome/test/data/extensions/api_test/sandboxed_pages_csp/manifest.json View 1 1 chunk +9 lines, -0 lines 0 comments Download
A chrome/test/data/extensions/api_test/sandboxed_pages_csp/remote_frame.html View 1 1 chunk +2 lines, -0 lines 0 comments Download
A chrome/test/data/extensions/api_test/sandboxed_pages_csp/remote_frame.js View 1 2 3 4 5 6 7 8 1 chunk +11 lines, -0 lines 0 comments Download
A chrome/test/data/extensions/api_test/sandboxed_pages_csp/sandboxed.html View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +57 lines, -0 lines 0 comments Download
M extensions/common/csp_validator.h View 1 1 chunk +12 lines, -0 lines 0 comments Download
M extensions/common/csp_validator.cc View 1 2 3 4 5 6 7 8 9 9 chunks +308 lines, -93 lines 0 comments Download
M extensions/common/csp_validator_unittest.cc View 1 2 3 4 5 6 5 chunks +278 lines, -196 lines 0 comments Download
M extensions/common/manifest_handlers/csp_info_unittest.cc View 1 2 3 4 5 6 1 chunk +3 lines, -2 lines 0 comments Download
M extensions/common/manifest_handlers/sandboxed_page_info.cc View 1 2 chunks +15 lines, -9 lines 0 comments Download
M extensions/test/data/manifest_tests/sandboxed_pages_valid_3.json View 1 2 3 4 5 6 1 chunk +1 line, -1 line 0 comments Download

Messages

Total messages: 54 (30 generated)
lazyboy
Devlin & Charlie: Wanted to see how you feel about this approach... This CL uses ...
4 years ago (2016-12-09 00:14:18 UTC) #2
Devlin
Overall, I like this approach. I think we should add an API test for it, ...
4 years ago (2016-12-09 15:46:01 UTC) #7
Charlie Reis
[+alexmos, mkwst for Devlin's question] Thanks for making progress on this! I'm ok with a ...
4 years ago (2016-12-09 19:55:07 UTC) #9
alexmos
https://codereview.chromium.org/2563843002/diff/1/extensions/common/csp_validator.cc File extensions/common/csp_validator.cc (right): https://codereview.chromium.org/2563843002/diff/1/extensions/common/csp_validator.cc#newcode348 extensions/common/csp_validator.cc:348: std::string GetEffectiveSandoxedPageCSP(const std::string& policy) { On 2016/12/09 19:55:07, Charlie ...
4 years ago (2016-12-12 19:04:11 UTC) #10
lazyboy
On 2016/12/12 19:04:11, alexmos wrote: > https://codereview.chromium.org/2563843002/diff/1/extensions/common/csp_validator.cc > File extensions/common/csp_validator.cc (right): > > https://codereview.chromium.org/2563843002/diff/1/extensions/common/csp_validator.cc#newcode348 > ...
4 years ago (2016-12-12 19:14:00 UTC) #11
lazyboy
(patch set #5) https://codereview.chromium.org/2563843002/diff/1/chrome/browser/extensions/chrome_content_browser_client_extensions_part.cc File chrome/browser/extensions/chrome_content_browser_client_extensions_part.cc (right): https://codereview.chromium.org/2563843002/diff/1/chrome/browser/extensions/chrome_content_browser_client_extensions_part.cc#newcode309 chrome/browser/extensions/chrome_content_browser_client_extensions_part.cc:309: // app. Isolating hosted apps is ...
4 years ago (2016-12-14 00:49:05 UTC) #23
Devlin
https://codereview.chromium.org/2563843002/diff/80001/chrome/test/data/extensions/api_test/sandboxed_pages_csp/local_frame.js File chrome/test/data/extensions/api_test/sandboxed_pages_csp/local_frame.js (right): https://codereview.chromium.org/2563843002/diff/80001/chrome/test/data/extensions/api_test/sandboxed_pages_csp/local_frame.js#newcode6 chrome/test/data/extensions/api_test/sandboxed_pages_csp/local_frame.js:6: window.parent.postMessage(JSON.stringify(['loaded', 'local_frame.html']), nit: This wrapping looks a bit weird. ...
4 years ago (2016-12-15 00:04:11 UTC) #24
lazyboy
https://codereview.chromium.org/2563843002/diff/80001/chrome/test/data/extensions/api_test/sandboxed_pages_csp/local_frame.js File chrome/test/data/extensions/api_test/sandboxed_pages_csp/local_frame.js (right): https://codereview.chromium.org/2563843002/diff/80001/chrome/test/data/extensions/api_test/sandboxed_pages_csp/local_frame.js#newcode6 chrome/test/data/extensions/api_test/sandboxed_pages_csp/local_frame.js:6: window.parent.postMessage(JSON.stringify(['loaded', 'local_frame.html']), On 2016/12/15 00:04:10, Devlin wrote: > nit: ...
4 years ago (2016-12-15 08:02:35 UTC) #25
Charlie Reis
BTW, I'll be OOO after today, so feel free to land this without me, once ...
4 years ago (2016-12-16 20:17:00 UTC) #26
Devlin
I'm still not in love with the approach, but I'm willing to accept that as ...
4 years ago (2016-12-20 17:36:39 UTC) #27
lazyboy
https://codereview.chromium.org/2563843002/diff/100001/chrome/test/data/extensions/api_test/sandboxed_pages_csp/sandboxed.html File chrome/test/data/extensions/api_test/sandboxed_pages_csp/sandboxed.html (right): https://codereview.chromium.org/2563843002/diff/100001/chrome/test/data/extensions/api_test/sandboxed_pages_csp/sandboxed.html#newcode23 chrome/test/data/extensions/api_test/sandboxed_pages_csp/sandboxed.html:23: // I couldn't find a better way than setTimeout ...
4 years ago (2016-12-22 03:07:30 UTC) #29
Devlin
https://codereview.chromium.org/2563843002/diff/140001/chrome/test/data/extensions/api_test/sandboxed_pages_csp/local_frame.js File chrome/test/data/extensions/api_test/sandboxed_pages_csp/local_frame.js (right): https://codereview.chromium.org/2563843002/diff/140001/chrome/test/data/extensions/api_test/sandboxed_pages_csp/local_frame.js#newcode5 chrome/test/data/extensions/api_test/sandboxed_pages_csp/local_frame.js:5: /* nit: dead code? https://codereview.chromium.org/2563843002/diff/140001/chrome/test/data/extensions/api_test/sandboxed_pages_csp/remote_frame.js File chrome/test/data/extensions/api_test/sandboxed_pages_csp/remote_frame.js (right): https://codereview.chromium.org/2563843002/diff/140001/chrome/test/data/extensions/api_test/sandboxed_pages_csp/remote_frame.js#newcode6 ...
4 years ago (2016-12-22 17:04:32 UTC) #33
lazyboy
https://codereview.chromium.org/2563843002/diff/140001/chrome/test/data/extensions/api_test/sandboxed_pages_csp/local_frame.js File chrome/test/data/extensions/api_test/sandboxed_pages_csp/local_frame.js (right): https://codereview.chromium.org/2563843002/diff/140001/chrome/test/data/extensions/api_test/sandboxed_pages_csp/local_frame.js#newcode5 chrome/test/data/extensions/api_test/sandboxed_pages_csp/local_frame.js:5: /* On 2016/12/22 17:04:32, Devlin wrote: > nit: dead ...
4 years ago (2016-12-22 22:57:06 UTC) #34
Devlin
nice; code lg. Were you planning on updating the documentation in this patch set? https://codereview.chromium.org/2563843002/diff/200001/chrome/test/data/extensions/api_test/sandboxed_pages_csp/sandboxed.html ...
3 years, 12 months ago (2016-12-27 17:48:38 UTC) #35
lazyboy
Updated the docs. https://codereview.chromium.org/2563843002/diff/200001/chrome/test/data/extensions/api_test/sandboxed_pages_csp/sandboxed.html File chrome/test/data/extensions/api_test/sandboxed_pages_csp/sandboxed.html (right): https://codereview.chromium.org/2563843002/diff/200001/chrome/test/data/extensions/api_test/sandboxed_pages_csp/sandboxed.html#newcode7 chrome/test/data/extensions/api_test/sandboxed_pages_csp/sandboxed.html:7: var identifier = +new Date; On ...
3 years, 12 months ago (2016-12-28 02:13:08 UTC) #36
Devlin
Largely lg; a few last nits. Since it's for public docs, I'd like to take ...
3 years, 11 months ago (2016-12-28 16:42:37 UTC) #37
lazyboy
https://codereview.chromium.org/2563843002/diff/220001/chrome/common/extensions/docs/templates/articles/manifest/sandbox.html File chrome/common/extensions/docs/templates/articles/manifest/sandbox.html (right): https://codereview.chromium.org/2563843002/diff/220001/chrome/common/extensions/docs/templates/articles/manifest/sandbox.html#newcode4 chrome/common/extensions/docs/templates/articles/manifest/sandbox.html:4: <b><em>Warning:</em></b> Starting version 57, Chrome will no longer load ...
3 years, 11 months ago (2016-12-28 19:14:09 UTC) #40
Devlin
lgtm
3 years, 11 months ago (2016-12-28 20:39:56 UTC) #43
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/2563843002/260001
3 years, 11 months ago (2017-01-03 20:09:19 UTC) #46
commit-bot: I haz the power
Committed patchset #14 (id:260001)
3 years, 11 months ago (2017-01-03 21:18:03 UTC) #49
commit-bot: I haz the power
Patchset 14 (id:??) landed as https://crrev.com/c0304f6696623d76672a4c8fbefa16378c3137b8 Cr-Commit-Position: refs/heads/master@{#441208}
3 years, 11 months ago (2017-01-03 21:20:21 UTC) #51
ikemevans
On 2016/12/28 19:14:09, lazyboy wrote: > https://codereview.chromium.org/2563843002/diff/220001/chrome/common/extensions/docs/templates/articles/manifest/sandbox.html > File chrome/common/extensions/docs/templates/articles/manifest/sandbox.html > (right): > > https://codereview.chromium.org/2563843002/diff/220001/chrome/common/extensions/docs/templates/articles/manifest/sandbox.html#newcode4 ...
3 years, 9 months ago (2017-03-21 00:21:14 UTC) #52
ikemevans
On 2016/12/28 16:42:37, Devlin wrote: > Largely lg; a few last nits. Since it's for ...
3 years, 9 months ago (2017-03-21 00:24:23 UTC) #53
Charlie Reis
3 years, 9 months ago (2017-03-21 17:49:41 UTC) #54
Message was sent while issue was closed.
On 2017/03/21 00:24:23, ikemevans wrote:
> Chrome Extensions do not allow the use of "webview" - only packaged apps do.
> There is now no way to load an external web page in a Chrome Extension as of
> Chrome 57.

You can still load iframes with web pages inside Chrome Extensions.  This CL
only applied to Chrome Apps.

Note: It's better to file bugs at https://new.crbug.com (or start a discussion
at chromium-extension@chromium.org) for things like this rather than posting to
closed CLs, where your question might go unseen.

Powered by Google App Engine
This is Rietveld 408576698