Arbitrary File + Directory read via .lnk files on Windows Share
Originally disclosed on Mozilla
- Fixed in 10 months
- Paid in 2.0 years
- Disclosed after 10 months
Created attachment 545068
PoC
If a user can be persuaded to visit an HTML file hosted on a public Windows share (see below) then that page can use .lnk files to read arbitrary files and directory listings from their machine.
Imagine we have index.html and foo.lnk in the same directory, with foo.lnk pointing to C:\boot.ini. The HTML file is loaded via a file URL then loads foo.link into an iframe. The contents of boot.ini are displayed but document.location of the iframe is still foo.lnk. However, if the outer page tries to access the iframe, it gets a permission denied error as Firefox still seems to realise that the outer page and inner page are from different origins/directories.
The trick is to have two link files:
baz.lnk -> index.html
foo.lnk -> C:\boot.ini
First we load baz.lnk, then replace baz.lnk with foo.lnk. The HTML page then loads baz.lnk (i.e. itself) using XHR or an iframe. Because the url of the requesting page matches the page loaded, Firefox assumes they're the same origin and allows the contents to be read. Both files and directories can be read in this manner. My PoC uses static .lnk files to read some system directories and the Firefox profile.ini file. However it would be possible to traverse the whole filesystem by grabbing a directory listing and then dynamically generating .lnk files on the server.
There are various method to get the user to load content from a public share (e.g. file://///myhost.com/share/index.html):
1. Use a Java applet to force a drop of the URL (see bug 546909) - PoC uses this
2. Put an innocent looking unhyperlinked HTTP url on the page and get the user to copy/paste it into the location bar. When the user has selected the URL, sneakily change the current selection to the file: URL so that gets copied instead (PoC also has this as an alternative option)
3. Possibly send the file URL in an email. I've not really looked into this, but I seem to recall Outlook will open up \\myhost.com\share\index.html in Firefox if it's the default browser.
This attack could either work within an intranet or possibly over the internet providing your ISP/Corporate firewall doesn't block the relevant ports. My ISP does, but I know not all do. I've attached the PoC as a zip file, as I don't currently have anywhere to host this publically. It's been tested on a few Windows XP machines, not sure if Win7 has any extra security measures to prevent things like this.
Finally, this bug was found in my own time, so I promise it won't be blogged, tweeted or publicised in any way before it's fixed.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
What is known
A high-severity security bug in General. Mozilla made it public on 3 May 2012 as CVE-2012-1945.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.