Skip to content
This repository has been archived by the owner on Sep 19, 2020. It is now read-only.

Referrer leakage at a certain website #78

Open
7 of 9 tasks
ghost opened this issue Oct 25, 2018 · 31 comments
Open
7 of 9 tasks

Referrer leakage at a certain website #78

ghost opened this issue Oct 25, 2018 · 31 comments
Labels
bug Something isn't working

Comments

@ghost
Copy link

ghost commented Oct 25, 2018

Prerequisites

  • I performed a cursory search of the issue tracker to avoid opening a duplicate issue
  • This is not a support issue or a question
    • Support issues and questions are handled at /r/uMatrix
  • I tried to reproduce the issue when...
    • uMatrix is the only extension
    • uMatrix with default lists/settings
    • using a new, unmodified browser profile
  • I am running the latest version of uMatrix
  • I checked the documentation to understand that the issue I report is not a normal behavior
  • I used the logger to rule out that the issue is caused by my ruleset

Description

Referrer leaks at https://www.myip.com/ when visited via google search result.

A specific URL where the issue occurs

https://www.myip.com/

Steps to Reproduce

  1. Visit https://www.google.com/
  2. Type my ip in search and hit Enter
  3. Click on the very first result which is https://www.myip.com/ and scroll down to the end of the page to locate Referrer field showing URL: www.google.com

Supporting evidence

Logger shows that REFERRER was blocked yet the website is able to detect.

Your environment

  • uMatrix version: v1.3.15.101
  • Browser Name and version: Chrome 72
  • Operating System and version: Win X
@uBlock-user uBlock-user added bug Something isn't working Chromium specific to Chromium/Chrome labels Oct 25, 2018
@uBlock-user
Copy link
Contributor

uBlock-user commented Oct 25, 2018

Chromium specific, not reproducible on Firefox.

@gorhill
Copy link
Member

gorhill commented Oct 25, 2018

I could not reproduce with Chromium 70/Linux on my side.

This reminds me of this issue: #74 -- though not confirmed by OP, it appears the Cookie header was not being removed by the browser as instructed by uMatrix.

@uBlock-user
Copy link
Contributor

uBlock-user commented Oct 25, 2018

I can reproduce on Chromium 70.0.3538.67/Windows on my end.

@ghost
Copy link
Author

ghost commented Oct 25, 2018

@gorhill so a browser bug ? Weird, only happens on that site and nowhere else. Should I close this ?

Btw I'm not affected by #74, if I block cookies, I get logged out, so don't think this is related to that issue.

@gorhill
Copy link
Member

gorhill commented Oct 25, 2018

Ok I could reproduce, I had to allow some 3rd-party scripts in the matrix.

After investigating, I confirm uMatrix really removes the Referer header from request headers.

However, the browser still sets the document.referrer to the original, unmodified header. I consider this to be a browser issue -- I can't even properly provide a workaround for this, only the browser can properly set the correct document.referrer value to match the request header one.

@ghost
Copy link
Author

ghost commented Oct 25, 2018

I had to allow some 3rd-party scripts in the matrix.

my bad, forgot to add you need to whitelist ajax.googleapis.com

the browser still sets the document.referrer to the original, unmodified header.

but this website only ? Other referrer testing websites work fine. Is the website triggering some exploit ?

@ghost
Copy link
Author

ghost commented Oct 25, 2018

Speaking of document.referrer, it stores the correct value no matter what on any website, below screenshot was taken on https://www.whatsmyreferer.com/ - referrer is spoofed succesfully yet this -

@gorhill
Copy link
Member

gorhill commented Oct 25, 2018

There are two ways a site can report to you the referrer they see: server-side or client-side.

If server-side, the referrer is looked up from the request headers, hence it will be spoofed.

If client-side (requires javascript code to be executed), the referrer will be looked up from document.referrer, hence not spoofed in Chromium due to browser bug.

@ghost
Copy link
Author

ghost commented Oct 25, 2018

Guessing they're picking the client-side value right ?

@gorhill
Copy link
Member

gorhill commented Oct 25, 2018

Yes, load https://www.myip.com/js/graf.js and scrolled to the end.

@ghost
Copy link
Author

ghost commented Oct 25, 2018

With Script-safe in place of uMatrix -

Seems the header is not sent at all or removed. I set the setting Block-click-through referrer to "On All Domains" for that to happen. Maybe you want to try this approach for a workaround.

@gorhill
Copy link
Member

