Bug 127172 - Never send a non-http(s) referrer header even with a referrer policy
Summary: Never send a non-http(s) referrer header even with a referrer policy
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: jochen
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-01-17 06:01 PST by jochen
Modified: 2014-01-20 11:49 PST (History)
3 users (show)

See Also:


Attachments
Patch (1.51 KB, patch)
2014-01-17 06:02 PST, jochen
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description jochen 2014-01-17 06:01:13 PST
Never send a non-http(s) referrer header even with a referrer policy
Comment 1 jochen 2014-01-17 06:02:56 PST
Created attachment 221460 [details]
Patch
Comment 2 jochen 2014-01-17 06:03:38 PST
Alexey, can you have a look please?
Comment 3 Alexey Proskuryakov 2014-01-17 09:37:28 PST
Comment on attachment 221460 [details]
Patch

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

It's not cool to have a function with such an ambitious name as shouldHideReferrer, and then have it explained in a header comment what it actually means (that being, do the same thing generateReferrerHeader(ReferrerPolicyDefault), but with a murky restriction of not using the result for Referrer header sending!)

There is only one call site outside SecurityPolicy, and that looks incorrect, as it actually blocks Referer header regardless of policy if shouldHideReferrer said so.

This patch is an improvement, r=me.

> Source/WebCore/page/SecurityPolicy.cpp:75
> +    if (!protocolIs(referrer, "http") && !protocolIs(referrer, "https"))
> +        return String();

This should use url.protocolIsInHTTPFamily().
Comment 4 jochen 2014-01-20 00:34:09 PST
(In reply to comment #3)
> (From update of attachment 221460 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=221460&action=review
> 
> It's not cool to have a function with such an ambitious name as shouldHideReferrer, and then have it explained in a header comment what it actually means (that being, do the same thing generateReferrerHeader(ReferrerPolicyDefault), but with a murky restriction of not using the result for Referrer header sending!)

Agreed. The ping loader should probably just use generateReferrerHeader()

> 
> There is only one call site outside SecurityPolicy, and that looks incorrect, as it actually blocks Referer header regardless of policy if shouldHideReferrer said so.

Since it's not using the string as referrer header, i'm not sure what to do here. Even if the policy is default, the Ping-From field won't be cleared on a https to http transition in the network stack.

The most reasonable thing to do would be to change the standard to use the referrer header instead of a Ping-From header.


> 
> This patch is an improvement, r=me.
> 
> > Source/WebCore/page/SecurityPolicy.cpp:75
> > +    if (!protocolIs(referrer, "http") && !protocolIs(referrer, "https"))
> > +        return String();
> 
> This should use url.protocolIsInHTTPFamily().

That means converting referrer to a KURL, is that ok with you?
Comment 5 Alexey Proskuryakov 2014-01-20 08:22:44 PST
Comment on attachment 221460 [details]
Patch

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

>>> Source/WebCore/page/SecurityPolicy.cpp:75
>>> +        return String();
>> 
>> This should use url.protocolIsInHTTPFamily().
> 
> That means converting referrer to a KURL, is that ok with you?

You are right, let's keep it as is then.
Comment 6 WebKit Commit Bot 2014-01-20 08:58:30 PST
Comment on attachment 221460 [details]
Patch

Clearing flags on attachment: 221460

Committed r162351: <http://trac.webkit.org/changeset/162351>
Comment 7 WebKit Commit Bot 2014-01-20 08:58:32 PST
All reviewed patches have been landed.  Closing bug.
Comment 8 Darin Adler 2014-01-20 11:49:45 PST
(In reply to comment #5)
> (From update of attachment 221460 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=221460&action=review
> 
> >>> Source/WebCore/page/SecurityPolicy.cpp:75
> >>> +        return String();
> >> 
> >> This should use url.protocolIsInHTTPFamily().
> > 
> > That means converting referrer to a KURL, is that ok with you?
> 
> You are right, let's keep it as is then.

We should create a string version of the protocolIsInHTTPFamily function, for the same reason we have a URL version.