Skip to content

13464: Unrestrict referrer hiding for top-level navigations. #7591

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

Merged
merged 2 commits into from
Jan 18, 2021

Conversation

iefremov
Copy link
Contributor

@iefremov iefremov commented Jan 13, 2021

To solve webcompat problems we replace forcing "no-referrer"
for cross-site top-level navigations with capping with
"strict-origin-when-cross-origin".

Fix brave/brave-browser#13464

Resolves

Submitter Checklist:

  • There is a ticket for my issue.
  • Used Github auto-closing keywords in the commit message.
  • Wrote a good PR/commit description
  • Added appropriate labels (QA/Yes or QA/No; release-notes/include or release-notes/exclude; OS/...) to the associated issue
  • Checked the PR locally: npm run test -- brave_browser_tests, npm run test -- brave_unit_tests, npm run lint, npm run gn_check, npm run tslint
  • Ran git rebase master (if needed).
  • Requested a security/privacy review as needed.

Reviewer Checklist:

  • New files have MPL-2.0 license header.
  • Adequate test coverage exists to prevent regressions
  • Major classes, functions and non-trivial code blocks are well-commented
  • Changes in component dependencies are properly reflected in gn
  • Code follows the style guide
  • Test plan is specified in PR before merging

After-merge Checklist:

Test Plan:

Use the following test pages to confirm that all test cases are working as expected:

@iefremov iefremov requested a review from a team as a code owner January 13, 2021 21:39
@iefremov iefremov requested review from fmarier and pes10k January 13, 2021 21:39
@fmarier
Copy link
Member

fmarier commented Jan 14, 2021

"X-Brave-Clear-Referer")) {
const_cast<RedirectInfo&>(redirect_info).new_referrer.clear();
"X-Brave-Cap-Referer")) {
url::Origin referrer = url::Origin::Create(
Copy link
Member

Choose a reason for hiding this comment

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

Does this take into account HTTPS -> HTTP transitions where the referrer needs to be empty?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

huh, good catch - should be fixed now

NavigateDirectlyToPageWithLink(same_origin_url());
EXPECT_EQ(ExecScriptGetStr(kReferrerScript, contents()), link_url().spec());
EXPECT_EQ(GetLastReferrer(same_origin_url()), link_url().spec());

// Same-site but cross-origin navigations get the original page origin as the
// referrer.
const std::string expected_referrer = link_url().GetOrigin().spec();
NavigateDirectlyToPageWithLink(same_site_url());
EXPECT_EQ(ExecScriptGetStr(kReferrerScript, contents()),
link_url().GetOrigin().spec());
Copy link
Member

Choose a reason for hiding this comment

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

You could use expected_referrer here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

NavigateDirectlyToPageWithLink(same_origin_url());
EXPECT_EQ(ExecScriptGetStr(kReferrerScript, contents()), link_url().spec());
EXPECT_EQ(GetLastReferrer(same_origin_url()), link_url().spec());

// Same-site but cross-origin navigations get the original page origin as the
// referrer.
const std::string expected_referrer = link_url().GetOrigin().spec();
NavigateDirectlyToPageWithLink(same_site_url());
EXPECT_EQ(ExecScriptGetStr(kReferrerScript, contents()),
link_url().GetOrigin().spec());
EXPECT_EQ(GetLastReferrer(same_site_url()), link_url().GetOrigin().spec());
Copy link
Member

Choose a reason for hiding this comment

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

(and here)

To solve webcompat problems we replace forcing "no-referrer"
for cross-site top-level navigations with capping with
"strict-origin-when-cross-origin".

Fix brave/brave-browser#13464
@iefremov
Copy link
Contributor Author

@mkarolin please take a look, there are only simple changes

removed_headers->end(),
"X-Brave-Clear-Referer")) {
const_cast<RedirectInfo&>(redirect_info).new_referrer.clear();
if (base::Contains(*removed_headers, "X-Brave-Cap-Referer")) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: X-Brave-Cap-Referer -> ReferRer? (if so, also in browser/net/brave_site_hacks_network_delegate_helper.cc)

Copy link
Collaborator

@mkarolin mkarolin left a comment

Choose a reason for hiding this comment

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

chromium_src changes LGTM

@iefremov
Copy link
Contributor Author

@fmarier PTAL

Copy link
Member

@fmarier fmarier left a comment

Choose a reason for hiding this comment

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

Looks good to me.

I've added a test plan. Please go through it before merging to make sure we didn't forget anything in the automated tests.

@iefremov iefremov merged commit 6999e42 into master Jan 18, 2021
@iefremov iefremov deleted the ie_referrer_cap branch January 18, 2021 09:18
@iefremov
Copy link
Contributor Author

Many thanks @fmarier for the test plan - I've verified everyhing. FWIW, we block referrer.js on https://dev-pages.brave.software/referrer/default.html so I had to disable adblocking to do the checks.

@iefremov
Copy link
Contributor Author

@kjozwiak
Copy link
Member

Verification PASSED on Win 10 x64 using the following build:

Brave | 1.21.10 Chromium: 88.0.4324.89 (Official Build) nightly (64-bit)
-- | --
Revision | 4534be84786f5269fb52e9bf82643af61e2fedaf-refs/branch-heads/4324@{#1721}
OS | Windows 10 OS Version 2009 (Build 19042.746)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Strip referer to strict-origin-when-cross-origin in all cases
5 participants