Closed Bug 1647681 Opened 4 years ago Closed 4 years ago

Circumventing anti-tracking with top-level sandboxing

Categories

(Core :: Privacy: Anti-Tracking, defect, P1)

defect

Tracking

()

VERIFIED FIXED
81 Branch
Tracking Status
firefox81 --- fixed

People

(Reporter: johannh, Assigned: dimi)

References

Details

Attachments

(1 file)

tl;dr I believe that using CSP: sandbox on the top-level document almost all current anti-tracking measures such as content blocking and cookie restrictions can be circumvented.

POC is here: https://sandboxed-with-trackers.glitch.me/

Top-level sandboxed pages are pages that are sending the Content-Security-Policy: sandbox; header as part of their HTTP response headers. This will put them in a similar state as iframes with the sandbox attribute, they get a null principal and are generally not same-origin with what's shown in the URL bar.

I initially noticed that these pages are not getting any shield icon in the url bar, which makes total sense considering that they can't receive tracking exceptions on their principal, but that is probably also a separate bug.

This top-level null principal seems to have further deep implications on our anti-tracking measures, as no tracking or fingerprinting resources loaded from top-level sandboxed documents will be blocked, and cookie restrictions from ETP also do not seem to apply regularly.

Of course sandboxed documents operate under restricted conditions, and they can't access their same-origin storage and cookies. This extends to their embedded iframes, but unfortunately it does not apply when loading resources such as images or iframes with SameSite=None cookies. Thus, a possible attack could look like this:

  • news.com wants to enable several online trackers to show more "relevant" advertisement based on cross-site tracking.
  • news.com sandboxes all its top-level pages except those where user account data is needed, i.e. the free version of the site is sandboxed and the behind-paywall version is not sandboxed
  • news.com loads tracker.com and fingerprinter.com successfully, bypassing any content blocking
  • To circumvent standard ETP cookie restrictions, tracker.com loads iframe ads that only rely on the HTTP cookie header for identifying the user and pass this state on via query params etc.

From my testing dFPI doesn't seem to help with this, purging is obviously unaffected and does help close this avenue a little.

(see POC)

news.com sandboxes all its top-level pages except those where user account data is needed

Thinking more about this, if they don't rely on document.cookie on the client they can just sandbox literally all their content except the login page.

Dimi, the solution might be related to URL Classifier. Could you take a look to see if you can take over this bug?
Talk to Johann or Baku if you have any questions.

Flags: needinfo?(dlee)

Coincidentally, I am working on another Bug 1437626 and one of the patches fixes this issue.
But note that the patch doesn't fix not showing shield icon in the url bar. As johnn mentioned, that should be a separate bug.

Flags: needinfo?(dlee)
Depends on: 1437626
Severity: -- → S3
Priority: -- → P1

This issue should be fixed by the patch in Bug 1437626. I'll write a testcase for this.

Assignee: nobody → dlee
Status: NEW → ASSIGNED
Blocks: 1654546
Flags: needinfo?(dlee)
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Flags: needinfo?(dlee) → in-testsuite+
Resolution: --- → FIXED
Target Milestone: --- → 81 Branch

This doesn't have to be confidential anymore, the fix shipped.

Group: mozilla-employee-confidential
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: