I was able to duplicate this this bug using [1]. Somehow preventing outside resource_uri access or pretending to be a non-firefox browser would obviate this quirk.
Pretending to be not-firefox contradicts that torbrowser pretends to be mozilla.
Does firefox really need this "re/" feature? It comes with a serious security warning. "Note that there are no security restrictions preventing web content from including content at resource: URIs, so take care what you make visible there." I.e. maybe better to lobby to remove it entirely from upstream.
I have been playing around with accessing the js files in re/ and it looks like this issue is a bit worse now that when it was first reported. In the proof of concept on marcorondini.eu, it was only checked that #tor.js existed. I believe that it could not easily be read in the version of tor at the time as there was a few "#" comments at the top which caused javascript errors when read using a script tag. However, in the current version of tor, the file is now called 000-tor-browser.js and can easily be read using a method similar to that used in marcorondini.eu. This is rather bad, as 000-tor-browser.js contains the tor browser version number, platform and real language. This would let you make a finger print that is unique at least to the tor browser version + platform + language (maybe even the cpu arch, since there is a 64bit version for Linux).
I made a simple script on http://cs1.ca/ttest/dump.html witch dumps everything that can be read in re/defaults/. Simply hashing this output would make for a good start at a finger print.
A temporary fix until it can be dealt with upstream might be to put a few "#"s at the top of each file. I think they are parsed out the way the browser normally reads the files but would cause javascript errors when accessed like in the script I posted. Definitely not a permanent solution but it might be better than nothing.
This can be bypassed in a couple of different ways (just off the top of my head). One is by pretending to be a non-firefox browser (as mentioned above), which has some serious compatibility issues with sites that serve up different code to different browsers. Another is to strip re/ requests on pageload when possible. The extension set Disconnect does this for around a million users. In Chrome, this would be dead simple with beforeload coupled with a background script but Firefox isn't impossible.
Perhaps make a Firefox extension that sets an observer (using observer-service) to listen for http-on-modify-request (literally any request) which can detect url scheme/prefix. Then block those requests. Or respond to all of them with gibberish.
To some extent this is less of an issue because the Tor browser bundle user group is comparatively homogenous. A larger issue is that it's possible to detect extensions used and launch an exploit for only those users (again, less of an issue for TBB, but large issue for internet as a whole).
This test shows the bug still exists in current version of the TBB. If JS is enabled, the type of platform is leaked. Adversary can distinguish Windows and Linux users.
Can you ask Mozilla to change exposing re[/](/) URIs opt-in for each extension via manifests (because some non-TBB extensions need it) and eliminate re[/](/) exposure in Firefox core? This is important upstream too. It is actually one of the most critical holes in Firefox (now with Components deprecated in Web). TBB's OS mangling is only half-baked with this problem unresolved. So each anonymity
set is quite a bit smaller than imagined.
As far as I can tell the approach you're taking is the only way to do this (the http-on-modify-request event does not fire for re[/](/`) URLs for obvious reasons, so a content policy is required). Not sure what the Tor Browser policy is on licensing.
My plan was to integrate it into torbutton, instead of having it be a separate addon, though I'll drop the idea if the browser developers tell me that this should be solved another way.
I pushed a change to also restrict chrome:// URIs, regardless of contentaccessible, per discussion with gk. It sort of sucks that certain addons will break, but they aren't the standard Tor Browser set.
I leave it up to the Tor Browser people if they want to take that commit or not.
Trac: Keywords: N/Adeleted, TorBrowserTeam201606R added Status: new to needs_review
Now that #18914 (moved) is fixed, this is an important remaining hole that needs an immediate fix. With this fixed, there will be no known locale leak as far as I know. -- Thanks!
The second one is that shouldLoad is not invoked for redirects. You only get one call, for the first URL requested. If you let it pass, it can redirect anywhere without you noticing it.
So, my first guess would be that redirects can bypass this blocking mechanism. Did anybody test this?
I have not. If nsIWebProgressListener2 fire, at the right time for chrome/resource URLs that may be an option here (specifically we want the onRefreshAttempted() callback).
My original idea is that only privileged chrome:// or about: pages can initiate a redirect to the blocked resources. If there is no such redirecting URIs accessible from content, there should be no leaks.
However, testing is needed anyway.
My original idea is that only privileged chrome:// or about: pages can initiate a redirect to the blocked resources. If there is no such redirecting URIs accessible from content, there should be no leaks.
After looking at the documentation and the relevant specs, I'm 99.9% sure you're correct.
XMLHttpRequest() will fail the same-origin check, since the request is not coming from internal to the Firefox code (requests dispatched from inside Firefox can bypass the check completely, but poorly written addons are not our problem).
Fetch() refuses to have anything to do with redirects to non-HTTP(s) scheme URLs. (See: 5.4 HTTP-redirect fetch).
Do nested schemes (view-[,](,) jar:`, etc.) leak information about existing restricted resources? Although I tend to think those schemes are inaccessible from content, that does not necessarily guarantee no information leak.
I think it might have been better to use http-on-modify-request here rather than both the content policy and the response listener, but you might also not have as much information there about the source content url. Maybe this doesn't matter so much, since what we really want is a direct Firefox patch. The extra observers will have a perf cost, though.
Otherwise, I think this is OK, and I agree it is an improvement. For now, I will merge this into the torbutton master branch for TBB 6.5-alpha, since it may shake a few more issues loose.
I think it might have been better to use http-on-modify-request here rather than both the content policy and the response listener, but you might also not have as much information there about the source content url. Maybe this doesn't matter so much, since what we really want is a direct Firefox patch. The extra observers will have a perf cost, though.
The CSP is required because http-on-modify-request events dont' fire for recourse:// urls, unfortunately.