Closed
Bug 1452980
Opened 8 years ago
Closed 8 years ago
Information leak: DNS request with the content of a HTML file before saving it
Categories
(Firefox :: Untriaged, defect)
Tracking
()
RESOLVED
INVALID
People
(Reporter: lor-bug, Unassigned)
Details
Attachments
(1 file)
|
182.48 KB,
image/png
|
Details |
User Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.89 Safari/537.36
Steps to reproduce:
When downloading a HTML file with MIME type "application/octet-stream", I noticed a DNS query originating from my machine. The content of the DNS query was for a non-existing URL contained in the HTML file.
Steps to reproduce:
1. Create a simple HTML file with a URL in it (e.g. <a href="http://12345.example.com">
2. Configure a web server to serve content as application/octet-stream. I've written my own (https://github.com/lorenzog/pyUpDown) but any can do
3. Intercept DNS requests via e.g. tcpdump, wireshark, or a local DNS server
4. Download the file without saving it
Actual results:
The browser made a DNS request to a URL contained in the file before the file was saved to disk.
Please see the attached file for a screenshot: the 'hello.html' file hasn't been saved to disk yet, but the DNS query (bottom left terminal) has been issued already.
This could be used to track users e.g. a malicious advertiser could serve crafted HTML files to be downloaded containing unique URLs; even if the user were to click 'cancel' instead of saving the file, a DNS request would have been issued to the advertiser's domain, thus allowing user tracking.
Expected results:
The browser should not have parsed the file before saving it, let alone performed a DNS request.
Comment 1•8 years ago
|
||
I can't reproduce this.
I tried my best to set things up the same way as you did. I used the python script you provided. I created an HTML file in the same directory as the python script, that looks like this:
<body>
<a href="http://invalid.name.foopy.com/">Click</a>
</body>
(I later changed `href` to `ref` per the screenshot, but that didn't make a difference)
I opened the URL directly (so http://localhost:8080/foopy.html (I used the default port) ) to verify I could see my custom HTML file. Then I added the "?mime=application/octet-stream" bit in the URL bar and hit enter. I got a dialog box that looked the same as yours. I didn't interact with it.
All the while I was using wireshark, filtering for "dns". No DNS requests for the domain went out (only other ones for background activity on the machine).
I *suspect* that the issue is this:
(In reply to Lor from comment #0)
> the 'hello.html' file hasn't
> been saved to disk yet, but the DNS query (bottom left terminal) has been
> issued already.
The file *has* been saved to disk. As soon as a download starts, Firefox will start the download in the background and save to disk. In part, this is because to figure out if something is a download, Firefox is already sending the request, and having to get the response, where only once we have response headers we can even know if this is a download or a page to display or something else. So at that point we're downloading the contents of the response already, and have to do something with them, and certainly for large response contents (iso files etc.), keeping it all in memory wouldn't do.
Specifically for downloads where we prompt you for what to do, we save the file to disk in the background immediately, without waiting for your response. This is so that when you do make a decision (either a destination to save the file, or an app to open it with), that can happen immediately. If you click 'cancel', any bits that we already saved to disk will be deleted again.
Of course, in this case the file is so tiny, and the network connection so good (server on the same machine) that probably by the time your eyes have made your brain aware there's a dialog box on the screen, the file has been fully saved to disk already. :-)
So my suspicion is that something on the machine (maybe a virus scanner or something like that?) has picked up the file (which I believe by default will get saved to somewhere under /tmp/, though I could be wrong) and that's why you're seeing the request. Similarly, it's possible that an add-on in your Firefox instance has read and tried to deal with the request.
Because I'm not seeing a DNS request at all, I'm not sure how to investigate further. If you can reliably reproduce the issue, I'd suggest trying to figure out more conclusively which application is sending the DNS request (I'm not a Linux expert - on Windows I'd use process monitor - https://osqa-ask.wireshark.org/questions/26171/how-can-i-determine-which-application-is-sending-dns-queries-to-my-bind-server and https://serverfault.com/questions/666482/how-to-find-out-pid-of-the-process-sending-packets-generating-network-traffic seem to have suggestions for what to do on Linux. It may be easier to monitor what processes are touching the temp file for the downloaded HTML...). If it's Firefox, it may also be worth checking if you can reproduce without any add-ons / on a clean profile ( https://support.mozilla.org/en-US/kb/profile-manager-create-and-remove-firefox-profiles ). It's possible that an add-on that has webRequest permissions is sniffing content and is doing something with it that triggers a DNS request.
Please let us know if/when you figure out what is going on here, irrespective of whether there is something to be fixed in Firefox, so we can update the ticket.
(In reply to Lor from comment #0)
> This could be used to track users e.g. a malicious advertiser could serve
> crafted HTML files to be downloaded containing unique URLs; even if the user
> were to click 'cancel' instead of saving the file, a DNS request would have
> been issued to the advertiser's domain, thus allowing user tracking.
I don't really understand how this would help. If the advertiser is serving the browser content, it could already just track the user directly based on serving the user that content... Plus, the advertiser could use cookies with that request, whereas the DNS request is stateless... so I don't think this is a security issue because of this scenario.
That said, it's disconcerting that something is doing a DNS request for content in an application/octet-stream mimetype, so keeping this hidden until we get to the bottom of why that is.
Finally, note that your copy of Firefox in that screenshot looks pretty old. What version did you test with? I used 59.0.2 (latest release) on Ubuntu.
Flags: needinfo?(lor-bug)
Hi,
Thanks for the prompt response!
I've tried this on two different computers, both running the most up to date version of Kali linux (a modified Debian version) and it works reliably on both machines. However I've also tried this on a recent version of the Tor browser on one of these machines, and it doesn't happen -- which seems to exclude the hypothesis that there's something monitoring the filesystem (although I'm not entirely familiar with the different behaviour of the Tor browser).
I suspect now it's either an extension that I missed, or something else going on. I'll try the same set-up on another instance, possibly Windows or Ubuntu to see if it happens reliably or not and I'll get back to you as soon as I can get it all sorted.
One small item - my test file started with <html> not <body>.
On the "saving" bit -- you're right, when the browser issues the GET request the response body already contains the file, so as you said Firefox should start saving it somewhere. What I should have written was, "before the user decided whether to save the file or not".
On the 'tracking users' bit: yes, an advertiser could track the user that downloads the content; however, if the file was copied and served elsewhere (e.g. through a CDN, or maliciously by other means) then a unique DNS lookup would inform that such file has been downloaded.
I'll get back to you later, thanks for now
Lor
Hi,
I've tried on the latest windows and ubuntu and I can't reproduce it, either.
I've tried on the machine where I found the bug running Firefox in safe mode with no result either -- I think I know now what the problem is, and it's not related to Firefox. It's most likely a tool I'm using for traffic interception that generates unwanted DNS requests. I'll investigate that further and report it to the vendor.
Meanwhile, thank you very much again for your help. You can close this bug.
L.
Flags: needinfo?(lor-bug)
Comment 4•8 years ago
|
||
OK, thanks for the quick response! I'll close this and stop tracking it as a security issue.
Group: firefox-core-security
Status: UNCONFIRMED → RESOLVED
Closed: 8 years ago
Resolution: --- → INVALID
You need to log in
before you can comment on or make changes to this bug.
Description
•