This forum was built by humans, for humans. AI was used exclusively for security auditing. The forum officially launched on November 24, 2026. Read more

romdump.net
romdump.net › Forum › Malware & Analysis › (IN)secure VBS enclaves: Analysis and exploitation

Writeup (IN)secure VBS enclaves: Analysis and exploitation

started by noqs

noqs Member Posts 12
Rep 61
Joined Nov 2026
1d ago OP #154
Legal disclaimer: this shit is only for educational purposes i am not held responsible for any misuse god forbid  
Hello romdump community and malware lovers

Intro:

So Vbs enclaves or secure enclaves are ms approach to Trusted Execution Environments (TEES for short) it is completely managed by VBS and isolated from VTL0 by the hypervisor at the hardware level. Enclaves run in IUM isolated user mode which lives in vtl1 so by design any unauthorized VTL0 process could not by any means or even the highest priveleges not even Ring 0 (in vtl0) tamper or even inspect the enclave memory it is a black box. This is not something like PPL nor a PPL alternative both work very differently in purpose. Also code running inside an enclave in IUM dont hold a magic power or privelege just to be clear an enclave cannot exec privileged CPU instructions or directly access hardware, device drivers, or standard VTL 0 kernel memory.

The enclave PE:

so before discussing what is interesting to us as attackers or red teamers we need to first quickly take a look at what an enclave's PE looks like 
and for that i will use the prefs_enclave_x64.dll enclave (the one associated with CVE-2023-36880)
yes it is a dll and yes you can load it using those windows apis
  • CreateEnclave — reserves the VTL1 memory region inside the process
  • LoadEnclaveImageW — loads a signed DLL ("enclave module") into it
  • InitializeEnclave — flips the enclave to its sealed, operational state
  • CallEnclave — the only sanctioned way to invoke a function exported by the module

as per windows documentation

because ofc we cannot use LoadLibrary this maps the dll in vtl0 memory space we use the above winapis for the OS enclave loader to map and initialize it into the protected enclave address space

we will use pe bear to analyze what makes an enclave dll different from a typical dll

