The default bug view has changed. See this FAQ.
Bug 848535 (CVE-2013-1694)

Use of PreserveWrapper in cases when we don't have a wrapper seems broken

RESOLVED FIXED in Firefox 22

Status

()

Core
DOM
RESOLVED FIXED
4 years ago
2 years ago

People

(Reporter: bz, Assigned: smaug)

Tracking

({sec-high})

unspecified
mozilla24
x86
Mac OS X
sec-high
Points:
---
Bug Flags:
in-testsuite ?

Firefox Tracking Flags

(firefox20 wontfix, firefox21 wontfix, firefox22+ fixed, firefox23+ fixed, firefox24 fixed, firefox-esr1722+ fixed, b2g1822+ fixed, b2g18-v1.0.0 wontfix, b2g18-v1.0.1 wontfix)

Details

(Whiteboard: [qa-][adv-main22+][adv-esr1707+])

Attachments

(2 attachments, 1 obsolete attachment)

Consider the following scenario:

1)  XHR starts.
2)  Its wrapper, if any, is collected.
3)  A C++ readystatechange listener calls GetResponse, and the response type is
    JSON or arraybuffer.  This causes nsXMLHttpRequest::RootJSResultObjects to be
    called, which calls PreserveWrapper.
4)  JS touches the XHR object, causing it to be wrapped, which calls
    nsWrapperCache::SetWrapper().

In a debug build this will assert fatally. In an opt build this will clear the preserved-wrapper flag on the wrapper cache, which seems bad.

Should we just preserve that flag on SetWrapper and remove the assert in that method, perhaps?  Alternately, we should stop using PreserveWrapper to mean "hold JS objects" in XHR.

Note that the above scenario is pretty simple to produce with a worker XHR if extension JS can ever touch the main-thread nsXMLHttpRequest of it, as far as I can tell.
nsDOMFileReader is possibly similarly broken.
Sounds kind of bad.  Feel free to adjust as needed.
Keywords: sec-high
May not get to this before next week.
Assignee: nobody → bugs
Created attachment 746645 [details] [diff] [review]
patch

This should do it. Technically drop in unlink isn't absolutely needed, but
we do drop preserved wrapper there too if there is such (in nsDOMEventTargetHelper). These aren't super perf critical so extra drop isn't too bad.
Attachment #746645 - Flags: review?(continuation)
But then, drop in unlink is rather useless... I'll remove it
Created attachment 746648 [details] [diff] [review]
patch
Attachment #746645 - Attachment is obsolete: true
Attachment #746645 - Flags: review?(continuation)
Attachment #746648 - Flags: review?(continuation)
Attachment #746648 - Flags: review?(continuation) → review+
Comment on attachment 746648 [details] [diff] [review]
patch

[Security approval request comment]
How easily could an exploit be constructed based on the patch?
As of now we don't know any exploit, but I don't think constructing one is too difficult.

Do comments in the patch, the check-in comment, or tests included in the patch paint a bulls-eye on the security problem?
commit will be about simpler js object holding

Which older supported branches are affected by this flaw?
all

Do you have backports for the affected branches? If not, how different, hard to create, and risky will they be?
backports should be almost the same

How likely is this patch to cause regressions; how much testing does it need?
Should be relatively safe
Attachment #746648 - Flags: sec-approval?
sec-approval+ for m-c on 5/14 after we branch and ship. Please prepare and nominate branch patches as well.
status-firefox20: --- → affected
status-firefox21: --- → affected
status-firefox22: --- → affected
status-firefox23: --- → affected
status-firefox-esr17: --- → affected
tracking-firefox22: --- → +
tracking-firefox23: --- → +
tracking-firefox-esr17: --- → +
Whiteboard: [checkin after 5/14]
Attachment #746648 - Flags: sec-approval? → sec-approval+
https://hg.mozilla.org/integration/mozilla-inbound/rev/21356b1fc017
https://hg.mozilla.org/mozilla-central/rev/21356b1fc017
Status: NEW → RESOLVED
Last Resolved: 4 years ago
status-b2g18: --- → ?
status-b2g18-v1.0.1: --- → ?
status-firefox20: affected → wontfix
status-firefox24: --- → fixed
Flags: in-testsuite?
Resolution: --- → FIXED
Target Milestone: --- → mozilla24
Whiteboard: [checkin after 5/14]
Ready for uplift noms?
Flags: needinfo?(bugs)
Preparing patches ....
Flags: needinfo?(bugs)
Created attachment 752297 [details] [diff] [review]
for branches

This patch seems to apply to branches. esr17 needs --fuzz=4


[Approval Request Comment]
Bug caused by (feature/regressing bug #): Something ancient
User impact if declined: Possible GC/CC related crashes
Testing completed (on m-c, etc.): landed to m-c 2013-05-15
Risk to taking this patch (and alternatives if risky): Shouldn't be risky
String or IDL/UUID changes made by this patch: NA
Attachment #752297 - Flags: approval-mozilla-esr17?
Attachment #752297 - Flags: approval-mozilla-beta?
Attachment #752297 - Flags: approval-mozilla-b2g18?
Attachment #752297 - Flags: approval-mozilla-aurora?
Comment on attachment 752297 [details] [diff] [review]
for branches

approving for desktop branches, holding off on b2g18 until we know if this needs to be uplifted to v1.0.1 - since it's only sec-high, I suspect it does not but will wait for confirmation.
Attachment #752297 - Flags: approval-mozilla-esr17?
Attachment #752297 - Flags: approval-mozilla-esr17+
Attachment #752297 - Flags: approval-mozilla-beta?
Attachment #752297 - Flags: approval-mozilla-beta+
Attachment #752297 - Flags: approval-mozilla-aurora?
Attachment #752297 - Flags: approval-mozilla-aurora+
tracking-firefox-esr17: + → 22+
https://hg.mozilla.org/releases/mozilla-aurora/rev/c43520eb66d0
https://hg.mozilla.org/releases/mozilla-beta/rev/6c0015af8603
https://hg.mozilla.org/releases/mozilla-esr17/rev/7298d758e1fa
status-firefox21: affected → wontfix
status-firefox22: affected → fixed
status-firefox23: affected → fixed
status-firefox-esr17: affected → fixed

Updated

4 years ago
status-b2g18: ? → affected
status-b2g18-v1.0.1: ? → wontfix
tracking-b2g18: --- → 22+

Updated

4 years ago
Attachment #752297 - Flags: approval-mozilla-b2g18? → approval-mozilla-b2g18+
https://hg.mozilla.org/releases/mozilla-b2g18/rev/8d224b154448
status-b2g18: affected → fixed
status-b2g18-v1.0.0: --- → wontfix
Based on the steps in comment 0 and the lack of an existing test case, we're going to mark this qa- for verification purposes. If that changes, remove qa- and/or let us know how we could otherwise verify fixed. Thanks.
Whiteboard: [qa-]
Whiteboard: [qa-] → [qa-][adv-main22+][adv-esr1707+]
Alias: CVE-2013-1694
Group: core-security
You need to log in before you can comment on or make changes to this bug.