Closed Bug 405299 Opened 18 years ago Closed 18 years ago

Firefox file input focus stealing through label element dispatch mouse click event

Categories

(Core :: Layout: Form Controls, defect)

1.8 Branch
defect
Not set
normal

Tracking

()

VERIFIED FIXED

People

(Reporter: yathong, Assigned: smaug)

References

()

Details

(Keywords: fixed1.8.0.15, testcase, verified1.8.1.12, Whiteboard: [sg:moderate])

Attachments

(2 files)

User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; zh-TW; rv:1.8.1.9) Gecko/20071025 Firefox/2.0.0.9 Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.0; zh-TW; rv:1.8.1.9) Gecko/20071025 Firefox/2.0.0.9 Focus change allowed between onKeyDown and onKeyPress, allowing attacker to read arbitary files. This is similar to bug 388784, but it is using label to dispatch mouse click event to change focus to textfield of file input object. I verified this with Firefox 2.0.0.9 Reproducible: Always Steps to Reproduce: 1. 2. 3.
Attached file Proof of concept
This is a duplicate of bug 404451.
Not quite. This bug doesn't rely on a user click to focus the wrong control; it actually focuses the file by focusing the label, then puts the focus back. I thought we'd prevented that with the label changes on branch.... The fix for bug 404451 might fix this, of course.
Status: UNCONFIRMED → NEW
Depends on: 404451
Ever confirmed: true
Taking. I have patch for this but it doesn't yet fix bug 404451.
Assignee: nobody → Olli.Pettay
Flags: blocking1.8.1.12?
Attached patch possible patchSplinter Review
I can't think of any solution which wouldn't change the behavior a bit. The patch makes it so that clicking something in <label> has similar behavior as calling label.focus(), meaning that input element is handled in a special way. To keep changes in behavior as small as possible, ::SetFocus is modified to check only type="file", not all input elements. Although this is a small patch, I'd like to get 2 separate reviews for this. Just in case someone comes up with some better solution.
Attachment #290682 - Flags: review?(jst)
Comment on attachment 290682 [details] [diff] [review] possible patch Looks reasonable to me. Do we need something similar for trunk too? r=jst, it'd probably be good if bz could look at this as well.
Attachment #290682 - Flags: review?(jst) → review+
Comment on attachment 290682 [details] [diff] [review] possible patch On trunk <input type="file"> works in a different way. There typing to the textfield isn't possible.
Attachment #290682 - Flags: superreview?(bzbarsky)
Attachment #290682 - Flags: superreview?(bzbarsky) → superreview+
Attachment #290682 - Flags: approval1.8.1.12?
Flags: blocking1.8.1.12? → blocking1.8.1.12+
Whiteboard: [sg:high]
Keywords: testcase
OS: Windows 2000 → All
Hardware: PC → All
Version: unspecified → 1.8 Branch
Comment on attachment 290682 [details] [diff] [review] possible patch approved for 1.8.1.12, a=dveditz for release-drivers
Attachment #290682 - Flags: approval1.8.1.12? → approval1.8.1.12+
Flags: wanted1.8.1.x+
Blocks: 404451
No longer depends on: 404451
Blocks: 404391
Keywords: fixed1.8.1.12
Status: NEW → RESOLVED
Closed: 18 years ago
Resolution: --- → FIXED
Flags: in-testsuite?
Whiteboard: [sg:high] → [sg:moderate]
Verified for branch with Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.12pre) Gecko/2008011803 BonEcho/2.0.0.12pre and Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.12pre) Gecko/2008011803 BonEcho/2.0.0.12pre.
Status: RESOLVED → VERIFIED
Group: security
distro patches block 1.8.0.15
Flags: blocking1.8.0.15+
Comment on attachment 290682 [details] [diff] [review] possible patch a=asac for 1.8.0.15 approving unmodified distro patch.
Attachment #290682 - Flags: approval1.8.0.15+
MOZILLA_1_8_0_BRANCH: Checking in content/html/content/src/nsHTMLLabelElement.cpp; /cvsroot/mozilla/content/html/content/src/nsHTMLLabelElement.cpp,v <-- nsHTMLLabelElement.cpp new revision: 1.87.6.1.2.2; previous revision: 1.87.6.1.2.1 done
Keywords: fixed1.8.0.15
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: