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

Issue 2612793002: Implement ContentSecurityPolicy on the browser-side. (Closed)

Created:
3 years, 11 months ago by arthursonzogni
Modified:
3 years, 10 months ago
Reviewers:
Mike West, clamy, jam, alexmos, nasko
CC:
chromium-reviews, creis+watch_chromium.org, darin-cc_chromium.org, jam, nasko+codewatch_chromium.org
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Implement ContentSecurityPolicy on the browser-side. Content Security Policy is currently parsed and checked in the renderer process inside Blink. We want to do it on the browser-side as well for a few reasons: - When the navigation occurs on the browser-side with PlzNavigate. - When using OOPIF. - When no renderer are used (frame-ancestors with PDF files, ...). This patch adds the base classes to make this feature works. It is self-contained and doesn't interact with anything. Only tests are using it for the moment. BUG=376522 CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:linux_site_isolation Review-Url: https://codereview.chromium.org/2612793002 Cr-Commit-Position: refs/heads/master@{#451807} Committed: https://chromium.googlesource.com/chromium/src/+/7c9cab4db31531feba84b8b8e6e8a8b859afbc5a

Patch Set 1 : Implement ContentSecurityPolicy on the browser-side. #

Patch Set 2 : Remove the parser, turn 'class' into 'struct'. #

Patch Set 3 : Temporary re-add the parser + transmit parsed CSP over IPC. #

Total comments: 1

Patch Set 4 : Expose blink CSP to the browser. #

Patch Set 5 : Remove frame-ancestors (+nits) #

Patch Set 6 : Add tests + add partial support for inner urls. #

Patch Set 7 : Remove DCHECK: Allow wildcard with 'self' or other source. #

Patch Set 8 : Rebase + nits. #

Patch Set 9 : Fix compile problem by removing a semicolon after a macro. #

Patch Set 10 : Fix inner_url and the case when no CSP are set. #

Patch Set 11 : Rebase. #

Patch Set 12 : Addressed comments jam@ #

Patch Set 13 : Handle case when 'self' has an unspecified port. #

Patch Set 14 : Rebase. #

Patch Set 15 : Remove headers that are no more used. #

Patch Set 16 : Rename SchemeShouldBypass => SchemeShouldBypassCSP. #

Total comments: 41

Patch Set 17 : Addressed comments(@mkwst) #

Patch Set 18 : Nit. #

Total comments: 21

Patch Set 19 : Addressed comments mkwst@ #2. #

Patch Set 20 : Make structs looks like structs. #

Patch Set 21 : Rebase from master. #

Total comments: 14

Patch Set 22 : Addressed comments(nasko@) #

Patch Set 23 : Rebase #

Patch Set 24 : Bring the CSP raw header inside each policy. #

Patch Set 25 : Rebase. #

