Bug 1054359 (CVE-2014-1562)

LCallDOMNative incorrectly assumes |this| is always an object

VERIFIED FIXED in Firefox 32, Firefox OS v1.3

Status

()

Core
JavaScript Engine: JIT
VERIFIED FIXED
3 years ago
2 years ago

People

(Reporter: jandem, Assigned: jandem)

Tracking

({sec-critical, topcrash})

unspecified
mozilla34
sec-critical, topcrash
Points:
---

Firefox Tracking Flags

(firefox31 wontfix, firefox32+ verified, firefox33+ verified, firefox34+ verified, firefox-esr2432+ verified, firefox-esr3132+ verified, b2g-v1.3 fixed, b2g-v1.3T fixed, b2g-v1.4 fixed, b2g-v2.0 fixed, b2g-v2.1 fixed)

Details

(Whiteboard: [adv-main32+][adv-esr31.1+][adv-esr24.8+])

Attachments

(3 attachments)

(Assignee)

Description

3 years ago
Created attachment 8473747 [details]
Testcase

I was looking at crash URLs for JIT crashes on crash-stats, and was able to reproduce a crash in JIT code on manpower.com

The problem is that CodeGenerator::visitCallDOMNative does:

    Register obj = masm.extractObject(Address(StackPointer, 0), argObj);

But |this| is not guaranteed to be an object. So if you do something like:

    var method = document.body.mozMatchesSelector;
    method.call(v, "selector");

And v is an integer, we'll treat it as an object pointer and this allows an attacker to do all kinds of scary things.

The attached testcase crashes Nightly for me on OS X, 32-bit (you may have to turn off off-thread compilation first).
(Assignee)

Updated

3 years ago
Keywords: topcrash
(Assignee)

Comment 1

3 years ago
Created attachment 8473754 [details] [diff] [review]
Patch

Having isDOMClass/getKnownClass/getTypedArrayType return |true| even if the value can be primitive is a footgun. I think we should consider changing that, but here's the safe and simple fix: only optimize DOM method calls if |this| is guaranteed to be an object.
Assignee: nobody → jdemooij
Status: NEW → ASSIGNED
Attachment #8473754 - Flags: review?(efaustbmo)
(Assignee)

Updated

3 years ago
status-firefox31: --- → affected
status-firefox32: --- → affected
status-firefox33: --- → affected
status-firefox34: --- → affected
status-firefox-esr31: --- → affected
tracking-firefox32: --- → ?
tracking-firefox33: --- → ?
tracking-firefox34: --- → ?
tracking-firefox-esr31: --- → ?
We're running out of time for beta 32. I'd like to see whether we can get this into beta8, which goes to build on Mon, Aug 18.
tracking-firefox32: ? → +
tracking-firefox33: ? → +
tracking-firefox34: ? → +

Comment 3

3 years ago
Comment on attachment 8473754 [details] [diff] [review]
Patch

Review of attachment 8473754 [details] [diff] [review]:
-----------------------------------------------------------------

This is a phenomenal catch. r=me for now, for uplift. Can you file a followup to deal with the footguns you mention?
Attachment #8473754 - Flags: review?(efaustbmo) → review-
(Assignee)

Comment 4

3 years ago
Comment on attachment 8473754 [details] [diff] [review]
Patch