one of the things that will stand out is in the import table as you can see in the image the import table references vertdll.dll (the enclave's substitute for ntdll — the syscall interface to the secure kernel) and, depending on the module, ucrtbase_enclave.dll / vcruntime140_enclave.dll. There is no kernel32, no user32. The enclave API surface is tiny by design: no files, no registry, no network.

and ucrtbase_enclave.dll which is a Windows dynamic link library that provides Universal C Runtime (UCRT) functions as you can see the dll enclave imports functions like memcpy to do basic operations otherwise not possible because remember you cannot inspect a vtl1 process mem and accordingly mapping a dll into its process virtual address space you can see a list of the exported functions by ucrtbase_enclave.dll here https://learn.microsoft.com/en-us/windows/win32/trusted-execution/enclaves-available-in-ucrt


so this is the smoking gun that indicates that we indeed are looking into a dll enclave PE


also another thing is that the load config is extended with enclave-specific fields (an enclave image import list and the location of the enclave configuration structure) that LoadEnclaveImage* consumes when validating and mapping the module so if you go to EnclaveConfigu... in loadconfig and follow the VA value stored in it you will find the IMAGE_ENCLAVE_CONFIG64 structure which holds the config values we talked abt

copy the hex values you find in the hex viewer and use this powershell script to decode it and organise it in readable structure

$hex = @""@[string[]]$tokens = ($hex -split '\s+') | Where-Object { $_ }[byte[]]$bytes = $tokens | ForEach-Object { [Convert]::ToByte($_, 16) }$familyIdBytes = [byte[]]$bytes[0x18..0x27]$imageIdBytes  = [byte[]]$bytes[0x28..0x37][PSCustomObject]@{    Size                      = "0x{0:X} ($([BitConverter]::ToUInt32($bytes, 0x00)))" -f [BitConverter]::ToUInt32($bytes, 0x00)    MinimumRequiredConfigSize = "0x{0:X} ($([BitConverter]::ToUInt32($bytes, 0x04)))" -f [BitConverter]::ToUInt32($bytes, 0x04)    PolicyFlags               = "0x{0:X}" -f [BitConverter]::ToUInt32($bytes, 0x08)    NumberOfImports           = [BitConverter]::ToUInt32($bytes, 0x0C)    ImportListRVA             = "0x{0:X}" -f [BitConverter]::ToUInt32($bytes, 0x10)    ImportEntrySize           = "0x{0:X} ($([BitConverter]::ToUInt32($bytes, 0x14)))" -f [BitConverter]::ToUInt32($bytes, 0x14)    FamilyID                  = ([Guid]::new($familyIdBytes)).ToString()    ImageID                   = ([Guid]::new($imageIdBytes)).ToString()    ImageVersion              = [BitConverter]::ToUInt32($bytes, 0x38)    SecurityVersion           = [BitConverter]::ToUInt32($bytes, 0x3C)    EnclaveSize               = "0x{0:X} ($([BitConverter]::ToUInt64($bytes, 0x40) / 1MB) MB)" -f [BitConverter]::ToUInt64($bytes, 0x40)    NumberOfThreads           = [BitConverter]::ToUInt32($bytes, 0x48)    EnclaveFlags              = "0x{0:X}" -f [BitConverter]::ToUInt32($bytes, 0x4C)}

and this is the result

ofcourse i wont dive deep into structures and specifics but you got the idea


Weaponization opportunities:

now after this analysis what are the possible weaponization opportunities leveraging the vbs enclaves' black box nature

(spoiler: we will use it to hide shellcode)


we obv cannot craft an enclave ourselves because loading a vbs enclave using (LoadEnclaveImageW) requires strict binary integrity, cryptographic signing, and OS configuration. BUT...

the caller access control is largely left to the enclave developer rather than enforced by the Windows loader.

and ofcourse there exist that one lovely chud coder somewhere that will make this article possible

now as you guessed because any local process can load the enclave, the enclave itself must treat its host process as untrusted and enforce its own caller checks

  • Pointer & Boundary Validation. Enclave routines must manually validate all pointers, buffer sizes, and structures passed from VTL0 (using enclave memory validation intrinsics) to ensure host-controlled pointers do not overlap with VTL1 private memory.
  • Caller Identity / Attestation. If an enclave needs to restrict execution to a specific host application or user, it must implement custom authentication inside its exported routines—such as verifying the host process image hash, checking cryptographic tokens, or using VBS enclave attestation and Windows Hello user-binding APIs

and that is when CVE-2023-36880 came to life

cve-2023-36880 is a vulnerability in Microsoft Edge's Virtualization-Based Security (VBS) enclave module (prefs_enclave_x64.dll) that allows out-of-enclave callers to trigger arbitrary read and write primitives inside the enclave

we will reverse engineer the vulnerable enclave and we will demo the mirage poc by https://github.com/akamai/Mirage  but i will actually use https://github.com/JayGLXR/RustyMirage 

thanks to this rust giga chad comerade i wont hurt my eyes looking into messy cpp code


Reverse engineering:

for RE we will use binary ninja

open the dll in binary ninja or any re tool now we are interested in two functions exported by this buggy enclave that can give us write and read primitives in vtl1 (SealSettings and UnSealSettings)

the plan of two functions is simple as follows starting with UnSealSettings:

  1. call EnclaveUnsealData now this is different from UnSealSettings this one is exported by vertdll.dll remember the one we noticed in the imports
  2. allocate memory big enough to hold the decrypted data
  3. do a memset call to initialize the alloacted buffer
  4. do a memcpy call and copy the data to a user supplied destination and dont validate anywhere that the destination lies outside the enclave no comparison against the enclave's base and size, no call to anything resembling a memory-range validator no no at all this is mandatory step please dont skip

that is pretty it

now since the enclave code can write anywhere in the host process's address space (VTL0 included), a caller in VTL0 can point that destination at the enclave's own memory and have the enclave write attacker-controlled data into itself.

That's your arbitrary write into VTL1


Now it is SealSettings turn:

  1. allocate memory with the datatoencryptsize
  2. do a memset call to zero out that buffer
  3. do another legendary memcpy call and ofcourse dont validate the source supplied by the user
  4. call EnclaveSealData exported by vertdll.dll to encrypt the data in the buffer you allocated in the enclave memory space

now since the function drops the sealed blob wherever the caller asks. point the source inside the enclave, and the enclave happily seals its own memory and hands you the ciphertext. One more UnsealData later, you decrypt it in VTL0.

 That's your arbitrary read out of VTL1.

now chain the two together and you can hide shellcode in vtl1 that is what i am going to demo


Critical note: if you revisit the SealSettings function you can see that the SealSettings function just in the third line limits the size of the data you give it to 0xffff which is approximately 64 kbs so take dat into account 


Demo time :

wtf is this you didnot even bother counting the array length 😭


C:\Users\*****\Desktop\test>Mirage.exe"VBS Enclave not supported-  Called vulnerable enclave init function, config at: 0000000000000000Failed to initialize vulnerable enclave"

because my machine is running windows 10 and vbs enclaves is supported only on windows 11 consider this demo done anyway


Conclusion:

i wont conclude with blue teaming type of notes because i am not that expert in blue teaming shit i just want to comfort you that microsoft for some reason did not release a policy or anything to prevent this specific enclave from being loaded like they do with byovd which is because this enclave is bundled with microsoft edge and webview2 this will risk breaking legacy or un-patched enterprise deployments that still rely on older Edge WebView2 runtimes yk ms like that backward compatibility weirdo thing.

thx for reading <3

ah btw the a later patch for that same module missed a toctou angle on the same validation idea and then we have

https://pulse.adyog.com/cve/CVE-2024-21423


5 likes · 0 dislikes
admin admin admingod mode Posts 116
Rep 505
Joined Nov 2026
1d ago #155
nice read, keep up the good stuff
2 likes · 0 dislikes
zer0matt Newcomer Posts 9
Rep 19
Joined Nov 2026
1d ago #159
Day by day forum posts increase quality I see:)
2 likes · 0 dislikes
admin admin admingod mode Posts 116
Rep 505
Joined Nov 2026
1d ago #160

zer0matt wrote

Day by day forum posts increase quality I see:)

makes me tear up

2 likes · 0 dislikes
noqs Member Posts 12
Rep 61
Joined Nov 2026
1d ago #162

zer0matt wrote

Day by day forum posts increase quality I see:)

thx man

2 likes · 0 dislikes
x0rbyte Member admin Posts 6
Rep 50
Joined Nov 2026
1d ago #166
nice work 

0xDEADBEEF  If you know  you know xd



2 likes · 0 dislikes
xavier Newcomer Posts 2
Rep 5
Joined Nov 2026
21h ago #170
nice work really
noqs Member Posts 12
Rep 61
Joined Nov 2026
21h ago #171

xavier wrote

nice work really

Thank u < 3

sLo0n Newcomer Posts 2
Rep 7
Joined Nov 2026
19h ago #174
great article!
🐘   .   .   .   .   .   💩
1 like · 0 dislikes
noqs Member Posts 12
Rep 61
Joined Nov 2026
19h ago #175

sLo0n wrote

great article!

Appreciate u ❤️

1 like · 0 dislikes

Log in to reply.