Skip to content
Memory corruption Disclosed report

Heap-use-after-free in nsTArray_base<nsTArrayInfallibleAllocator, nsTArray_CopyElements<mozilla::dom::HTMLImageElement*> >::Hdr()

Atte Kettunen Follow

Originally disclosed on Mozilla

Critical View original
  • Fixed in 13 days
  • Paid in 13 days
  • Disclosed after 13 days
Text
Created attachment 765613
Repro-file

Tested on:

OS: Ubuntu 12.04

Firefox: ASAN debug-build from https://ftp.mozilla.org/pub/mozilla.org/firefox/tinderbox-builds/mozilla-central-linux64-dbg-asan/1371733138/


ASAN-report:

###!!! ASSERTION: mForm should be null at this point!: '!mForm', file /builds/slave/m-cen-l64-dbg-asan-00000000000/build/content/html/content/src/nsGenericHTMLElement.cpp, line 2124
###!!! ASSERTION: Form control should have had flag set correctly: '(mForm != nullptr) == HasFlag(ADDED_TO_FORM)', file /builds/slave/m-cen-l64-dbg-asan-00000000000/build/content/html/content/src/HTMLImageElement.cpp, line 664
=================================================================
==17530== ERROR: AddressSanitizer: heap-use-after-free on address 0x7f38e07e45d0 at pc 0x7f39011b2c97 bp 0x7fffc993f410 sp 0x7fffc993f408
READ of size 8 at 0x7f38e07e45d0 thread T0
    #0 0x7f39011b2c96 in nsTArray_base<nsTArrayInfallibleAllocator, nsTArray_CopyElements<mozilla::dom::HTMLImageElement*> >::Hdr() const /builds/slave/m-cen-l64-dbg-asan-00000000000/build/../../../../dist/include/nsTArray.h:498
    #1 0x7f39011b2d38 in nsTArray_Impl<mozilla::dom::HTMLImageElement*, nsTArrayInfallibleAllocator>::Elements() const /builds/slave/m-cen-l64-dbg-asan-00000000000/build/../../../../dist/include/nsTArray.h:859
    #2 0x7f39011b2cba in unsigned int nsTArray_Impl<mozilla::dom::HTMLImageElement*, nsTArrayInfallibleAllocator>::IndexOf<mozilla::dom::HTMLImageElement*, nsDefaultComparator<mozilla::dom::HTMLImageElement*, mozilla::dom::HTMLImageElement*> >(mozilla::dom::HTMLImageElement* const&, unsigned int, nsDefaultComparator<mozilla::dom::HTMLImageElement*, mozilla::dom::HTMLImageElement*> const&) const /builds/slave/m-cen-l64-dbg-asan-00000000000/build/../../../../dist/include/nsTArray.h:961
    #3 0x7f39011aeb19 in unsigned int nsTArray_Impl<mozilla::dom::HTMLImageElement*, nsTArrayInfallibleAllocator>::IndexOf<mozilla::dom::HTMLImageElement*>(mozilla::dom::HTMLImageElement* const&, unsigned int) const /builds/slave/m-cen-l64-dbg-asan-00000000000/build/../../../../dist/include/nsTArray.h:977
    #4 0x7f39011aea56 in mozilla::dom::HTMLFormElement::RemoveImageElement(mozilla::dom::HTMLImageElement*) /builds/slave/m-cen-l64-dbg-asan-00000000000/build/content/html/content/src/HTMLFormElement.cpp:2789
    #5 0x7f390104931f in mozilla::dom::HTMLImageElement::ClearForm(bool) /builds/slave/m-cen-l64-dbg-asan-00000000000/build/content/html/content/src/HTMLImageElement.cpp:675
.
.
.
freed by thread T0 here:
    #0 0x43b1e0 in free ??:0
    #1 0x7f3900e2a0f7 in nsNodeUtils::LastRelease(nsINode*) /builds/slave/m-cen-l64-dbg-asan-00000000000/build/content/base/src/nsNodeUtils.cpp:265
    #2 0x7f3900c742c0 in mozilla::dom::FragmentOrElement::Release() /builds/slave/m-cen-l64-dbg-asan-00000000000/build/content/base/src/FragmentOrElement.cpp:1709
    #3 0x7f39011a1ece in mozilla::dom::HTMLFormElement::Release() /builds/slave/m-cen-l64-dbg-asan-00000000000/build/content/html/content/src/HTMLFormElement.cpp:328
    #4 0x7f38ffe32d67 in nsTArray_Impl<nsCOMPtr<nsIContent>, nsTArrayInfallibleAllocator>::DestructRange(unsigned int, unsigned int) /builds/slave/m-cen-l64-dbg-asan-00000000000/build/../../dist/include/nsTArray.h:1535
    #5 0x7f38ffe32c06 in nsTArray_Impl<nsCOMPtr<nsIContent>, nsTArrayInfallibleAllocator>::RemoveElementsAt(unsigned int, unsigned int) /builds/slave/m-cen-l64-dbg-asan-00000000000/build/../../dist/include/nsTArray.h:1252
.
.
.

The original report as published on Mozilla's Bugzilla, by Atte Kettunen. Images and videos are our own copies; raw HTML is shown as text. View it on Mozilla's Bugzilla.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

What is known

A critical-severity memory corruption bug in DOM: Core & HTML. Mozilla made it public on 3 July 2013.

About Memory corruption

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

What is Memory corruption?

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.

More by Atte Kettunen

View all

62 more disclosed reports, best first.

More from Mozilla

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Memory corruption

The lesson behind this report.

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.