(This is causing topcrashes so it'd be great if we could get this on beta.)

[Security approval request comment]
> How easily could an exploit be constructed based on the patch?
Not trivial but also not hard for somebody who knows what he/she's doing.

> Do comments in the patch, the check-in comment, or tests included in the patch paint a bulls-eye on the security problem?
No.

> 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?
Should be very easy.

> How likely is this patch to cause regressions; how much testing does it need?
Unlikely; it just adds an extra check to guard an optimization.
Attachment #8473754 - Flags: sec-approval?

Comment 5

3 years ago
Comment on attachment 8473754 [details] [diff] [review]
Patch

No, the one with two little lines. (meant r+ initially, obviously)
Attachment #8473754 - Flags: review- → review+
status-firefox31: affected → wontfix
status-firefox-esr24: --- → ?
tracking-firefox-esr31: ? → 32+
Comment on attachment 8473754 [details] [diff] [review]
Patch

sec-approval+ for trunk. Assuming it goes in clean, please have beta and aurora patches made and nominated so we can approve them ASAP.
Attachment #8473754 - Flags: sec-approval? → sec-approval+
(Assignee)

Comment 7

3 years ago
https://hg.mozilla.org/integration/mozilla-inbound/rev/f6cdb000f3d8
(Assignee)

Comment 8

3 years ago
Comment on attachment 8473754 [details] [diff] [review]
Patch

Approval Request Comment
[Feature/regressing bug #]: Older Ion bug
[User impact if declined]: Topcrash, security bugs
[Describe test coverage new/current, TBPL]: Code should be tested on TBPL, very simple patch.
[Risks and why]: Very low; small/simple patch.
[String/UUID change made/needed]: None.
Attachment #8473754 - Flags: approval-mozilla-beta?
Attachment #8473754 - Flags: approval-mozilla-aurora?
Comment on attachment 8473754 [details] [diff] [review]
Patch

I'm approving for beta before this hits m-c as I want to take this in beta8 today. I don't expect a backout. If necessary, we'll deal with a build2.
Attachment #8473754 - Flags: approval-mozilla-beta?
Attachment #8473754 - Flags: approval-mozilla-beta+
Attachment #8473754 - Flags: approval-mozilla-aurora?
Attachment #8473754 - Flags: approval-mozilla-aurora+
https://hg.mozilla.org/releases/mozilla-aurora/rev/b0b59289683f
https://hg.mozilla.org/releases/mozilla-beta/rev/f5bfa8f3434c

Looks like we need esr31 and esr24 (if affected) noms on this as well.
status-b2g-v2.1: --- → fixed
status-firefox32: affected → fixed
status-firefox33: affected → fixed
status-firefox34: affected → fixed
Flags: needinfo?(jdemooij)
(Assignee)

Comment 11

3 years ago
Comment on attachment 8473754 [details] [diff] [review]
Patch

[Approval Request Comment]
User impact if declined: Security bugs, topcrashes.
Fix Landed on Version: 34, backported to 32/33.
Risk to taking this patch (and alternatives if risky): None-Low.
String or UUID changes made by this patch: None.
Attachment #8473754 - Flags: approval-mozilla-esr31?
(Assignee)

Comment 12

3 years ago
Created attachment 8474692 [details] [diff] [review]
Patch for ESR24

[Approval Request Comment]
User impact if declined: Security bugs, topcrashes.
Fix Landed on Version: 34, backported to 32/33
Risk to taking this patch (and alternatives if risky): None-Low.
String or UUID changes made by this patch: None.

See https://wiki.mozilla.org/Release_Management/ESR_Landing_Process for more info.
Attachment #8474692 - Flags: review+
Attachment #8474692 - Flags: approval-mozilla-esr24?
(Assignee)

Updated

3 years ago
Flags: needinfo?(jdemooij)
https://hg.mozilla.org/mozilla-central/rev/f6cdb000f3d8
https://hg.mozilla.org/releases/mozilla-b2g32_v2_0/rev/f5bfa8f3434c
Status: ASSIGNED → RESOLVED
Last Resolved: 3 years ago
status-b2g-v1.3: --- → affected
status-b2g-v1.3T: --- → affected
status-b2g-v1.4: --- → affected
status-b2g-v2.0: --- → fixed
status-firefox-esr24: ? → affected
Resolution: --- → FIXED
Target Milestone: --- → mozilla34
Attachment #8473754 - Flags: approval-mozilla-esr31? → approval-mozilla-esr31+
Attachment #8474692 - Flags: approval-mozilla-esr24? → approval-mozilla-esr24+
https://hg.mozilla.org/releases/mozilla-esr31/rev/bb8c53609400
https://hg.mozilla.org/releases/mozilla-b2g30_v1_4/rev/a2712ce8bf92
https://hg.mozilla.org/releases/mozilla-b2g28_v1_3/rev/709347e7fb78
https://hg.mozilla.org/releases/mozilla-esr24/rev/a2e3f3644944
status-b2g-v1.3: affected → fixed
status-b2g-v1.3T: affected → fixed
status-b2g-v1.4: affected → fixed
status-firefox-esr24: affected → fixed
status-firefox-esr31: affected → fixed
tracking-firefox-esr24: --- → ?
b2g30 needed the esr24 version of the patch:
https://hg.mozilla.org/releases/mozilla-b2g30_v1_4/rev/d8ec0a9650fe
This is akin to bug 951517, which it looks like we didn't fix as well as we should have.  :(

We definitely need a followup to fix isDOMClass here.
(Assignee)

Comment 17

3 years ago
(In reply to Boriz Zbarsky [:bz] from comment #16)
> We definitely need a followup to fix isDOMClass here.

Filed bug 1055768.
tracking-firefox-esr24: ? → 32+
Whiteboard: [adv-main32+][adv-esr31.1+][adv-esr24.8+]
Confirmed crash on Fx34, 2014-08-11.
Verified fixed in Fx32, Fx33 and Fx34, 2014-08-22.
Verified fixed in Fx24.8.0esr, release.
Verified fixed in Fx31.1.0esr, release.
Status: RESOLVED → VERIFIED
status-firefox32: fixed → verified
status-firefox33: fixed → verified
status-firefox34: fixed → verified
status-firefox-esr24: fixed → verified
status-firefox-esr31: fixed → verified
Depends on: 1059456
Alias: CVE-2014-1562
Group: javascript-core-security
Depends on: 1062857

Updated

3 years ago
No longer depends on: 1059456

Updated

2 years ago
Group: core-security → core-security-release
Group: core-security-release
You need to log in before you can comment on or make changes to this bug.