Can trick layout history into filling <input type=file> with text from <input type=text> using key collision

VERIFIED FIXED in mozilla1.0.1

Status

()

Core
Security
--
major
VERIFIED FIXED
15 years ago
4 years ago

People

(Reporter: Jesse Ruderman, Assigned: John Keiser (jkeiser))

Tracking

({csectype-disclosure, sec-high})

Trunk
mozilla1.0.1
x86
Windows 2000
csectype-disclosure, sec-high
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: [adt2 RTM] [FIX])

Attachments

(3 attachments, 2 obsolete attachments)

(Reporter)

Description

15 years ago
Layout history uses keys that look like this to refill forms in session history:
Tagname>InputName>InputType>FormName>IndexInForm

InputName and FormName can contain the > character, so it is possible to trick
layout history into filling the contents of a text field into a file-upload
field.  This allows an attacker to upload a file if he knows its filename.
(Reporter)

Comment 1

15 years ago
Created attachment 95035 [details]
lame demo

I'm working on a better demo.
(Reporter)

Updated

15 years ago
Keywords: adt1.0.1, nsbeta1
(Reporter)

Comment 2

15 years ago
Created attachment 95055 [details]
better demo: uploads c:\test.txt

Thanks to jesus_X and grok for writing the server side of this demo.
Attachment #95035 - Attachment is obsolete: true
(Assignee)

Comment 3

15 years ago
Created attachment 95073 [details] [diff] [review]
Patch

This fixes the problem by putting all developer-controlled elements *after*
non-developer-controlled elements like type in the key.  Because the key is
used only to match, if the first part (containing the type) does not match the
entire key cannot match.  And since none of the things inserted can be
controlled directly by the developer, there is no chance of messing up that
crucial part. 

This has been tested against http://www.johnkeiser.com/cgi-bin/mozform.pl (to
ensure no regressions), Bugzilla bug entry and attachment pages, and the
enclosed testcase.
(Assignee)

Comment 4

15 years ago
Created attachment 95074 [details] [diff] [review]
Patch -u

Universal diff of previous patch.
Attachment #95073 - Attachment is obsolete: true
(Assignee)

Comment 5

15 years ago
sicking, bz, reviews?
(Assignee)

Updated

15 years ago
Status: NEW → ASSIGNED
Whiteboard: [FIX]
Comment on attachment 95074 [details] [diff] [review]
Patch -u

sr=bzbarsky
Attachment #95074 - Flags: superreview+
Comment on attachment 95074 [details] [diff] [review]
Patch -u

r=sicking
Attachment #95074 - Flags: superreview+ → review+
It might be worth adding some comment to make sure that noone changes this
again. IE something about that author-data should be last so that it can't
tamper with the type.
(Assignee)

Comment 9

15 years ago
I actually considered that but figured people watching the checkin would notice;
it would be nice to make this checkin seem as benign as humanly possible given
the horrifying scope of the exploit.

Comment 10

15 years ago
Marking as ADT2 RTM, until we can discuss the severity and discoverability of
this one with jesse and mitch.
Blocks: 143047
Keywords: nsbeta1 → nsbeta1+
Whiteboard: [FIX] → [adt2 RTM] [FIX]
Target Milestone: --- → mozilla1.0.1
(Assignee)

Comment 11

15 years ago
Fix checked in to trunk.  Leaving open until we decide what else to do with it.
(Assignee)

Comment 12

15 years ago
Comment on attachment 95074 [details] [diff] [review]
Patch -u

a=asa for 1.0.x (asa gave approval just now)
Attachment #95074 - Flags: superreview+
Attachment #95074 - Flags: approval+
(Assignee)

Updated

15 years ago
Keywords: mozilla1.0.1+
(Assignee)

Comment 13

15 years ago
Checked in on 1.1 branch.
(Assignee)

Comment 14

15 years ago
Created attachment 95199 [details]
Linux-friendly testcase

Comment 15

15 years ago
Tested on Linux with the following:

1. Netscape 7.0 PR1
2. Patch build based on 8/13 trunk build

Using the testcase created in comment 14, clicked on the button 'Make me upload
/etc/passwd'.

Results:
In Netscape 7.0PR1 contents of file were returned.
With patch build, contents of file were NOT returned.

Comment 16

15 years ago
adding adt1.0.1+.  Please check this in tonight.
Keywords: adt1.0.1 → adt1.0.1+

Comment 17

15 years ago
jkeiser: Did we not check this into the 1.0 branch? Ia sk because there is no
"fixed1.0.1" marking in the keywords, nor did I see a comment saying this was
checked into the 1.0 branch, after Scott provided ADT approval. Pls advise ...

Comment 18

15 years ago
According to bonsai, this was checked in last night, so marking fixed1.0.1
Keywords: fixed1.0.1
(Assignee)

Comment 19

15 years ago
Yes, sorry, things got hectic last night.  It should be in this morning's builds.

This is all the builds I am concerned with, resolving fixed.

We need to notify the embedders we know about so that they can pick up this fix.
Status: ASSIGNED → RESOLVED
Last Resolved: 15 years ago
Resolution: --- → FIXED

Comment 20

15 years ago
bsharma: bindu, pls verify this as fixed on the 1.0 branch and the trunk.

Comment 21

15 years ago
Verified on 2002-08-14-trunk build on Win 2000.

Loaded test cases in comment #1, #2, #3.

All of them give either error or exception in the JS console.
Status: RESOLVED → VERIFIED

Comment 22

15 years ago
Verified on 2002-08-15-branch build on Win 2000.

Loaded comment #1, #2 and #3 and all of them gave the appropriate error messages.
Keywords: fixed1.0.1 → verified1.0.1
Group: security?
Group: security?
Group: security
(Reporter)

Updated

4 years ago
Keywords: csec-disclosure, sec-high
You need to log in before you can comment on or make changes to this bug.