gorhill commented Oct 25, 2018

I consider this a browser bug, this is what needs to be fixed. No reliable workaround can be crafted to match current referrer-spoofing feature -- at best, a workaround would be unreliable, i.e. easily bypassed by having script code executed at the top of a document, before uMatrix's own content script can patch the referrer according to current ruleset. I rather there be a real, actual fix than the appearance of one. My official suggestion would be to just use Firefox if rock-solid referrer spoofing is important.

@ghost
Copy link
Author

ghost commented Oct 25, 2018

No I'm fine, thought I would suggest one until document.referrer gets patched. So do you want me to keep it open ?

@uBlock-user
Copy link
Contributor

I consider this a browser bug, this is what needs to be fixed.

Can't find any bugs filed on the tracker. Do you know of any ?

@gorhill
Copy link
Member

gorhill commented Oct 26, 2018

Keep it open, I remembered there is this new Referrer-Policy header which appeared relatively recently, I need to investigate whether it can be used to implement uMatrix's referrer-spoofing.

@gorhill
Copy link
Member

gorhill commented Oct 26, 2018

With Script-safe in place of uMatrix

I looked into this, and I found that ScriptSafe adds a rel="no-referrer" to every link element in the DOM. Not sure what would happen if new link elements are dynamically added -- I didn't look further. Also unsure what would happen for when a location is navigated programmatically.

@ghost
Copy link
Author

ghost commented Oct 26, 2018

Is there any extension of Referrer Policy ? I want to see it in action once and see it deals.

@uBlock-user
Copy link
Contributor

Made a uBO-Scriptlet to patch document.referrer, useful on cases where document.referrer is used.

(function () {
	let myRefer = '{{1}}';
	window.document.__defineGetter__('referrer', function () {
		return myRefer;
	});
})();

@ribatamu
Copy link

ribatamu commented Feb 6, 2019

The extension Referer Control at https://chrome.google.com/webstore/detail/referer-control/hnkcfpcejkafcihlgbojoidoihckciin?hl=en is blocking the referer with success on 3rd party requests.

@uBlock-user
Copy link
Contributor

Yes, like this --

chrome.runtime.sendMessage({
	type:"blockReferrer"
}, function (r) {
	try {
		if(r.block){
			var meta = document.createElement('meta');
			meta.name = "referrer";
			meta.content = "no-referrer";
			document.getElementsByTagName('head')[0].appendChild(meta);
		}
	} catch(ignore){}
});

@ribatamu
Copy link

ribatamu commented Feb 6, 2019

@uBlock-user could you made this part from your uBO-Scriptlet?

@uBlock-user
Copy link
Contributor

It's better if the fix lands in the extension itself, rather than having to use a scriptlet in ublock.

@ribatamu
Copy link

ribatamu commented Feb 6, 2019

I agreed.

I tried to play with the options in this Referer Control extension... I tested of few pages with which I had referer leakage with uMatrix before and seems to work well.

I am not sure if that can be implemented in uMatrix.

@HashLiver
Copy link

referrer-spoof not work in Chrome 72+, working on Chrome 71 now

@gorhill
Copy link
Member

gorhill commented Feb 7, 2019

@HashLiver Probably related to #74, fixed in dev build.

@ribatamu
Copy link

ribatamu commented Mar 8, 2019

The extension Privacy Manager is working really well about hiding the referer in Chrome.

The uMatrix is not working of some pages. The referer control extension is working on every site tested but I had cases in which I had to disable the blocking the referrer string of third-party requests in order the page to work properly.

I don't know how they do but surprisingly, the Privacy Manager is working on every page tested.

@cnleo

This comment has been minimized.

@uBlock-user
Copy link
Contributor

uBlock-user commented Nov 11, 2019

Apparently I can reproduce this on Firefox Nightly too --

image

image

@uBlock-user uBlock-user removed the Chromium specific to Chromium/Chrome label Nov 11, 2019
@uBlock-user uBlock-user changed the title Referrer leakage at a certain website in Chrome Referrer leakage at a certain website Nov 11, 2019
@rusty-snake
Copy link

FYI: https://gitlab.com/smart-referer/smart-referer/issues/138

@rusty-snake
Copy link

FYI: https://bugzilla.mozilla.org/show_bug.cgi?id=1601496

@nikitalita
Copy link

@uBlock-user did you ever get this working on chrome? I have been trying a number of techniques to get around this to no avail.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

7 participants