requestPointerLock Race Condition Allow Set pointerLock to Any window.open URL (with MouseEvent still pass to script origin)
A race condition in Firefox's pointer lock handling let a page call requestPointerLock() and window.open() in quick succession so that the lock was applied to the newly opened tab instead of the original page. The original page kept receiving mouse events, so it could read the victim's mouse movement and clicks while they were on the other tab, and could even trigger a file picker that appeared to come from that tab.
Originally disclosed on Mozilla
- Fixed in 20 days
- Paid in 27 days
- Disclosed after 20 days
Created attachment 9205131 pointerlock+inputfile.html
When using setTimeout to adjust strict timing to call requestPointerLock() and window.open(URL) surprisingly the pointerLock will applied to the new window URL.
After pointer is set to locked state, the MouseEvent still pass to website that trigger the pointerlock, thus allow the script origin to listen user MouseEvent movement data (including mousemove, mousedown, mouseup, click, and wheel) while user on another tab.
Interestingly I found when change pointerLock element to e.g. <input type="file"> or <select><options> and etc. (I'm still explore to find interesting HTML element), the mouse click event will redirected to the element, so it also possible to trick user that the dialog was initiated by the current tab page.
In the attached testcase I'm using <input type="file"> element to demonstrate to trick the user that upload file dialog was initiated by the current tab page.
Version Tested:
- Firefox Nightly 88.0a1 (2021-02-24) (64-bit)
- Firefox Release 86.0 (64-bit)
Steps to Reproduce:
- Visit attached pointerlock+inputfile.html
- Click "Visit VT to Upload File" button
- VirusTotal page is opened on new tab with pointer set to lock state (If VirusTotal tab immediately closed click again until success) (works most of the time on Windows 10, but on Linux may need to click for 2-5 times)
- Click "Choose file" button on VirusTotal page or click any on the page
- File upload dialog is open (as initiated by VirusTotal page)
- Select any file then the file is submitted to script origin page
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 a race condition: the pointer lock request and the window.open() call were processed in an order that let the lock attach to the new window while event routing stayed with the original document.
What the attacker needed
Victim uses Firefox; victim clicks a button on the attacker page; timing race must succeed (retries may be needed)
How it was found
- Open the attached test page in Firefox.
- Click the button that opens the other site in a new tab.
- The new tab opens with the pointer already locked (may need retries).
- Click anywhere on the new tab, for example its file-choose button.
- A file picker opens as if the new tab started it.
- Choosing a file sends it to the original page's origin.
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.
Pointer lock is a browser feature that hides the mouse cursor and sends mouse movement to a web page, normally only after the user agrees. Here, by opening a new tab at almost the same moment as asking for the lock, the page could get the lock applied to the wrong tab. The page that asked for the lock then kept seeing the user's mouse activity even while the user was looking at a different site.
What is Race condition?
Parallel requests reach a state the code assumed could not happen: a coupon used twice, a limit overrun, a check skipped.