New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 712228 link

Starred by 1 user

Issue metadata

Status: WontFix
Owner:
Leaves the project on 2018/03/02
Closed: May 2017
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux , Android , Windows , Chrome , Mac
Pri: 2
Type: Bug



Sign in to add a comment

Origin set to null when redirected on fetched resource

Reported by mikkocar...@gmail.com, Apr 17 2017

Issue description

UserAgent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36

Steps to reproduce the problem:
I've set up a working POC at http://rootme.in/fetch, please follow along;

1. Open a your browser's Developer Tools and switch to Network tab
2. Copy & paste the following URL into the address bar

http://rootme.in/fetch?url=http://request.rootme.in/redirect%3furl=http://rootme.in

(request.rootme.in is an alias of rootme.in)

Or you can simply send fetch request to above URL from your browser's console while in rootme.in.

You'll see an error message in console saying "Origin 'null' is not allowed to access the requested resource". If you noticed, it's the same domain that we got redirected to i.e. rootme.in. Technically, it's communicating same domain so it should be able to read received response anyway.

Again, to verify the issue- please copy & paste the following URL;
http://rootme.in/fetch?url=http://request.rootme.in/redirect%3furl=http://httpbin.org

You, now, should be able to read received response. However, if you inspect, you'll see the sent origin is 'null' again.

What is the expected behavior?
The expected behavior is to retain "Origin" along the way. The fetch spec says;
> The `Origin` header is a version of the `Referer` header that does not reveal a path.

The referrer, however, is retained across all requests. 

What went wrong?
- Origin header wrongly interpreted as being 'null'. 
- Same-origin communication prevented due to intermediate cross-domain redirect

To clarify my second point, you can change above URL to;
http://rootme.in/fetch?url=http://rootme.in/redirect%3furl=http://rootme.in/

The redirector domain above has been changed to rootme.in which is originating domain itself. So, now we'll be able to read response as with same-domain communication. Changing final destination to httpbin.org;
http://rootme.in/fetch?url=http://rootme.in/redirect%3furl=http://httpbin.org

Now, if you inspect, it retains Origin header.

Did this work before? N/A 

Chrome version: 57.0.2987.133  Channel: stable
OS Version: 
Flash Version: 

The redirector script must be served with 'Access-Control-Allow-Origin: *' or with specified domain. Otherwise, redirection fails.
 
Screenshot from 2017-04-17 20-20-16.png
76.1 KB View Download
Screenshot from 2017-04-17 16-33-46.png
85.8 KB View Download
Components: Blink>SecurityFeature>CORS
Labels: -Type-Bug-Security -Restrict-View-SecurityTeam Type-Bug
Thanks for the report.  If this is indeed over-blocking, it's not a security vulnerability so I'll switch it to a regular bug. I've repro'd the behaviour you cited but I haven't confirmed that's not to-spec.
Labels: Needs-Triage-M57

Comment 3 by mkwst@chromium.org, Apr 19 2017

Labels: OS-Android OS-Chrome OS-Mac OS-Windows
Owner: tyoshino@chromium.org
Status: Untriaged (was: Unconfirmed)
tyoshino@: Can you triage this, please?
Labels: Needs-Feedback
rootme.in and request.rootme.in are not same origin.

See https://html.spec.whatwg.org/multipage/browsers.html#same-origin for the definition of same origin-ness.

Since the origin of the page "http://rootme.in/fetch?url=http://request.rootme.in/redirect%3furl=http://rootme.in" is "http://rootme.in", the request by fetch() call to "http://request.rootme.in/redirect?url=http://rootme.in" is cross-origin.

See the step 10 of HTTP-redirect fetch algorithm at https://fetch.spec.whatwg.org/#http-redirect-fetch. Here:
- CORS flag is set since current url's origin ("http://request.rootme.in/") and request's origin ("http://rootme.in/") are not same origin and therefore HTTP fetch was performed with CORS flag set. See the step 12 of the Main fetch algorithm at https://fetch.spec.whatwg.org/#main-fetch.
- location URL is "http://rootme.in/" as the Location header in the response for "http://request.rootme.in/redirect?url=http://rootme.in" is "http://rootme.in". This is not same origin with request's current url's origin which is http://request.rootme.in.

So, as specified, request's origin is set to unique opaque origin before following the redirect. This gets serialized into "null".
Yeah, it appeared to be following what fetch spec says. Apologies for confusion.
Labels: -Needs-Feedback
Status: WontFix (was: Untriaged)
Thank you for confirming. Closing.

Sign in to add a comment