DownloadHelper.js in Firefox for iOS leaks cross-origin download URLs
Categories
(Firefox for iOS :: General, defect, P4)
Tracking
()
People
(Reporter: sdna.muneaki.nishimura, Unassigned, NeedInfo)
References
()
Details
(Keywords: csectype-sop, reporter-external, sec-moderate, Whiteboard: [reporter-external] [client-bounty-form] [verif?])
Attachments
(1 file)
|
703.12 KB,
image/gif
|
Details |
DownloadHelper.js is a javascript used for downloading content of blob: URLs in web pages.
When downloading a blob: URL, this handler is executed in WKWebView and the handler gets the corresponding content of given blob: URL.
The handler is executed regardless of frames. If a blob: URL is downloaded in a subframe of a page then the handler in the parent window is called.
This behavior can be abused for stealing downloaded URLs in cross-origin subframes.
Actual attack is that the handler uses startsWith function of a page.
https://github.com/mozilla-mobile/firefox-ios/blob/ca2f5c98dd25b8f3026b2bd976450edff1853172/Client/Frontend/UserContent/UserScripts/AllFrames/AtDocumentStart/DownloadHelper.js#L30
So if a parent window manipulates startsWith in a page, download contents in cross-origin subframes are stolen.
The PoC of the attack is below.
http://csrf.jp/2020/download_handler_injection_cross_origin_data_leakage2.html
The attached animated GIF file also shows the attack.
Updated•5 years ago
|
Comment 1•5 years ago
|
||
violating the same-origin policy is horrible, but as a practical attack seems limited. what site uses blob: urls for downloads and why would users trust some random framed content on your site more than what you could do directly?
Updated•5 years ago
|
Tracking in JIRA for priority with https://mozilla-hub.atlassian.net/browse/FXIOS-4598
Comment 3•2 years ago
|
||
Hello, I'm an iOS developer considering giving this a try to fix. I'm trying to understand how the exploit works. Is the error still applicable?
| Reporter | ||
Comment 4•2 years ago
|
||
Thank you for your response.
This bug is no longer reproduced today because, during the past two years, relevant processing of DownloadHelper has been moved to the default content world, which separates the JavaScript context from the website's context.
https://github.com/mozilla-mobile/firefox-ios/blob/main/firefox-ios/Client/Frontend/Browser/OpenInHelper/DownloadHelper.swift#L68
The reason for this bug previously was that Firefox iOS injected the following JavaScript code into the parent window when downloading blob: data.
https://github.com/mozilla-mobile/firefox-ios/blob/main/firefox-ios/Client/Frontend/UserContent/UserScripts/AllFrames/AtDocumentStart/DownloadHelper.js#L8
By abusing this, it was possible to steal the URL of the blob: data downloaded in the subframe by tampering with startsWith method called internally by the JavaScript (see below).
https://github.com/mozilla-mobile/firefox-ios/blob/main/firefox-ios/Client/Frontend/UserContent/UserScripts/AllFrames/AtDocumentStart/DownloadHelper.js#L30
Currently, this JavaScript execution space is separated from website, so tampering with the startsWith method on the website doesn't affect DownloadHelper.
Comment 5•2 years ago
|
||
Thank you for the response! Tagging Andrei and Andy for visibility
Updated•2 years ago
|
Updated•2 years ago
|
It sounds like this is no longer reproducible but if anyone believes there are any remaining issues here which are still a concern please let me know. Thank you
Updated•2 years ago
|
Updated•1 year ago
|
Description
•