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

Issue 348253002: Add CORS headers to URLRequestRedirectJob. (Closed)

Created:
6 years, 6 months ago by robwu
Modified:
6 years, 3 months ago
CC:
cbentzel+watch_chromium.org, chromium-apps-reviews_chromium.org, chromium-reviews, extensions-reviews_chromium.org, Mike West
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Project:
chromium
Visibility:
Public.

Description

In Chromium, requests can be redirected before they hit the network by (re)starting the request with a URLRequestRedirectJob. This is used by HSTS, the extension webRequest API and protocol handlers. These redirects are trusted and must be followed. However when such redirects are triggered for a cross-origin resource, e.g. <img src=".." crossorigin="anonymous">, Blink blocks the redirect because the Access-Control-Allow-{Origin,Credentials} response headers are missing. This CL adds these headers to fix the problem. Adding these CORS headers to the redirect response is safe, because CORS is still enforced at the redirect target. For example, if HSTS is active for google.com and an evil page embeds <img src="http://google.com/" crossorigin="use-credentials">, then the image is not displayed because google.com does not reply with "Access-Control-Allow-Origin: null". BUG=387198 TEST=ExtensionWebRequestApiTest.WebRequestBlocking, HTTPSRequestTest.HSTSCrossOriginAddHeaders Committed: https://crrev.com/4e0be1f338c3bb9bb3c347cdb4c5e3b7944c5c67 Cr-Commit-Position: refs/heads/master@{#294494}

Patch Set 1 #

Total comments: 4

Patch Set 2 : use a more efficient string concatenation method #

Total comments: 1

Patch Set 3 : rebase to deal with changes by CL 422233006 #

Total comments: 4

Patch Set 4 : Add comment about URL visibility to url_request_redirect_job.h #

Patch Set 5 : Add HTTPSRequestTest.HSTSCrossOriginAddHeaders #

Total comments: 8

Patch Set 6 : Update test, remove redundant comments. #

Total comments: 6

Patch Set 7 : fixed nits #

Patch Set 8 : EXPECT GURL -> std::string #

Unified diffs Side-by-side diffs Delta from patch set Stats (+260 lines, -3 lines) Patch
A chrome/test/data/extensions/api_test/webrequest/cors/load_image.html View 1 chunk +24 lines, -0 lines 0 comments Download
A chrome/test/data/extensions/api_test/webrequest/cors/redirect_target.gif View Binary file 0 comments Download
A chrome/test/data/extensions/api_test/webrequest/cors/redirect_target.gif.mock-http-headers View 1 chunk +9 lines, -0 lines 0 comments Download
M chrome/test/data/extensions/api_test/webrequest/test_blocking.js View 1 2 2 chunks +137 lines, -0 lines 0 comments Download
M net/url_request/url_request_redirect_job.h View 1 2 3 1 chunk +5 lines, -3 lines 0 comments Download
M net/url_request/url_request_redirect_job.cc View 1 2 3 4 5 1 chunk +17 lines, -0 lines 0 comments Download
M net/url_request/url_request_unittest.cc View 1 2 3 4 5 6 7 1 chunk +68 lines, -0 lines 0 comments Download

Messages

