Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug 1370855 - Restrict Referer to same-origin #855

Merged
merged 1 commit into from Oct 25, 2018

Conversation

da2x
Copy link
Contributor

@da2x da2x commented Oct 23, 2018

No description provided.

@kyoshino kyoshino added the small Small changes that can be quickly merged label Oct 23, 2018
@@ -561,6 +561,10 @@ sub header {
# the MIME type away from the declared Content-Type.
$headers{'-x_content_type_options'} = 'nosniff';

# Add Referrer-Policy (sic) header to prevent browsers sending
# Referer (sic) headers to external websites.
$headers{'-referrer_policy'} = 'same-origin';
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please consider adding a backup referrer policy, for browsers that don't support 'same-origin'; for example, the below approach probably works to block older browsers from transmitting any referrer at all unless they support the new same-origin policy:

Referrer-Policy: same-origin, no-referrer, none

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would cause more issues than it solves. It would set the document policty to any one of the three values at random (as per the standard algorithm that doesn’t specify a sorting order).

I did a quick check, and not a single website in the HTTP Archive has the Referrer-Policy value of same-origin, no-referrer, none. I ran out of credits there just now so I can’t check if any value at all contains a comma.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The algorithm for Referrer Policy does specify an order:
https://www.w3.org/TR/referrer-policy/#unknown-policy-values

So Referrer-Policy: no-referrer, strict-origin-when-cross-origin is perfectly valid, as is the policy above.

@dylanwh
Copy link
Contributor

dylanwh commented Oct 23, 2018

Because of the move to Mojolicious, we have a much better place to apply headers that will work for both the old parts of the code (CGI) and all future code.

In addition, this could be accomplished with a plugin: https://metacpan.org/pod/Mojolicious::Plugin::SecurityHeader

To do this, you'd add Mojolicious::Plugin::SecurityHeader to Makefile.PL (near the other lines about Mojolicious stuff) and then in Bugzilla/Quantum.pm add $self->plugin('SecurityHeader' => {...}) as in the docs for Mojolicious::Plugin::SecurityHeader linked above.

@dylanwh
Copy link
Contributor

dylanwh commented Oct 23, 2018

Using that plugin will actually solve this bug and a bunch of other bugs, some of which have not been filed yet.

@floatingatoll
Copy link

floatingatoll commented Oct 23, 2018

Works for me! (And thank you for considering it.)

Copy link
Contributor

@dylanwh dylanwh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is good enough for now. we'll need to add this using either SecurityHeaders plugin, or manually with a before-request hook, eventually.

@dylanwh
Copy link
Contributor

dylanwh commented Oct 25, 2018

@da2x Thanks for contributing this! It should be live sometime next week, Tuesday or Wednesday at the latest.

@dylanwh dylanwh merged commit ac92b20 into mozilla-bteam:master Oct 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
small Small changes that can be quickly merged
5 participants