Patch Set 26 : Add the TODO and bug ids that was forgotten. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+1925 lines, -123 lines) Patch
M content/browser/DEPS View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 2 chunks +1 line, -1 line 0 comments Download
M content/browser/frame_host/frame_tree_node.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 3 chunks +9 lines, -2 lines 0 comments Download
M content/browser/frame_host/frame_tree_node.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 1 chunk +4 lines, -1 line 0 comments Download
M content/browser/frame_host/render_frame_host_impl.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 2 chunks +4 lines, -1 line 0 comments Download
M content/browser/frame_host/render_frame_host_impl.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 2 chunks +4 lines, -2 lines 0 comments Download
M content/browser/shared_worker/shared_worker_instance.h View 1 2 3 1 chunk +1 line, -1 line 0 comments Download
M content/common/BUILD.gn View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 1 chunk +10 lines, -0 lines 0 comments Download
M content/common/DEPS View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 2 chunks +1 line, -1 line 0 comments Download
M content/common/content_param_traits_macros.h View 1 2 3 1 chunk +1 line, -1 line 0 comments Download
A content/common/content_security_policy/content_security_policy.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 1 chunk +53 lines, -0 lines 0 comments Download
A content/common/content_security_policy/content_security_policy.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 1 chunk +159 lines, -0 lines 0 comments Download
A content/common/content_security_policy/content_security_policy_unittest.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 1 chunk +128 lines, -0 lines 0 comments Download
A content/common/content_security_policy/csp_context.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 1 chunk +60 lines, -0 lines 0 comments Download
A content/common/content_security_policy/csp_context.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1 chunk +88 lines, -0 lines 0 comments Download
A content/common/content_security_policy/csp_context_unittest.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 1 chunk +84 lines, -0 lines 0 comments Download
A content/common/content_security_policy/csp_directive.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 1 chunk +48 lines, -0 lines 0 comments Download
A content/common/content_security_policy/csp_directive.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 chunk +51 lines, -0 lines 0 comments Download
A content/common/content_security_policy/csp_source.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 1 chunk +66 lines, -0 lines 0 comments Download
A content/common/content_security_policy/csp_source.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 1 chunk +186 lines, -0 lines 0 comments Download
A content/common/content_security_policy/csp_source_list.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 1 chunk +44 lines, -0 lines 0 comments Download
A content/common/content_security_policy/csp_source_list.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 1 chunk +109 lines, -0 lines 0 comments Download
A content/common/content_security_policy/csp_source_list_unittest.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 1 chunk +180 lines, -0 lines 0 comments Download
A content/common/content_security_policy/csp_source_unittest.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 1 chunk +328 lines, -0 lines 0 comments Download
M content/common/content_security_policy_header.h View 1 2 3 1 chunk +1 line, -1 line 0 comments Download
M content/common/frame_messages.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 4 chunks +34 lines, -2 lines 0 comments Download
M content/renderer/BUILD.gn View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 1 chunk +2 lines, -0 lines 0 comments Download
A content/renderer/content_security_policy_util.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 1 chunk +23 lines, -0 lines 0 comments Download
A content/renderer/content_security_policy_util.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 1 chunk +57 lines, -0 lines 0 comments Download
M content/renderer/render_frame_impl.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 1 chunk +2 lines, -1 line 0 comments Download
M content/renderer/render_frame_impl.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 3 chunks +11 lines, -5 lines 0 comments Download
M content/renderer/render_frame_proxy.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 1 chunk +0 lines, -1 line 0 comments Download
M content/renderer/shared_worker/embedded_shared_worker_stub.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 1 chunk +1 line, -1 line 0 comments Download
M content/renderer/shared_worker/shared_worker_repository.h View 1 2 3 1 chunk +1 line, -1 line 0 comments Download
M content/test/BUILD.gn View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 1 chunk +4 lines, -0 lines 0 comments Download
M third_party/WebKit/LayoutTests/FlagExpectations/enable-browser-side-navigation View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 1 chunk +0 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/core/frame/csp/CSPDirectiveList.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 2 chunks +13 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/core/frame/csp/CSPDirectiveList.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 1 chunk +21 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/core/frame/csp/CSPSource.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 3 chunks +4 lines, -1 line 0 comments Download
M third_party/WebKit/Source/core/frame/csp/CSPSource.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 1 chunk +14 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/core/frame/csp/ContentSecurityPolicy.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 2 chunks +22 lines, -12 lines 0 comments Download
M third_party/WebKit/Source/core/frame/csp/SourceListDirective.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 2 chunks +7 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/core/frame/csp/SourceListDirective.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 1 chunk +12 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/core/loader/FrameLoaderClient.h View 1 2 3 4 5 6 7 8 9 10 11 3 chunks +8 lines, -5 lines 0 comments Download
M third_party/WebKit/Source/web/AssertMatchingEnums.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 4 chunks +6 lines, -1 line 0 comments Download
M third_party/WebKit/Source/web/FrameLoaderClientImpl.h View 1 2 3 4 5 6 7 8 9 10 1 chunk +5 lines, -3 lines 0 comments Download
M third_party/WebKit/Source/web/FrameLoaderClientImpl.cpp View 1 2 3 4 5 6 7 8 9 10 1 chunk +3 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/web/SharedWorkerRepositoryClientImpl.cpp View 1 2 3 4 5 6 7 8 9 10 3 chunks +3 lines, -3 lines 0 comments Download
M third_party/WebKit/Source/web/WebEmbeddedWorkerImpl.h View 1 2 3 4 5 6 7 1 chunk +2 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/web/WebSharedWorkerImpl.h View 1 2 3 4 5 6 7 1 chunk +2 lines, -2 lines 0 comments Download
A + third_party/WebKit/public/platform/WebContentSecurityPolicy.h View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +3 lines, -0 lines 0 comments Download
A + third_party/WebKit/public/platform/WebContentSecurityPolicyStruct.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 1 chunk +35 lines, -10 lines 0 comments Download
D third_party/WebKit/public/web/WebContentSecurityPolicy.h View 1 2 3 1 chunk +0 lines, -50 lines 0 comments Download
M third_party/WebKit/public/web/WebEmbeddedWorkerStartData.h View 1 2 3 1 chunk +1 line, -1 line 0 comments Download
M third_party/WebKit/public/web/WebFrameClient.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 4 chunks +7 lines, -5 lines 0 comments Download
M third_party/WebKit/public/web/WebRemoteFrame.h View 1 2 3 4 5 6 7 1 chunk +1 line, -1 line 0 comments Download
M third_party/WebKit/public/web/WebSharedWorker.h View 1 2 3 1 chunk +1 line, -1 line 0 comments Download

