[Writeup] (IN)secure VBS enclaves: Analysis and exploitation ============================================================ Section: Malware & Analysis Started: 2026-11-29 05:00 UTC by noqs Replies: 9, last post 2026-11-30 08:03 UTC Page: 1 of 1 Web: https://romdump.net/t/130 ------------------------------------------------------------------------------ #154 noqs, 2026-11-29 05:00 UTC [OP] Source: https://romdump.net/raw/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) link: https://github.com/akamai/Mirage/blob/main/prefs_enclave_x64.dll 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. [image: https://romdump.net/img/8e6dbe3fdc234ee8c94df92f0c73179ab2565bb3fb91569851cdd2bc57f295a5] 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 [image: https://romdump.net/img/4037f67e25278e3c09dfa2869dab8de75d644cbbda7ab73a293aec2aa210131f] 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 [image: https://romdump.net/img/1e16ea40be4fbb83515c4242c5757b8c944c2ffa28728de51ff1b35b4d2436ed] 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 [image: https://romdump.net/img/d322e0824fe111227237d0290dd2445c0e29cdecd0b870ba84aaa36817f0fd59] 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. [image: https://romdump.net/img/3813761dcf95fe2096d72fb01228c6e9e46d0db985a585b043b1a9b32fbb2846] 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 : [image: https://romdump.net/img/fee52d2582cd42025362d83766ea1c4398fdc953232b5f6a8eda7371bb597745] 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: 0000000000000000 Failed 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 [image: https://romdump.net/img/e66562940eb28135fc11569f68ce30f58f64b67cb1054fee5ba2544d7586d77c] ------------------------------------------------------------------------------ #155 admin, 2026-11-29 05:30 UTC Source: https://romdump.net/raw/155 nice read, keep up the good stuff ------------------------------------------------------------------------------ #159 zer0matt, 2026-11-29 22:01 UTC Source: https://romdump.net/raw/159 Day by day forum posts increase quality I see:) ------------------------------------------------------------------------------ #160 admin, 2026-11-29 22:18 UTC Source: https://romdump.net/raw/160 Day by day forum posts increase quality I see:) makes me tear up ------------------------------------------------------------------------------ #162 noqs, 2026-11-29 23:54 UTC Source: https://romdump.net/raw/162 Day by day forum posts increase quality I see:) thx man ------------------------------------------------------------------------------ #166 x0rbyte, 2026-11-30 00:32 UTC Source: https://romdump.net/raw/166 nice work ------------------------------------------------------------------------------ #170 xavier, 2026-11-30 05:54 UTC Source: https://romdump.net/raw/170 nice work really ------------------------------------------------------------------------------ #171 noqs, 2026-11-30 05:55 UTC Source: https://romdump.net/raw/171 nice work really Thank u < 3 ------------------------------------------------------------------------------ #174 sLo0n, 2026-11-30 08:02 UTC Source: https://romdump.net/raw/174 great article! ------------------------------------------------------------------------------ #175 noqs, 2026-11-30 08:03 UTC Source: https://romdump.net/raw/175 great article! Appreciate u ❤️ ------------------------------------------------------------------------------ Page 1 of 1. End of thread.