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

Issue 2290193003: Include the Origin header for XHR and Fetch API even if the request is same-origin

Created:
4 years, 3 months ago by tyoshino (SeeGerritForStatus)
Modified:
4 years, 3 months ago
Reviewers:
CC:
chromium-reviews, blink-reviews, loading-reviews_chromium.org, tyoshino+watch_chromium.org, Nate Chapin, gavinp+loader_chromium.org
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Include the Origin header for XHR and Fetch API even if the request is same-origin FrameFetchContext::addAdditionalRequestHeaders() which is used by the ResourceFetcher to initialize a ResourceRequest uses ResourceRequest::addHTTPOriginIfNeeded() to add the Origin header. But this method omits the Origin header if the method is GET or HEAD. This logic was originally for addressing privacy concerns. But for cross-origin requests initiated by XHR and Fetch API, we're already sending the Origin header regardless of the method in use to use the CORS protocol. Even for same-origin requests, the XHR and Fetch Standard requires the Origin to be included. Sending the Origin header for same origin requests never reveals any privacy as the requester script and the destination server are the same origin. So, add an option to ThreadableLoaderOptions to add the Origin header for same-origin requests as well as the cross-origin case where CrossOriginAccessControl::updateRequestForAccessControl() is called and it adds the Origin header, and turn on the option for XHR and Fetch API. See also the spec discussion at https://github.com/whatwg/fetch/issues/91 BUG=641620, 557621

Patch Set 1 #

Patch Set 2 : a #

Patch Set 3 : a #

Unified diffs Side-by-side diffs Delta from patch set Stats (+47 lines, -23 lines) Patch
M third_party/WebKit/LayoutTests/http/tests/cache/resources/xhr-vary-header-response.php View 1 1 chunk +3 lines, -4 lines 0 comments Download
M third_party/WebKit/LayoutTests/http/tests/cache/resources/xhr-vary-header-subframe.html View 1 1 chunk +1 line, -1 line 0 comments Download
M third_party/WebKit/LayoutTests/http/tests/cache/xhr-vary-header.html View 1 2 chunks +4 lines, -4 lines 0 comments Download
M third_party/WebKit/LayoutTests/http/tests/cache/xhr-vary-header-expected.txt View 1 1 chunk +3 lines, -3 lines 0 comments Download
M third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/fetch-request-xhr-iframe.html View 1 2 chunks +2 lines, -2 lines 0 comments Download
M third_party/WebKit/LayoutTests/http/tests/xmlhttprequest/origin-header-same-origin-get-async-expected.txt View 1 1 chunk +1 line, -1 line 0 comments Download
M third_party/WebKit/LayoutTests/http/tests/xmlhttprequest/origin-header-same-origin-get-sync-expected.txt View 1 1 chunk +1 line, -1 line 0 comments Download
M third_party/WebKit/LayoutTests/http/tests/xmlhttprequest/xhr-to-blob-in-isolated-world.html View 1 2 1 chunk +10 lines, -2 lines 0 comments Download
M third_party/WebKit/LayoutTests/http/tests/xmlhttprequest/xmlhttprequest-allowed-with-disabled-web-security-expected.txt View 1 1 chunk +1 line, -1 line 0 comments Download
M third_party/WebKit/Source/core/loader/DocumentThreadableLoader.h View 1 chunk +1 line, -1 line 0 comments Download
M third_party/WebKit/Source/core/loader/DocumentThreadableLoader.cpp View 3 chunks +9 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/core/loader/ThreadableLoader.h View 2 chunks +10 lines, -1 line 0 comments Download
M third_party/WebKit/Source/core/xmlhttprequest/XMLHttpRequest.cpp View 1 1 chunk +1 line, -0 lines 0 comments Download

Messages

Total messages: 8 (8 generated)
tyoshino (SeeGerritForStatus)
The CQ bit was checked by tyoshino@chromium.org to run a CQ dry run
4 years, 3 months ago (2016-08-30 11:33:24 UTC) #1
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2290193003/1
4 years, 3 months ago (2016-08-30 11:33:45 UTC) #2
commit-bot: I haz the power
The CQ bit was unchecked by commit-bot@chromium.org
4 years, 3 months ago (2016-08-30 13:06:22 UTC) #3
commit-bot: I haz the power
Dry run: Try jobs failed on following builders: mac_chromium_rel_ng on master.tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/mac_chromium_rel_ng/builds/287278)
4 years, 3 months ago (2016-08-30 13:06:22 UTC) #4
tyoshino (SeeGerritForStatus)
The CQ bit was checked by tyoshino@chromium.org to run a CQ dry run
4 years, 3 months ago (2016-09-01 08:59:58 UTC) #5
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2290193003/20001
4 years, 3 months ago (2016-09-01 09:00:20 UTC) #6
tyoshino (SeeGerritForStatus)
Description was changed from ========== Include the Origin header even in same-origin requests. BUG=641620,557621 ========== ...
4 years, 3 months ago (2016-09-01 09:22:41 UTC) #7
tyoshino (SeeGerritForStatus)
4 years, 3 months ago (2016-09-02 04:57:45 UTC) #8
Description was changed from

==========
Include the Origin header for XHR and Fetch API even if the request is
same-origin

FrameFetchContext::addAdditionalRequestHeaders() which is used by the
ResourceFetcher to initialize a ResourceRequest uses
ResourceRequest::addHTTPOriginIfNeeded() to add the Origin header. But
this method omits the Origin header if the method is GET or HEAD.

This logic was originally for addressing privacy concerns. But for
cross-origin requests initiated by XHR and Fetch API, we're already
sending the Origin header regardless of the method in use to use the
CORS protocol. Even for same-origin requests, the XHR and Fetch
Standard requires the Origin to be included. Sending the Origin header
for same origin requests never reveals any privacy as the requester
script and the destination server are the same origin. So, add an
option to ThreadableLoaderOptions to add the Origin header for
same-origin requests as well as the cross-origin case where
CrossOriginAccessControl::updateRequestForAccessControl() is called and
it adds the Origin header, and turn on the option for XHR and Fetch API.

See also the spec discussion at https://github.com/whatwg/fetch/issues/91

BUG=641620,557621
==========

to

==========
Include the Origin header for XHR and Fetch API even if the request is
same-origin

FrameFetchContext::addAdditionalRequestHeaders() which is used by the
ResourceFetcher to initialize a ResourceRequest uses
ResourceRequest::addHTTPOriginIfNeeded() to add the Origin header. But
this method omits the Origin header if the method is GET or HEAD.

This logic was originally for addressing privacy concerns. But for
cross-origin requests initiated by XHR and Fetch API, we're already
sending the Origin header regardless of the method in use to use the
CORS protocol. Even for same-origin requests, the XHR and Fetch
Standard requires the Origin to be included. Sending the Origin header
for same origin requests never reveals any privacy as the requester
script and the destination server are the same origin. So, add an
option to ThreadableLoaderOptions to add the Origin header for
same-origin requests as well as the cross-origin case where
CrossOriginAccessControl::updateRequestForAccessControl() is called and
it adds the Origin header, and turn on the option for XHR and Fetch API.

See also the spec discussion at https://github.com/whatwg/fetch/issues/91

BUG=641620,557621
==========

Powered by Google App Engine
This is Rietveld 408576698