Closed Bug 411080 Opened 14 years ago Closed 14 years ago
File upload input focus stealing: any "tab" keydown events can be used to set focus in file input element
4.00 KB, text/html
14.51 KB, application/java-archive
14.65 KB, application/java-archive
User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:22.214.171.124) Gecko/20071127 Firefox/126.96.36.199 Build Identifier: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:188.8.131.52) Gecko/20071127 Firefox/184.108.40.206 By examining keydown events for the tab key, focus can be set in the file input text entry field. When a tab keydown event is detected, the focus is set to another element. Then, when the keypress event is fired, the browser will interpret the tab key and move the focus. By specially choosing the element to set the focus on, the tab key will move the focus to file input element. For example, if a tab keydown event is detected, the element is chosen such that the next element in the tab cycle is the file input. If a shift+tab is detected, a slightly different approach is required. The element is chosen so the file input precedes it in the tab cycle, but depending on the operating system focus may end up on the file picker button instead. To compensate, instead of targeting a file input element, a label associated with the file is used instead. Then when focus is set on the label, it is transfered to the file input element. Although requiring additional user interaction initially, once the focus is set on the file element, any entered keystrokes can be selectively captured and potentially used to upload arbitrary files from the user. Reproducible: Always
Once a tab is detected, the example attempts to disable mousedown events and ignore tabs. Depending on the operating system, this may or may not work. Use the reset button to reset the form. Example tested with user agents: - Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:220.127.116.11) Gecko/20071127 Firefox/18.104.22.168 - Mozilla/5.0 (X11; U; Linux i686 (x86_64); en-US; rv:22.214.171.124) Gecko/20071127 Firefox/126.96.36.199 - Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:188.8.131.52) Gecko/20071127 Firefox/184.108.40.206 - Mozilla/5.0 (X11; U; Linux i686 (x86_64); en-US; rv:220.127.116.11pre) Gecko/20080106 BonEcho/18.104.22.168pre - Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:22.214.171.124pre) Gecko/20080106 BonEcho/126.96.36.199pre
Assignee: nobody → dveditz
Product: Firefox → Core
QA Contact: firefox → toolkit
Status: UNCONFIRMED → NEW
Ever confirmed: true
Flags: blocking188.8.131.52? → blocking184.108.40.206+
Attachment #295721 - Attachment mime type: application/zip → application/java-archive
On all of these it's easier to tell the difference of when you're really focused in a form field and when the real focus is in the hidden file upload control if you set the pref "browser.display.use_focus_colors" to true. You can also use Firebug, DOMI or other tools to bring the file upload control back onto the page.
Assignee: dveditz → Olli.Pettay
The fix in bug 413135 makes this attack ineffective on branch; trunk not affected.
Status: NEW → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
Updated the example attack to use the disabled property to selectively cancel keystrokes. This bypasses the fix for bug 413135 in attachment 298006 [details] [diff] [review].
I have verified that with Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:220.127.116.11) Gecko/2008012822 Firefox/18.104.22.168, the updated attack from Gregory still exploits the browser. As noted in one of the related bugs, the demo should be updated to take keyboard tabbing into account. It works otherwise though.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
My bad. The test cause is counterintuitive. Olli and I just conferred and this is fixed. Re-resolving and verifying.
Status: REOPENED → RESOLVED
Closed: 14 years ago → 14 years ago
Resolution: --- → FIXED
That is, the test case. *sigh*
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.