Skip to content
Memory corruption Disclosed report

Use After Free in WebSocketChannel::BeginOpen()

Looben Yang Follow

Originally disclosed on Mozilla

Critical View original
  • Fixed in 29 days
  • Paid in 42 days
  • Disclosed after 29 days
Text
Created attachment 8536986
wsserver_uaf_BeginOpen.js

Steps to reproduce:

Run web socket server wsserver_uaf_BeginOpen.js  with Node.js module websocket, enter http://localhost:12345/ in Firefox browser. It can hit a non relevant null pointer reference, in this case just restart it.

Firefox Version: 37.0a1 (2014-12-16)
Operating System: Windows 7 64bit


Test case:
On server side, it accepts web socket at port 12345 with protocol "wsm1-protocol", and then send close frame in 50ms;
On client side, it initiates web socket to port 12345 with protocol "wsm1-protocol" in 2 web workers.

Client and server side code have been combined in a single node.js source file wsserver_uaf_BeginOpen.js.


Actual results:

Firefox crashes in WebSocketChannel::BeginOpen(), the 5A5A5A5A pattern in crash address indicates a Use After Free:

First-chance exception at 0x02522151 (xul.dll) in firefox.exe: 0xC0000005: Access violation reading location 0x5A5A5A5E.
Unhandled exception at 0x02522151 (xul.dll) in firefox.exe: 0xC0000005: Access violation reading location 0x5A5A5A5E.


Registers:

EAX = 5A5A5A5A EBX = 00000000 ECX = 1A924000 EDX = 00000000 ESI = 193F8840 EDI = 1A924000 EIP = 02522151 ESP = 1B0BF650 EBP = 00000000 EFL = 00010206 

0x5a5a5a5e = 00000000 


Backtrace:

>	xul.dll!nsRunnableMethodImpl<void (__thiscall nsProcess::*)(void),void,1>::nsRunnableMethodImpl<void (__thiscall nsProcess::*)(void),void,1>(nsProcess * aObj, void (void) * aMethod) Line 382	C++
 	xul.dll!NS_NewRunnableMethod<nsAttributeTextNode *,void (__thiscall nsAttributeTextNode::*)(void)>(nsAttributeTextNode * aPtr, void (void) * aMethod) Line 411	C++
 	xul.dll!mozilla::net::WebSocketChannel::BeginOpen() Line 1186	C++
 	xul.dll!mozilla::net::FailDelayManager::DelayOrBegin(mozilla::net::WebSocketChannel * ws) Line 286	C++
 	xul.dll!mozilla::net::nsWSAdmissionManager::ConnectNext(nsCString & hostName) Line 495	C++
 	xul.dll!mozilla::net::nsWSAdmissionManager::OnStopSession(mozilla::net::WebSocketChannel * aChannel, tag_nsresult aReason) Line 429	C++
 	xul.dll!mozilla::net::CallOnStop::Run() Line 604	C++
 	xul.dll!mozilla::dom::`anonymous namespace'::WorkerRunnableDispatcher::WorkerRun(JSContext * aCx, mozilla::dom::workers::WorkerPrivate * aWorkerPrivate) Line 2557	C++
 	xul.dll!mozilla::dom::workers::WorkerRunnable::Run() Line 326	C++
 	xul.dll!nsThread::ProcessNextEvent(bool aMayWait, bool * aResult) Line 830	C++
 	xul.dll!NS_ProcessNextEvent(nsIThread * aThread, bool aMayWait) Line 265	C++
 	xul.dll!mozilla::dom::workers::WorkerPrivate::DoRunLoop(JSContext * aCx) Line 4248	C++
 	xul.dll!`anonymous namespace'::WorkerThreadPrimaryRunnable::Run() Line 2615	C++
 	xul.dll!nsThread::ProcessNextEvent(bool aMayWait, bool * aResult) Line 830	C++
 	xul.dll!NS_ProcessNextEvent(nsIThread * aThread, bool aMayWait) Line 265	C++
 	xul.dll!mozilla::ipc::MessagePumpForNonMainThreads::Run(base::MessagePump::Delegate * aDelegate) Line 339	C++
 	xul.dll!MessageLoop::RunHandler() Line 227	C++
 	xul.dll!MessageLoop::Run() Line 201	C++
 	xul.dll!nsThread::ThreadFunc(void * aArg) Line 359	C++
 	nss3.dll!_PR_NativeRunThread(void * arg) Line 419	C
 	nss3.dll!pr_root(void * arg) Line 90	C
 	msvcr110.dll!_callthreadstartex() Line 354	C
 	msvcr110.dll!_threadstartex(void * ptd) Line 332	C
 	kernel32.dll!@BaseThreadInitThunk@12()	Unknown
 	ntdll.dll!___RtlUserThreadStart@8()	Unknown
 	ntdll.dll!__RtlUserThreadStart@8()	Unknown

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.

What is known

A critical-severity memory corruption bug in DOM: Workers. Mozilla made it public on 14 January 2015.

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