Dependent Patchsets:

Messages

Total messages: 111 (79 generated)
arthursonzogni
Hi Mike, I would like to have your feeling about this. Its a set of ...
3 years, 11 months ago (2017-01-11 15:08:07 UTC) #8
arthursonzogni
Hi Nasko, I discuss with Mike yesterday, he think it would be a safer first ...
3 years, 11 months ago (2017-01-18 10:30:24 UTC) #10
nasko
> I discuss with Mike yesterday, he think it would be a safer first step ...
3 years, 11 months ago (2017-01-23 22:54:50 UTC) #13
nasko
Adding alexmos@ actually.
3 years, 11 months ago (2017-01-23 23:08:07 UTC) #15
alexmos
On 2017/01/23 22:54:50, nasko wrote: > > I discuss with Mike yesterday, he think it ...
3 years, 11 months ago (2017-01-24 01:54:09 UTC) #16
arthursonzogni
Hi there, I think I have reached the point where this patch can be reviewed. ...
3 years, 11 months ago (2017-01-24 16:16:23 UTC) #21
alexmos
> Since I removed the parser from the browser and rely on the renderer parser, ...
3 years, 11 months ago (2017-01-24 18:14:04 UTC) #22
arthursonzogni
Thanks @alex@ for these confirmations. I double check what we talk about with 'frame-ancestors'. Yes, ...
3 years, 11 months ago (2017-01-25 10:06:20 UTC) #23
Mike West
On 2017/01/24 at 18:14:04, alexmos wrote: > > Since I removed the parser from the ...
3 years, 11 months ago (2017-01-25 10:48:02 UTC) #24
arthursonzogni
On 2017/01/25 10:48:02, Mike West (sloooooow) wrote: > On 2017/01/24 at 18:14:04, alexmos wrote: > ...
3 years, 11 months ago (2017-01-25 12:27:28 UTC) #25
clamy
On 2017/01/25 12:27:28, arthursonzogni wrote: > On 2017/01/25 10:48:02, Mike West (sloooooow) wrote: > > ...
3 years, 11 months ago (2017-01-25 12:40:30 UTC) #26
Mike West
On 2017/01/25 at 12:40:30, clamy wrote: > - For shipping PlzNavigate: we don't need to ...
3 years, 11 months ago (2017-01-25 12:43:45 UTC) #27
arthursonzogni
On 2017/01/25 12:43:45, Mike West (sloooooow) wrote: > On 2017/01/25 at 12:40:30, clamy wrote: > ...
3 years, 11 months ago (2017-01-25 13:38:22 UTC) #28
nasko
On 2017/01/25 13:38:22, arthursonzogni wrote: > On 2017/01/25 12:43:45, Mike West (sloooooow) wrote: > > ...
3 years, 11 months ago (2017-01-25 14:49:55 UTC) #29
arthursonzogni
On 2017/01/25 14:49:55, nasko (very slow) wrote: > On 2017/01/25 13:38:22, arthursonzogni wrote: > > ...
3 years, 10 months ago (2017-02-09 16:52:36 UTC) #62
jam
The classes in content/common have constructors that take in Blink types that are non-POD/enum. Since ...
3 years, 10 months ago (2017-02-09 17:50:38 UTC) #64
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/2612793002/550001
3 years, 10 months ago (2017-02-10 12:54:17 UTC) #69
commit-bot: I haz the power
No L-G-T-M from a valid reviewer yet. CQ run can only be started by full ...
3 years, 10 months ago (2017-02-10 12:54:21 UTC) #71
arthursonzogni
On 2017/02/09 17:50:38, jam wrote: > The classes in content/common have constructors that take in ...
3 years, 10 months ago (2017-02-10 12:56:35 UTC) #72
Mike West
https://codereview.chromium.org/2612793002/diff/670001/content/common/content_security_policy/csp_source.h File content/common/content_security_policy/csp_source.h (right): https://codereview.chromium.org/2612793002/diff/670001/content/common/content_security_policy/csp_source.h#newcode17 content/common/content_security_policy/csp_source.h:17: struct CONTENT_EXPORT CSPSource { If your struct has methods ...
3 years, 10 months ago (2017-02-13 14:10:51 UTC) #75
arthursonzogni
Thank Mike for the review! I think I addressed the majority of the issues. For ...
3 years, 10 months ago (2017-02-14 17:07:04 UTC) #76
Mike West
Thanks for taking another pass! More comments. :) https://codereview.chromium.org/2612793002/diff/670001/content/common/content_security_policy/csp_source.h File content/common/content_security_policy/csp_source.h (right): https://codereview.chromium.org/2612793002/diff/670001/content/common/content_security_policy/csp_source.h#newcode17 content/common/content_security_policy/csp_source.h:17: struct ...
3 years, 10 months ago (2017-02-15 16:18:18 UTC) #77
arthursonzogni
Thanks Mike! I applied your suggestions. I also have removed the methods from the structs. ...
3 years, 10 months ago (2017-02-16 13:30:26 UTC) #78
nasko
Some preliminary comments, haven't gone through most of the code yet. https://codereview.chromium.org/2612793002/diff/770001/content/common/content_security_policy/csp_context.cc File content/common/content_security_policy/csp_context.cc (right): ...
3 years, 10 months ago (2017-02-17 01:03:20 UTC) #83
arthursonzogni
Thanks Nasko! https://codereview.chromium.org/2612793002/diff/770001/content/common/content_security_policy/csp_context.cc File content/common/content_security_policy/csp_context.cc (right): https://codereview.chromium.org/2612793002/diff/770001/content/common/content_security_policy/csp_context.cc#newcode11 content/common/content_security_policy/csp_context.cc:11: self_scheme_(""), On 2017/02/17 01:03:15, nasko (out until ...
3 years, 10 months ago (2017-02-17 09:30:22 UTC) #84
Mike West
Sorry for the OOO delay. LGTM. Let's land this to get out of y'all's way ...
3 years, 10 months ago (2017-02-21 10:07:31 UTC) #93
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/2612793002/850001
3 years, 10 months ago (2017-02-21 13:03:49 UTC) #96
arthursonzogni
Thanks Mike! Yes, it is not good thing to have CSP checked on the two ...
3 years, 10 months ago (2017-02-21 13:27:54 UTC) #101
clamy
Thanks! content/ lgtm.
3 years, 10 months ago (2017-02-21 14:10:59 UTC) #102
Mike West
IPC still LGTM.
3 years, 10 months ago (2017-02-21 14:16:22 UTC) #103
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/2612793002/870001
3 years, 10 months ago (2017-02-21 15:30:21 UTC) #108
commit-bot: I haz the power
3 years, 10 months ago (2017-02-21 18:59:07 UTC) #111
Message was sent while issue was closed.
Committed patchset #26 (id:870001) as
https://chromium.googlesource.com/chromium/src/+/7c9cab4db31531feba84b8b8e6e8...

Powered by Google App Engine
This is Rietveld 408576698