same origin policy implementation allows reading directory of a local file
Firefox's same-origin policy for file:// URIs allowed a locally saved HTML page to load a directory into an iframe and read its contents through JavaScript. An attacker who gets a victim to save and open an HTML file could list and read files in that folder.
- Fixed in 2.7 years
- Paid in 20 months
- Disclosed after 2.7 years
Created attachment 8841241
file_sop_test.zip
User Agent: Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:51.0) Gecko/20100101 Firefox/51.0
Build ID: 20170126153103
Steps to reproduce:
I have created a file that loads another file or directory in an iframe, and tries to read the contentDocument's innerHTML/innerText, to demonstrate how the same origin policy for file:// URIs works. Load the soptest.html file that is in the attached archive, enter the name of the file or directory to load into the textbox, press the 'load source' button, then press the 'steal source' button. Do this for the directory '.' (current directory).
Firefox version 51.0.1 (64-bit) on Fedora fc25
Actual results:
When loading the document's directory (.) in the iframe, the directory contents is copied out of the iframe and accessible through JavaScript (see screenshot in attached file).
An attacker that has a victim save an HTML file locally (typically in the Downloads folder), can see the files in that folder and thus read all of these files.
Expected results:
According to the SOP for "file:" URIs, this should not be allowed: "Directories cannot be loaded this way" (see
https://developer.mozilla.org/en-US/docs/Same-origin_policy_for_file:_URIs )
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 the file:// origin check treated a directory loaded in an iframe as same-origin readable content instead of blocking directory listings.
Impact
An attacker who gets a victim to save an HTML file locally could list and read files in that folder, though this is limited to Firefox on the tested platform.
What the attacker needed
Victim saves an HTML file locally; victim opens the file in Firefox; files sit in the same folder
How it was found
- Open the provided test HTML file locally in Firefox.
- Type the name of a file or directory into the textbox.
- Press the 'load source' button to load it in an iframe.
- Press the 'steal source' button to try reading the iframe content.
- Repeat with the current directory '.' to see its contents exposed.
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.
Browsers normally stop one website from reading another site's content, and the same rule is meant to apply to files opened from your own disk. Here, a saved web page could peek inside the folder it sits in and read the files there. So a page you download and open could quietly harvest other files in your Downloads folder.
What is Info disclosure?
Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.