Speedpwning VMware Workstation
Speedpwning VMware Workstation
Ekoparty 2020
4 Exploit
1 Introduction
5 Conclusion
2 Workstation Discovery
6 Annexes
3 Vulnerability Research
What is this ?
1/124
Who are we ?
2/124
Introduction
3/124
Planning
4/124
Plan
3 Vulnerability Research
1 Introduction
4 Exploit
2 Workstation Discovery
Virtualization for 5 Conclusion
dummies
Workstation Discovery 6 Annexes
Plan
3 Vulnerability Research
1 Introduction
4 Exploit
2 Workstation Discovery
Virtualization for 5 Conclusion
dummies
Workstation Discovery 6 Annexes
4/124
Virtualization for dummies
Virtualization ?
Virtualization allows to ”emulate” the hardware of a
computer.
Allows to run different(s) OS on the same hardware.
A guest or Virtual Machine (VM) is an OS which run with
the emulated hardware.
The host is the main (real) OS of the computer.
The hypervisor is all the code for handling the guest.
Security
The host should be isolated from the guests.
A VM Escape allows to get code execution in the host from
the guest.
5/124
Virtualization for dummies: devices
6/124
Plan
3 Vulnerability Research
1 Introduction
4 Exploit
2 Workstation Discovery
Virtualization for 5 Conclusion
dummies
Workstation Discovery 6 Annexes
6/124
VMware Workstation
7/124
General Reverse
Locate user input
Functions allowing to register IOPort, MMIO, PCI…
Functions for read/write/map the guest memory.
Debug Symbols
Rename all globals setup from the configuration.
Rename lock functions from the open-vm-tools.
Locate and rename functions from debug strings.
Lot of symbols from the code loading a snapshot.
Misc
A vmware-vmx-debug.exe exists: more debug strings but
also more checks.
Init. of the devices documented in Straight Outta VMware.
8/124
Target selection
9/124
Plan
SVGA2
Vulnerability
1 Introduction
4 Exploit
2 Workstation Discovery
5 Conclusion
3 Vulnerability Research
Misc research results
6 Annexes
Planning
10/124
Plan
SVGA2
Vulnerability
1 Introduction
4 Exploit
2 Workstation Discovery
5 Conclusion
3 Vulnerability Research
Misc research results
6 Annexes
10/124
VMware Workstation architecture
11/124
Quick vulnerabity research results
HDAudio
Only forwards to waveIn* and waveOut* APIs of
winmm.dll.
No parsing, only raw data audio transmission to hardware.
Very few code, not interesting.
12/124
Quick vulnerabity research results
Fuzzing
Tried to fuzz every component we audited.
With WinAFL and Synacktiv’s internal fuzzer.
Hard to implement, took a lot of time.
No results, big regret on spending too much time trying to
fuzz.
13/124
Plan
SVGA2
Vulnerability
1 Introduction
4 Exploit
2 Workstation Discovery
5 Conclusion
3 Vulnerability Research
Misc research results
6 Annexes
13/124
SVGA2
14/124
SVGA2 guest view
15/124
Graphics object & ArrayID
Graphics object
Objects are everything we usually see: shaders, surfaces…
Objects are read from DMA zone in the guest and are
lazy-loaded by the VMX.
Possible to readback: for sync. between host and guest.
ArrayID
Array for storing the graphical objects on the VMX side.
Function for adding, removing and searching in those.
When an element is added to an array, the memory for this
element is allocated, and freed when removed.
16/124
Direct X API
Commands & APIs
Define graphical objects through a set of commands.
Several APIs (sets of commands) are exposed through the
commands and they can be used concurrently.
Commands/API enabled depend on config., host, guest…
We used two of them:
the GB (global ?): the ”normal” one,
the DX (Direct X) which is specific to Windows host.
DX API
The DX objects are always associated with a DxContext.
The DxContext is a classical graphical object.
Most commands of the DX API use a current context
provided by the guest for a batch of commands.
17/124
Back-end Renderer
18/124
Planning
19/124
Plan
SVGA2
Vulnerability
1 Introduction
4 Exploit
2 Workstation Discovery
5 Conclusion
3 Vulnerability Research
Misc research results
6 Annexes
19/124
Vulnerability
20/124
Execution of DX Commands
21/124
Execution of DX Commands
22/124
Execution of DX Commands
23/124
The UAF
24/124
DxContext UAF
25/124
Vulnerability recap.
26/124
Of course we have time
27/124
Plan
4 Exploit 6 Annexes
Exploit Strategy
Planning
28/124
Plan
4 Exploit 6 Annexes
Exploit Strategy
28/124
Planning
29/124
Exploitation strategy
30/124
Exploitation strategy
31/124
Exploit - Massaging the heap
32/124
Exploit - Chosing a target object
33/124
Exploit Strategy
34/124
Plan
4 Exploit 6 Annexes
Exploit Strategy
34/124
Exploit - Heap Leak
35/124
Exploit - DxContext Pointer
36/124
Adding a DxShader
37/124
DxShader format
38/124
Reading back the DxShader pointer
39/124
A little problem
40/124
Final steps for the leak
41/124
Final steps for the leak
42/124
Final steps for the leak
43/124
Final steps for the leak
44/124
Final steps for the leak
45/124
Exploit Steps
46/124
Leak conclusion
47/124
Planning
48/124
Plan
4 Exploit 6 Annexes
Exploit Strategy
48/124
Exploit - Getting a .text leak
49/124
Exploit - Getting an arbitrary free/call primitive
50/124
Exploit - Controlling the RcIndex
51/124
Exploit - Controlling the RcIndex
52/124
Exploit - Controlling the RcIndex
53/124
Exploit - Controlling the RcIndex
54/124
Exploit - Controlling the RcIndex
55/124
Exploit - Controlling the RcIndex
56/124
Exploit - Controlling the RcIndex
Finally, a GbContext is allocated. Since its size is 0x5490, the
place needed with the header is 0x54A0, which falls perfectly
with the hole just created.
57/124
Exploit - Controlling the RcIndex
58/124
Exploit - Getting an arbitrary free/call primitive
59/124
Exploit - Getting an arbitrary free/call primitive
60/124
Exploit - Getting an arbitrary free/call primitive
61/124
Exploit - Getting an arbitrary free/call primitive
62/124
Exploit - Arbitrary free to .text leak
63/124
Exploit - Arbitrary free to .text leak
64/124
Exploit - Arbitrary free to .text leak
65/124
Exploit - Arbitrary free to .text leak
66/124
Exploit - Arbitrary free to .text leak
67/124
Exploit - Arbitrary free to .text leak
68/124
Exploit - Arbitrary free to .text leak
69/124
Exploit - Arbitrary free to .text leak
70/124
Exploit - Arbitrary free to .text leak
71/124
Exploit - Arbitrary free to .text leak
72/124
Exploit - Getting an arbitrary free/call primitive
73/124
Exploit - Arbitrary free to .text leak
74/124
Exploit - Arbitrary free to .text leak
75/124
Exploit - Getting an arbitrary free/call primitive
76/124
Exploit - Arbitrary free to .text leak
77/124
Exploit - Arbitrary free to .text leak
78/124
Exploit - Arbitrary free to .text leak
79/124
Exploit - Getting an arbitrary free/call primitive
80/124
Exploit - Arbitrary free to .text leak
81/124
Exploit - Arbitrary free to .text leak
82/124
Exploit - Arbitrary free to .text leak
83/124
Exploit - Arbitrary free to .text leak
84/124
Exploit - Arbitrary free to .text leak
85/124
Exploit - Arbitrary free to .text leak
86/124
Exploit - Arbitrary free to .text leak
87/124
Exploit - Arbitrary free to .text leak
88/124
Plan
4 Exploit 6 Annexes
Exploit Strategy
88/124
Exploit - Before leaving the command loop
89/124
Exploit - Before leaving the command loop
A GbContext can be quickly reallocated in the place of the
old one.
Write again the RcIndex using the
set_depthstencil_state command.
90/124
Exploit - Before leaving the command loop
91/124
Exploit - Using the arbitrary call
92/124
Planning
93/124
Exploit - Not so arbitrary call
94/124
Exploit - Using the arbitrary call
95/124
Exploit - Using the arbitrary call
96/124
Exploit - Using the arbitrary call
97/124
Exploit - Using the arbitrary call
98/124
Exploit - Using the arbitrary call
99/124
Exploit - Using the arbitrary call
3 Adds the WinExec offset to the CreateProcessW address.
100/124
Exploit - Using the arbitrary call
4 Use the arbitrary add to add an offset to the call pointer,
and change it back to the arbitrary read function.
101/124
Exploit - Using the arbitrary call
5 Use the arbitrary read to readback the WinExec address
and replace the call pointer by WinExec.
102/124
Exploit - Using the arbitrary call
6 Call WinExec with controlled arguments.
103/124
Pwn2Own - Popping a notepad
104/124
Pwn2Own - Popping a notepad
DEMO
105/124
Planning
106/124
Plan
4 Exploit 6 Annexes
Exploit Strategy
106/124
Exploit - Timeline
107/124
Exploit - Timeline
108/124
Exploit - WTF
109/124
Planning
110/124
Exploit - WTF
111/124
Exploit - Last day
112/124
Plan
4 Exploit 6 Annexes
Exploit Strategy
112/124
Pwn2Own - Us at Pwn2Own
113/124
Pwn2Own - aaaaand... fail
Failed attempt:
The exploit failed 3 times.
Numerous problems we knew about and could have fix, but
did not have time.
Of course we don’t know exactly why.
Very frustrating.
But ZDI did buy the vulnerability and the exploit outside of
the contest.
Really cool from them !
114/124
Pwn2Own - Feedback
115/124
Plan
4 Exploit
1 Introduction
5 Conclusion
2 Workstation Discovery
6 Annexes
3 Vulnerability Research
The End
116/124
The End
117/124
Thanks
118/124
Plan
4 Exploit
1 Introduction
5 Conclusion
2 Workstation Discovery
6 Annexes
State of The Art
3 Vulnerability Research
Our Setup
Plan
4 Exploit
1 Introduction
5 Conclusion
2 Workstation Discovery
6 Annexes
State of The Art
3 Vulnerability Research
Our Setup
118/124
State Of The Art – publication
119/124
State Of The Art – tools & code
120/124
Plan
4 Exploit
1 Introduction
5 Conclusion
2 Workstation Discovery
6 Annexes
State of The Art
3 Vulnerability Research
Our Setup
120/124
VMware binaries
Original Binaries
Version: 15.5.1.50853
vmware-vmx.exe MD5:
D76FEB17DF9153630D00E373A6ECB99B
Final Binaries
Version: 15.5.2.54704
vmware-vmx.exe MD5:
B23A9F348DA1F2DC2B0D6B2DB5D9CCA7
121/124
Our setup
122/124
Guest driver & devices initialization
123/124
ANY
QUESTIONS?
THANK YOU