file: URIs SOP Bypass: local HTML file can lead to file stealing (similar to CVE-2015-7186)
A locally saved HTML file opened in Firefox on Android could read files from the device's shared storage, because file: URIs were treated as same-origin with each other. An attacker could get a victim to download and open a crafted page that then reads and exfiltrates images from known folders on the SD card.
Originally disclosed on Mozilla
- Fixed in 25 days
- Paid in 35 days
- Disclosed after 25 days
Created attachment 9071074
In this zip there are download.php base64.php test.html payload.html to reproduce the problem.
User Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.80 Safari/537.36
Steps to reproduce:
STEP TO REPROCUDE
1) Upload all the files from zip to your server
2) Edit files - replace attacker.domain with your server domain
3) Add a small image (<2kb, max 50x50) in /sdcard/Download/test.jpeg [I have used this path because it is easy and I have used a little image because so the code of the proof of concept is easy, but it is possible to replicate with every image]
4) With Firefox 67.0 open attacker.domain/test.html
5) Firefox will download the file payload.html and will save it in /sdcard/Download (by default)
6) Open with Firefox the downloaded file payload.html and wait some seconds
7) The base64 string of test.jpeg should be in image.txt
Tested on Samsung Galaxy S6 with Android 7.0 and Firefox 67.0
In the PoC.zip you find:
- test.html
- download.php, that downloads the file payload.html
- the malicious file payload.html
- base64.php to convert an image into base64 and steal it
Sorry for my english.
Actual results:
It is possible to steal files from sdcard, in particular it is easy to steal the images. In my opinion it is a serious problem because it is really easy to find some paths (e.g. /sdcard/Whatsapp/Media/WhatsApp Images/ and the images have easy name: IMG-AAAAMMDD-WAXXXX.jpg where XXXX is a number like 0000, 0001, and so)
Expected results:
In Chrome, or Microsoft Edge, or Samsung Browser this doesn't append because there is a different Same Origin Policy. I think that it is important, because it is possible to receive an HTML file in a chat (like WhatsApp), download it and open it with Firefox. So in my opinion this is a bug.
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: URI scheme was treated as a single origin, so a local HTML file could read other local files instead of being isolated.
Impact
An attacker could steal images and other files from predictable folders on the SD card, but only on Firefox for Android; Chrome, Edge and Samsung Browser were not affected.
What the attacker needed
Firefox on Android; victim downloads and opens an HTML file; target file in a known folder
How it was found
- Host the proof-of-concept files on a server and set the attacker domain in them.
- Place a small image in the device's Download folder.
- Open the hosted test page in Firefox on Android, which downloads a payload HTML file.
- Open the downloaded payload file in Firefox and wait.
- The image is read and its base64 data is sent to the attacker's server.
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 website's data; this rule is called the Same Origin Policy. Here, pages opened from the phone's local storage (file: addresses) were allowed to read each other, so a downloaded page could read other local files. The attacker only needed the victim to open a downloaded HTML file in Firefox on Android.
What is Info disclosure?
Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.