webkitdirectory - OS username disclosure
The webkitdirectory file picker remembers the last folder used and can be triggered by a scripted click, so a page can repeatedly open the picker and, if the victim keeps pressing Enter, walk up to the user's Desktop and reveal the OS username. If the victim previously selected a folder under Documents, a later page can cause the whole Documents folder to be uploaded without an explicit new choice.
Originally disclosed on Mozilla
- Fixed in 3 months
- Paid in 3 months
- Disclosed after 3 months
Created attachment 8813100
filedis.html
User Agent: Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.99 Safari/537.36
Steps to reproduce:
Tested on latest Nightly 53.0a1 (2016-11-21) (64-bit)
-----------OS username disclosure--------
The webkitdirectory on fresh install and profile (or new website where directory has never been uploaded) seems to always default to 'C:\Users\{user}\Desktop'
1. Open PoC on a fresh URL where directory uploading has never been performed (to make sure it defaults to dekstop)
2. Hold down enter
3. Since webkitdirectory keeps going back a folder every time its used, we only need to make sure a victim keeps hitting enter for at least 2-3 upload dialogues and then we would have successfully grabbed the OS username.
------------Arbitrary File Disclosure--------
Say you go to website 'A' and you upload a directory (doesn't actually have to upload, just as long as you loaded files) that exists in the folder 'C:\Users\{user}\Documents\', if we are able to run the attached PoC on website 'A' (say XSS or if website 'A' is codepen/jsfiddle..etc) we will be able to fool the user into uploading the entire contents of the 'My Documents' folder.
Here is one scenario:
1. Victim visits a codepen link that showcases html5 webkitdirectory.
2. Victim tests this new feature by uploading/selecting a random folder within 'My documents' then forgets about it.
3. Victim receives an attackers website which embeds a codepen code that uses the PoC here.
4. Victim then knowingly exposes his/her files.
As I mentioned, this can also be done with XSS vulnerabilities or possibly even URL spoofing.
Actual results:
In both scenarios we either disclose OS username or we have access to arbitrary files on victims computer.
Expected results:
Two suggestions:
1. Prevent input.click() from bypassing popup blocker, only allow it from mouse clicks.
2. Prevent the behavior where within the Documents folder and its contents (sub folders as well) be uploaded without explicitly choosing such an action.
For some reason #2 so far only works on Documents folder, the folder uploader seems to ignore this behavior when on C: or desktop folder and others. But if it worked for My Documents my guess is it would work on other locations.
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 directory picker both remembers the last selected folder and can be opened by a scripted click without a real user gesture, so repeated dialogs can navigate upward and re-select previously used folders.
Impact
An attacker could learn the victim's OS username, and if the victim had previously selected a folder under Documents, could cause the contents of that folder to be uploaded.
What the attacker needed
Victim uses a browser with webkitdirectory; victim presses Enter repeatedly; for file disclosure, victim previously picked a folder
How it was found
- Open the proof-of-concept page on a fresh profile where no directory has been uploaded before.
- Hold down the Enter key so the directory picker opens repeatedly.
- After two or three dialogs the picker has moved up to the Desktop and the OS username is disclosed.
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.
When a website asks you to pick a folder to upload, the browser remembers the last folder you used. The report says a malicious page can open that folder picker on its own and, if you keep pressing Enter, the picker moves up to your Desktop, which shows your computer username. It also says that if you once picked a folder inside Documents, a later page could get the whole Documents folder uploaded.
What is Info disclosure?
Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.