Closed
Bug 590771
(CVE-2010-3766)
Opened 15 years ago
Closed 14 years ago
nsDOMAttribute MutationObserver Remote Code Execution Vulnerability (ZDI-CAN-898)
Categories
(Core :: DOM: Core & HTML, defect)
Core
DOM: Core & HTML
Tracking
()
People
(Reporter: reed, Assigned: mounir)
References
Details
(4 keywords, Whiteboard: [sg:critical?])
Attachments
(5 files)
420 bytes,
text/html
|
Details | |
1.92 KB,
patch
|
sicking
:
review+
|
Details | Diff | Splinter Review |
13.80 KB,
patch
|
sicking
:
review+
dveditz
:
approval1.9.2.13+
dveditz
:
approval1.9.1.16+
|
Details | Diff | Splinter Review |
2.84 KB,
patch
|
sicking
:
review+
|
Details | Diff | Splinter Review |
15.74 KB,
patch
|
sicking
:
review+
|
Details | Diff | Splinter Review |
ZDI-CAN-898: Mozilla Firefox nsDOMAttribute MutationObserver Remote Code Execution Vulnerability
-- CVSS ----------------------------------------------------------------
10, (AV:N/AC:L/Au:N/C:C/I:C/A:C)
-- 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 application's support of an API used
for element traversal. Due to a particular element not implementing
functionality required by the API, a use-after free vulnerability can be
made to occur. This can be used to achieve code execution under the
context of the application.
The issue occurs within the application's support of the NodeIterator
API that is used for DOM Traversal as outlined in the DOM specification
on w3.org.
In order to support the node iteration, the application needs to keep
track of modifications to the dom tree in order to update the state of
the iterator. This is done explicitly by a pair of methods called
AddMutationObserver/RemoveMutationObserver. Anytime an element is
created, the observer list will be updated so that a node iterator can
adjust for modified elements.
When adding an element, it will need to update the MutationObserver list
as in the following code.
content/base/src/nsNodeIterator.cpp:185
nsNodeIterator::nsNodeIterator(nsINode *aRoot,
PRUint32 aWhatToShow,
nsIDOMNodeFilter *aFilter,
PRBool aExpandEntityReferences) :
nsTraversal(aRoot, aWhatToShow, aFilter, aExpandEntityReferences),
mDetached(PR_FALSE),
mPointer(mRoot, PR_TRUE)
{
aRoot->AddMutationObserver(this); // XXX
}
nsNodeIterator::~nsNodeIterator()
{
/* destructor code */
if (!mDetached && mRoot)
mRoot->RemoveMutationObserver(this); // XXX
}
AddMutationObserver/RemoveMutationObserver will add the provided element
to a page-global list that can be queried by the NodeIterator.
content/base/src/nsGenericElement.cpp:295
void
nsINode::AddMutationObserver(nsIMutationObserver* aMutationObserver)
{
nsSlots* slots = GetSlots();
if (slots) {
slots->mMutationObservers.AppendElementUnlessExists(aMutationObserver);
}
}
void
nsINode::RemoveMutationObserver(nsIMutationObserver* aMutationObserver)
{
nsSlots* slots = GetExistingSlots();
if (slots) {
slots->mMutationObservers.RemoveElement(aMutationObserver);
}
}
One element however does not update the mutation list. This is the
nsDOMAttribute and is defined in content/base/src/nsDOMAttribute.cpp.
This will allow someone to manipulate the nsDOMAttribute node without
the nsNodeIterator api being informed. This will bypass the type-safety
of the compiler and can lead to code execution.
Version(s) tested: Mozilla Firefox
Platform(s) tested: Windows XP SP3
-- CREDIT --------------------------------------------------------------
This vulnerability was discovered by:
* regenrecht
Comment 1•15 years ago
|
||
I get a js error on trunk:
Error: uncaught exception: [Exception... "Component returned failure code: 0x80004003 (NS_ERROR_INVALID_POINTER) [nsIDOMAttr.removeChild]" nsresult: "0x80004003 (NS_ERROR_INVALID_POINTER)" location: "JS frame :: https://bug590771.bugzilla.mozilla.org/attachment.cgi?id=469260&t=BcPe7a6cgh :: run :: line 11" data: no]
On Firefox3.6.8, I get an alert saying "[object Text]".
Assignee | ||
Comment 3•14 years ago
|
||
I believe this has been fixed on trunk with bug 540848 with the following changesets:
http://hg.mozilla.org/mozilla-central/rev/068150b06d11
http://hg.mozilla.org/mozilla-central/rev/13571a9165ea
Status: NEW → ASSIGNED
Assignee | ||
Comment 4•14 years ago
|
||
Forget comment 3, this is not related actually.
Very likely, this is fixed on trunk because of a regression of bug 566416. I filed bug 598877 about the regression. Quickly, attributes.firstChild returns null in the test case with the current trunk which is wrong and make the script fail too early.
This bug expected, this is not fixed on trunk apparently.
Assignee | ||
Comment 5•14 years ago
|
||
Attachment #478909 -
Flags: review?(jonas)
Assignee | ||
Comment 6•14 years ago
|
||
Attachment #478910 -
Flags: review?(jonas)
Assignee | ||
Updated•14 years ago
|
Attachment #478910 -
Flags: approval1.9.2.11?
Comment 7•14 years ago
|
||
Comment on attachment 478910 [details] [diff] [review]
Patch for 1.9.1 and 1.9.2 [checked-in]
Please get reviews before asking for branch approval
Attachment #478910 -
Flags: approval1.9.2.11?
Comment 8•14 years ago
|
||
Does this affect 1.9.1? If not, do we know what bug introduced the flaw?
Assignee | ||
Comment 9•14 years ago
|
||
(In reply to comment #8)
> Does this affect 1.9.1? If not, do we know what bug introduced the flaw?
I'm building 1.9.1 to check that.
Asking for 2.0 blocking considering this is affecting the trunk too.
Assignee | ||
Comment 10•14 years ago
|
||
(In reply to comment #8)
> Does this affect 1.9.1? If not, do we know what bug introduced the flaw?
1.9.1 is also affected. The same patch applies and work.
Assignee | ||
Updated•14 years ago
|
Attachment #478909 -
Attachment description: Tests for 1.9.2 → Tests for 1.9.1 and 1.9.2
Assignee | ||
Updated•14 years ago
|
Attachment #478910 -
Attachment description: Patch for 1.9.2 → Patch for 1.9.1 and 1.9.2
Comment 11•14 years ago
|
||
Do we need a different trunk patch after the regression is fixed?
Updated•14 years ago
|
blocking2.0: ? → betaN+
Assignee | ||
Comment 12•14 years ago
|
||
(In reply to comment #11)
> Do we need a different trunk patch after the regression is fixed?
Yes. The code has changed so the current patch will not fix the issue on trunk.
Comment on attachment 478910 [details] [diff] [review]
Patch for 1.9.1 and 1.9.2 [checked-in]
Add a comment to the declaration of AttributeChildRemoved that says that attributes never have more than 1 children and so this is always that one single child that is removed.
>diff --git a/content/base/src/nsNodeIterator.cpp b/content/base/src/nsNodeIterator.cpp
>--- a/content/base/src/nsNodeIterator.cpp
>+++ b/content/base/src/nsNodeIterator.cpp
>@@ -212,17 +212,17 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_END
> NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsNodeIterator)
> NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mRoot)
> NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mFilter)
> NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
>
> // QueryInterface implementation for nsNodeIterator
> NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsNodeIterator)
> NS_INTERFACE_MAP_ENTRY(nsIDOMNodeIterator)
>- NS_INTERFACE_MAP_ENTRY(nsIMutationObserver)
>+ NS_INTERFACE_MAP_ENTRY(nsIMutationObserver2)
> NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMNodeIterator)
> NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(NodeIterator)
> NS_INTERFACE_MAP_END
You need to keep both interfaces in the interface map. We still want QIing to nsIMutationObserver to work.
>+nsNodeUtils::AttributeChildRemoved(nsINode* aAttribute,
>+ nsIContent* aChild)
>+{
>+ NS_PRECONDITION(aAttribute->IsNodeOfType(nsINode::eATTRIBUTE),
>+ "container must be a nsIAttribute");
>+
>+ // This is a variant of IMPL_MUTATION_NOTIFICATION.
Add a comment to IMPL_MUTATION_NOTIFICATION so that if someone modifies that, this code is modified too.
r=me with those changes.
Attachment #478910 -
Flags: review?(jonas) → review+
Attachment #478909 -
Flags: review?(jonas) → review+
Assignee | ||
Comment 14•14 years ago
|
||
Shouldn't this be blocking 1.9.1 too?
Updated•14 years ago
|
blocking1.9.1: ? → needed
Assignee | ||
Updated•14 years ago
|
Attachment #478909 -
Flags: approval1.9.2.11?
Attachment #478909 -
Flags: approval1.9.1.14?
Assignee | ||
Updated•14 years ago
|
Attachment #478910 -
Flags: approval1.9.2.11?
Attachment #478910 -
Flags: approval1.9.1.14?
Assignee | ||
Updated•14 years ago
|
Attachment #478909 -
Flags: approval1.9.2.11?
Attachment #478909 -
Flags: approval1.9.1.14?
Assignee | ||
Updated•14 years ago
|
Attachment #478910 -
Flags: approval1.9.2.11?
Attachment #478910 -
Flags: approval1.9.1.14?
Assignee | ||
Comment 15•14 years ago
|
||
Removing approval requests given that I've been told on IRC that this shouldn't land for this release.
Assignee | ||
Comment 16•14 years ago
|
||
(In reply to comment #15)
> Removing approval requests given that I've been told on IRC that this shouldn't
> land for this release.
1.9.1 and 1.9.2 branches.
Assignee | ||
Comment 17•14 years ago
|
||
Attachment #479331 -
Flags: review?(jonas)
Assignee | ||
Comment 18•14 years ago
|
||
Attachment #479332 -
Flags: review?(jonas)
Assignee | ||
Comment 19•14 years ago
|
||
I actually found a few regressions from bug 566416 and my patch for trunk is built on top of them, so I'm marking them as dependencies.
Attachment #479331 -
Flags: review?(jonas) → review+
Attachment #479332 -
Flags: review?(jonas) → review+
Updated•14 years ago
|
blocking1.9.1: needed → ?
blocking1.9.2: needed → ?
Assignee | ||
Comment 20•14 years ago
|
||
Comment on attachment 479332 [details] [diff] [review]
Patch for trunk [checked-in]
Patch pushed on mozilla-central:
http://hg.mozilla.org/mozilla-central/rev/56403a9ae8b6
Attachment #479332 -
Attachment description: Patch for trunk → Patch for trunk [checked-in]
Should this be marked FIXED?
If not, what remains to do?
Assignee | ||
Comment 22•14 years ago
|
||
Patches should be pushed on branches (according to branch rules, I have to wait a few days before asking for an approval and it's not really urgent). In addition, I think that tests will have to be pushed after branch releases.
Updated•14 years ago
|
blocking1.9.1: ? → .15+
blocking1.9.2: ? → .12+
Assignee | ||
Comment 23•14 years ago
|
||
Pushed in 1.9.1 and 1.9.2:
http://hg.mozilla.org/releases/mozilla-1.9.1/rev/bcfb355e5c2b
http://hg.mozilla.org/releases/mozilla-1.9.2/rev/dc30f8b144a9
I will push all tests after 1.9.1 and 1.9.2 branching.
Assignee | ||
Updated•14 years ago
|
Attachment #478910 -
Attachment description: Patch for 1.9.1 and 1.9.2 → Patch for 1.9.1 and 1.9.2 [checked-in]
Reporter | ||
Comment 24•14 years ago
|
||
Fixed on trunk == RESOLVED FIXED. Branches are tracked separately.
Status: ASSIGNED → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
Reporter | ||
Comment 25•14 years ago
|
||
(In reply to comment #22)
> Patches should be pushed on branches (according to branch rules, I have to wait
> a few days before asking for an approval and it's not really urgent). In
> addition, I think that tests will have to be pushed after branch releases.
(In reply to comment #23)
> Pushed in 1.9.1 and 1.9.2:
> http://hg.mozilla.org/releases/mozilla-1.9.1/rev/bcfb355e5c2b
> http://hg.mozilla.org/releases/mozilla-1.9.2/rev/dc30f8b144a9
What happened to the "asking for an approval" thing? *all* branch patches require approval before landing.
> I will push all tests after 1.9.1 and 1.9.2 branching.
No, wait until after the release has been made before landing tests.
Reporter | ||
Updated•14 years ago
|
Attachment #478910 -
Flags: approval1.9.2.13?
Attachment #478910 -
Flags: approval1.9.1.16?
Assignee | ||
Comment 26•14 years ago
|
||
> (In reply to comment #23)
> > Pushed in 1.9.1 and 1.9.2:
> > http://hg.mozilla.org/releases/mozilla-1.9.1/rev/bcfb355e5c2b
> > http://hg.mozilla.org/releases/mozilla-1.9.2/rev/dc30f8b144a9
>
> What happened to the "asking for an approval" thing? *all* branch patches
> require approval before landing.
It has been marked as 'blocking'. Isn't that enough?
> > I will push all tests after 1.9.1 and 1.9.2 branching.
>
> No, wait until after the release has been made before landing tests.
That's what I meant.
Comment 27•14 years ago
|
||
No, the approval policy for released branches is different than the one for under-development branches. For released branches all patches require approval, regardless of blocking status.
Comment 28•14 years ago
|
||
Note that eventually Firefox 4 will end up in that state -- think of the branches as perpetual "Release Candidate" stage. Rules for each tree are always on their tinderboxen, and they differ. Please check.
Comment 29•14 years ago
|
||
Comment on attachment 478910 [details] [diff] [review]
Patch for 1.9.1 and 1.9.2 [checked-in]
retroactive approval for 1.9.2.13 and 1.9.1.16, a=dveditz for release-drivers
Attachment #478910 -
Flags: approval1.9.2.13?
Attachment #478910 -
Flags: approval1.9.2.13+
Attachment #478910 -
Flags: approval1.9.1.16?
Attachment #478910 -
Flags: approval1.9.1.16+
Updated•14 years ago
|
Alias: ZDI-CAN-898
Reporter | ||
Updated•14 years ago
|
Alias: ZDI-CAN-898
Updated•14 years ago
|
Alias: CVE-2010-3766
Comment 30•14 years ago
|
||
Verified fixed for 1.9.2 with Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.13pre) Gecko/20101117 Namoroka/3.6.13pre and for 1.9.1 with Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.1.16pre) Gecko/20101117 Shiretoko/3.5.16pre using PoC.
Keywords: verified1.9.1,
verified1.9.2
Assignee | ||
Comment 31•14 years ago
|
||
Tests pushed on trunk:
http://hg.mozilla.org/mozilla-central/rev/be885fbb66c2
Assignee | ||
Comment 32•14 years ago
|
||
Tests pushed in 1.9.1 and 1.9.2 branches:
http://hg.mozilla.org/releases/mozilla-1.9.1/rev/d1f3e4b9a9d9
http://hg.mozilla.org/releases/mozilla-1.9.2/rev/9e561d402701
Assignee | ||
Updated•14 years ago
|
Flags: in-testsuite+
Updated•14 years ago
|
Group: core-security
Updated•13 years ago
|
Depends on: CVE-2011-3659
Updated•12 years ago
|
Component: DOM: Traversal-Range → DOM: Core & HTML
You need to log in
before you can comment on or make changes to this bug.
Description
•