Skip to content
Access control Disclosed report Intermediate CVE-2023-3482

"Block all cookies" bypass for localstorage using about:blank iframe, plus document.cookie weirdness

Firefox's cookie blocking setting (including 'All cookies') could be bypassed for localStorage by accessing it through an iframe's contentWindow. An attacker could store and retrieve data despite the user's privacy settings.

Martin Hostettler Follow

Originally disclosed on Mozilla

  • Fixed in 6 days
  • Paid in 7 days
  • Disclosed after 6 days
Text
Created attachment 9340109
testfiles.zip

[originally submitted via email, but the autoresponder asked to resubmit via bugzilla]
While testing a cookie auto deletion addon, i came across what seem to be a cookie/storage permission bypass.

Steps to reproduce:

0. As usual serve the attached files using a local webserver (like python3 -mhttp.server) and access them on a
   non localhost ip.

1. I have tested this with a fresh firefox nightly (116.0a1 (2023-06-16)(64bit).
2. In the fresh profile set cookie blocking to "custom" and select to block "All cookies".[1]
3. Confirm that normal access to local storage is blocked by using the attached test-noiframe.html
3a: Access to the storage APIs gives a "DOMException: The operation is insecure.", the storage tab in developer tools show no saved data.
4. But Using the attached test2.html give unblocked access to local storage.

Expected Result:
Firefox blocks storage access the same as when using the non iframe version of the test. No data stored.

Actual Result:
The storage apis work and ignore the setting to block the access:
* No exception on usage
* When entering data in the textbox and pressing save, on reloading the page, the page can retrieve the data.
* The saved data is not visible in developer tools, but even after restarting firefox the page can still read back the data.
* The origin with the saved data is shown in "Manage Cookies and Site Data" as having used storage.

I have not tracked done the regression point, but using firefox 100, the blocking works and the api access gives the expected exceptions.
This seems to be a recent regression.

The core part of test2.html is as follows. It seems by just using the contentWindow of a otherwise defaulted iframe,
the blocking of the storage api is evaded.
'''HTML
<iframe id="preview" name="preview"></iframe>
<script>
let p = document.getElementById('preview');
let currentData = p.contentWindow.localStorage.getItem('blah');
document.getElementById('odata').innerText = currentData;

function setTest() {
    p.contentWindow.localStorage.setItem('blah', document.getElementById('idata').value);
}
</script>
'''
From looking at the profile directory the local storage seems to be attributed to the origin used to access test2.html.

storage.sqlite
INSERT INTO origin VALUES(2,'','192.168.123.123','http://192.168.123.123:4567','L9',9,1686945337316151,1,0);

storage/default/http+++192.168.123.123+4567/ls/data.sqlite
INSERT INTO "database" VALUES('http://192.168.123.123:4567',9,1686944680773745,0,6144);


I've played around a bit if this also allows evading storage isolation, but i did not the storage to leak across.
But this still evades supported data privacy settings.


 [1] The problem also manifests with other global settings and blocking the specific origin.

The original report as published on Mozilla's Bugzilla, by Martin Hostettler. Images and videos are our own copies; raw HTML is shown as text. View it on Mozilla's Bugzilla.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely a regression in Firefox's storage access checks that fails to apply cookie blocking when localStorage is accessed via an iframe's contentWindow.

Impact

The setting to block all cookies (and other global or per-origin blocking) can be bypassed for localStorage, allowing data to be stored and read despite the user's privacy preferences.

What the attacker needed

Firefox with cookie blocking enabled; Victim visits a malicious page

How it was found

  1. Serve the test files on a non-localhost IP.
  2. In a fresh Firefox profile, set cookie blocking to 'custom' and block 'All cookies'.
  3. Confirm normal localStorage access is blocked using test-noiframe.html.
  4. Access test2.html, which uses an iframe's contentWindow to access localStorage.
  5. Observe that localStorage operations succeed without exceptions and data persists.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

A browser setting to block cookies should also block website storage like localStorage. This report shows that if a page uses an iframe (an embedded page) and accesses its storage through JavaScript, the block is ignored, so data can still be saved and read.

What is Access control?

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.

More from Mozilla

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.