"Firefox Screenshots" functionality can be tricked into injecting trusted UI into an untrusted frame
The Firefox Screenshots extension injected its trusted UI into a frame without verifying the frame's URL, allowing a page to load about:blank and manipulate the UI. An attacker could trick a user into clicking a transparent button to save a screenshot and overwrite the clipboard.
Originally disclosed on Mozilla
- Fixed in 11 days
- Paid in 18 days
- Disclosed after 11 days
Created attachment 8886122
Proof of concept
The Firefox Screenshots feature injects its user interface into the pages. The general approach is correct: the feature's user interface is separated from the page content via a moz-extension://.../blank.html frame that the page cannot access. However, the extension will not check the frame's URL, so the page can load about:blank into the frame and the same trusted user interface will be injected. This allows the page to automate the user interface, only limited by the few event.isTrusted checks in the code.
Steps to reproduce:
1. Make sure to use "Firefox Screenshots" feature at least once, so that the tour no longer appears. The proof of concept might still work with the tour appearing but I didn't test it in this scenario.
2. Open the attached proof of concept page.
3. Right-click the page, choose "Take a Screenshot" from the context menu.
4. Wait a second, then click anywhere on the page.
Expected results:
The screenshot UI doesn't appear (no way to prevent the page from hiding the frames) but the click doesn't have any effect either.
Actual results:
In Firefox 56.0a1 nightly (2017-07-12), clicking the page saves the screenshot to "My Shots", opens a new tab for it and displays a message about the contents of my clipboard being overwritten. This is because the page replace frame URLs by about:blank which allowed it to manipulate the contents - trigger the necessary event handlers to select a part of the page, then change the "Save" button occupy the entire page while staying transparent (performing the same manipulation with the "Download" button would have been possible as well). It still needs the user to click it however (not a high hurdle) because the button's click handler will check event.isTrusted and reject generated events.
Recommendations:
In extension's webextension/selector/ui.js, the onload event handlers defined by iframeSelection.display() and iframePreSelection.display() should check that this.element.contentDocument.URL is still browser.extension.getURL("blank.html") - this handler shouldn't initialize documents with unexpected URLs. Also, it should be a good idea to make sure that this handler runs only once per frame (remove after it is triggered for the first time). Finally, defense in the depth should be consistent - no event handlers should accept untrusted events.
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
The extension did not verify that the frame's URL was still its own blank.html before injecting the UI, allowing the page to substitute about:blank.
Impact
The page could automate the screenshot UI to save a screenshot to 'My Shots', open a new tab, and overwrite the clipboard, but required a user click because event.isTrusted checks rejected generated events.
What the attacker needed
Firefox with Screenshots used at least once; victim visits a malicious page; victim right-clicks and chooses Take a Screenshot; victim clicks anywhere on the page
The fix
The onload handlers should check that the frame's contentDocument.URL is still the extension's blank.html, run only once per frame, and consistently reject untrusted events.
How it was found
- Use Firefox Screenshots at least once so the tour no longer appears.
- Open the proof of concept page.
- Right-click the page and choose 'Take a Screenshot'.
- Wait a second, then click anywhere on the page.
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.
Firefox Screenshots adds a special interface to web pages so you can capture them. The extension trusted any frame it found, even if the page had replaced it with a blank one. A malicious page could then control that interface and make you click a hidden button that saves a screenshot and changes your clipboard.
What is UI spoofing?
The interface lies to the user: a framed page catches their clicks, or a browser shows the wrong address or a fake prompt. Paid when it leads to a sensitive action or convincing phishing.