Bug 161902 - [Fetch API] Referrer and Origin header should not be considered as safe request headers
Summary: [Fetch API] Referrer and Origin header should not be considered as safe reque...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: youenn fablet
URL:
Keywords:
Depends on: 151937
Blocks:
  Show dependency treegraph
 
Reported: 2016-09-13 04:06 PDT by youenn fablet
Modified: 2016-09-16 00:36 PDT (History)
4 users (show)

See Also:


Attachments
Patch (26.42 KB, patch)
2016-09-13 05:26 PDT, youenn fablet
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description youenn fablet 2016-09-13 04:06:47 PDT
As stated in https://fetch.spec.whatwg.org/#cors-safelisted-request-header, Referrer and Origin are not safe request headers.
Comment 1 youenn fablet 2016-09-13 04:07:20 PDT
As per fetch, these headers are set after preflighting.
Comment 2 youenn fablet 2016-09-13 05:26:41 PDT
Created attachment 288688 [details]
Patch
Comment 3 Alex Christensen 2016-09-13 10:54:23 PDT
Comment on attachment 288688 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=288688&action=review

> Source/WebCore/Modules/fetch/FetchLoader.cpp:96
> +    if (referrer == "no-referrer") {

Should this be a case-insensitive comparison?

> Source/WebCore/Modules/fetch/FetchLoader.cpp:100
> +        referrer = (referrer == "client") ? context.url().strippedForUseAsReferrer() : URL(context.url(), referrer).strippedForUseAsReferrer();

ditto
Comment 4 youenn fablet 2016-09-13 11:30:07 PDT
(In reply to comment #3)
> Comment on attachment 288688 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=288688&action=review
> 
> > Source/WebCore/Modules/fetch/FetchLoader.cpp:96
> > +    if (referrer == "no-referrer") {
> 
> Should this be a case-insensitive comparison?

This is not necessary.

> > Source/WebCore/Modules/fetch/FetchLoader.cpp:100
> > +        referrer = (referrer == "client") ? context.url().strippedForUseAsReferrer() : URL(context.url(), referrer).strippedForUseAsReferrer();
> 
> ditto

This is not necessary either.

"client" is a string computed within FetchRequest when given parameter is about:client or ABOUT:client. We could add a test for different "about" casing, but this is not related to this patch.

In another patch, as a small improvement, we could make fetch referrer as a structure instead of a string. That would allow to remove the need for string comparison.
Comment 5 WebKit Commit Bot 2016-09-16 00:35:53 PDT
Comment on attachment 288688 [details]
Patch

Clearing flags on attachment: 288688

Committed r206009: <http://trac.webkit.org/changeset/206009>
Comment 6 WebKit Commit Bot 2016-09-16 00:36:02 PDT
All reviewed patches have been landed.  Closing bug.