Total messages: 45 (10 generated)
robwu
Hi mmenke, could you review this? I have added tests for the webRequest API, but ...
6 years, 6 months ago (2014-06-22 23:13:23 UTC) #1
mmenke
On 2014/06/22 23:13:23, robwu wrote: > Hi mmenke, could you review this? > I have ...
6 years, 6 months ago (2014-06-22 23:24:51 UTC) #2
robwu
Adam, could you review the sanity of my patch (CORS)? Ryan, could you review the ...
6 years, 6 months ago (2014-06-22 23:42:34 UTC) #3
mmenke
On 2014/06/22 23:42:34, robwu wrote: > Adam, could you review the sanity of my patch ...
6 years, 6 months ago (2014-06-23 00:35:23 UTC) #4
abarth-chromium
I don't have enough context to evaluate whether this CL make sense. Sorry. https://codereview.chromium.org/348253002/diff/1/net/url_request/url_request_redirect_job.cc File ...
6 years, 6 months ago (2014-06-23 17:01:09 UTC) #5
robwu
On 2014/06/23 17:01:09, abarth wrote: > I don't have enough context to evaluate whether this ...
6 years, 6 months ago (2014-06-23 17:28:19 UTC) #6
abarth-chromium
On 2014/06/23 at 17:28:19, rob wrote: > On 2014/06/23 17:01:09, abarth wrote: > > I ...
6 years, 6 months ago (2014-06-23 18:07:56 UTC) #7
Ryan Sleevi
I'm adding palmer here to comment on the HSTS-affecting behaviour. Caveat: I am not too ...
6 years, 6 months ago (2014-06-23 21:46:47 UTC) #8
palmer
I don't think I am the right person to review this. (I know nearly nothing ...
6 years, 6 months ago (2014-06-25 21:44:12 UTC) #9
robwu
Review status? @abarth In your previous comment, you voiced the concern that the Origin header ...
6 years, 5 months ago (2014-07-07 21:54:19 UTC) #10
abarth-chromium
On 2014/07/07 at 21:54:19, rob wrote: > @abarth > In your previous comment, you voiced ...
6 years, 5 months ago (2014-07-07 22:14:10 UTC) #11
palmer
Seems reasonable to me, but I think tsepez and abarth are much better people to ...
6 years, 5 months ago (2014-07-07 22:16:46 UTC) #12
Ryan Sleevi
abarth: A sanity check would be making sure that the headers are the correct value ...
6 years, 5 months ago (2014-07-07 22:22:30 UTC) #13
abarth-chromium
On 2014/07/07 at 22:22:30, rsleevi wrote: > abarth: A sanity check would be making sure ...
6 years, 5 months ago (2014-07-07 22:29:40 UTC) #14
Ryan Sleevi
On 2014/07/07 22:29:40, abarth wrote: > On 2014/07/07 at 22:22:30, rsleevi wrote: > > abarth: ...
6 years, 5 months ago (2014-07-07 22:42:26 UTC) #15
robwu
On 2014/07/07 22:22:30, Ryan Sleevi wrote: > We'll likely want to page in one of ...
6 years, 5 months ago (2014-07-08 10:49:27 UTC) #16
Ryan Sleevi
On 2014/07/08 10:49:27, robwu wrote: > Given that the redirect URL is not supposed to ...
6 years, 5 months ago (2014-07-08 18:40:09 UTC) #17
robwu
crbug.com/390458 has been fixed, so the Origin header is now super reliable. Could you resume ...
6 years, 3 months ago (2014-08-26 12:33:09 UTC) #18
Ryan Sleevi
Ok, one last reviewer shuffle, but having read through this more (and having recently dealt ...
6 years, 3 months ago (2014-09-02 23:55:26 UTC) #20
Mike West
This looks reasonable on its face. As noted in the comments above, it shouldn't expose ...
6 years, 3 months ago (2014-09-03 10:35:28 UTC) #21
robwu
On 2014/09/03 10:35:28, Mike West wrote: > It would be valuable to add a test ...
6 years, 3 months ago (2014-09-03 17:45:32 UTC) #22
Ryan Sleevi
On 2014/09/03 17:45:32, robwu wrote: > On 2014/09/03 10:35:28, Mike West wrote: > > It ...
6 years, 3 months ago (2014-09-03 19:25:42 UTC) #23
robwu
On 2014/09/03 19:25:42, Ryan Sleevi wrote: > On 2014/09/03 17:45:32, robwu wrote: > > On ...
6 years, 3 months ago (2014-09-04 22:43:59 UTC) #24
robwu
Added an extra test in //net @rsleevi, could you review the patch?
6 years, 3 months ago (2014-09-10 10:32:34 UTC) #30
Mike West
The code change and test LGTM, but Ryan or someone more familiar with //net should ...
6 years, 3 months ago (2014-09-10 10:39:52 UTC) #31
Ryan Sleevi
Mostly there, but a few nits. This LG to me, but I'm going to ask ...
6 years, 3 months ago (2014-09-10 21:47:47 UTC) #32
mmenke
I'll get back to you tomorrow. On 2014/09/10 21:47:47, Ryan Sleevi wrote: > Mostly there, ...
6 years, 3 months ago (2014-09-10 22:08:06 UTC) #33
robwu
https://codereview.chromium.org/348253002/diff/180001/net/url_request/url_request_redirect_job.cc File net/url_request/url_request_redirect_job.cc (right): https://codereview.chromium.org/348253002/diff/180001/net/url_request/url_request_redirect_job.cc#newcode103 net/url_request/url_request_redirect_job.cc:103: // in the header string. On 2014/09/10 21:47:47, Ryan ...
6 years, 3 months ago (2014-09-11 11:54:29 UTC) #34
mmenke
url_request_unittests LGTM, just some minor suggestions. https://codereview.chromium.org/348253002/diff/220001/net/url_request/url_request_unittest.cc File net/url_request/url_request_unittest.cc (right): https://codereview.chromium.org/348253002/diff/220001/net/url_request/url_request_unittest.cc#newcode6834 net/url_request/url_request_unittest.cc:6834: GURL(base::StringPrintf("http://example.net:%d/echo", "echo" is ...
6 years, 3 months ago (2014-09-11 14:38:09 UTC) #36
robwu
https://codereview.chromium.org/348253002/diff/220001/net/url_request/url_request_unittest.cc File net/url_request/url_request_unittest.cc (right): https://codereview.chromium.org/348253002/diff/220001/net/url_request/url_request_unittest.cc#newcode6834 net/url_request/url_request_unittest.cc:6834: GURL(base::StringPrintf("http://example.net:%d/echo", On 2014/09/11 14:38:08, mmenke wrote: > "echo" is ...
6 years, 3 months ago (2014-09-11 14:55:40 UTC) #37
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patchset/348253002/240001
6 years, 3 months ago (2014-09-11 19:33:38 UTC) #39
commit-bot: I haz the power
Try jobs failed on following builders: linux_chromium_gn_rel on tryserver.chromium.linux (http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_gn_rel/builds/14692) mac_chromium_compile_dbg on tryserver.chromium.mac (http://build.chromium.org/p/tryserver.chromium.mac/builders/mac_chromium_compile_dbg/builds/14662) mac_chromium_rel_swarming ...
6 years, 3 months ago (2014-09-11 20:30:32 UTC) #41
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patchset/348253002/260001
6 years, 3 months ago (2014-09-11 21:30:51 UTC) #43
commit-bot: I haz the power
Committed patchset #8 (id:260001) as b950723a0a25c481d2c7914bd520704f5df8343b
6 years, 3 months ago (2014-09-11 23:42:31 UTC) #44
commit-bot: I haz the power
6 years, 3 months ago (2014-09-12 00:22:12 UTC) #45
Message was sent while issue was closed.
Patchset 8 (id:??) landed as
https://crrev.com/4e0be1f338c3bb9bb3c347cdb4c5e3b7944c5c67
Cr-Commit-Position: refs/heads/master@{#294494}

Powered by Google App Engine
This is Rietveld 408576698