How to Configure Windows Sandbox Hyper-V Isolated Enclaves via XML in Windows 11

Confidential computing and secure software architectures increasingly rely on hardware-isolated enclaves—such as Virtualization-Based Security (VBS) Enclaves (Virtual Secure Mode) and Intel SGX / AMD SEV extensions. Software enclaves isolate sensitive in-memory computations (such as cryptographic key generation, biometric template matching, and proprietary algorithms) into hardware-shielded memory spaces that even privileged kernel drivers or rogue system administrators cannot inspect. When developing enclave applications or testing zero-trust cryptographic workflows, developers can simulate Hyper-V isolated enclaves inside Windows Sandbox in Windows 11.

Understanding VBS Software Enclaves in Windows

VBS Enclaves operate within Isolated User Mode (IUM) powered by the Windows Hypervisor:

  • VBS Enclave DLLs: Specialized dynamic link libraries compiled with the /ENCLAVE linker flag and signed with trusted certificates.
  • Enclave Memory Management: Enclave memory is allocated via CreateEnclave() and InitializeEnclave(). The hypervisor masks these physical pages from standard Virtual Trust Level 0 (VTL 0) memory mappings.
  • Hardware Memory Protection: Even if malware achieves full Ring 0 kernel execution inside the container, hardware virtualization locks prevent reading or altering enclave RAM.

Authoring the Enclave Provisioning Script

Create a dedicated host folder (e.g. C:\SandboxEnclaveTest) and save a PowerShell provisioning script named InitEnclave.ps1:

# InitEnclave.ps1 - Configure VBS Enclave environment inside Windows Sandbox
Write-Host "Configuring Virtualization-Based Security (VBS) isolated enclave support..." -ForegroundColor Cyan

# 1. Enable VBS Enclave Subsystem in Registry
$vbsPath = "HKLM:SYSTEMCurrentControlSetControlDeviceGuard"
if (-not (Test-Path $vbsPath)) { New-Item -Path $vbsPath -Force | Out-Null }

Set-ItemProperty -Path $vbsPath -Name "EnableVirtualizationBasedSecurity" -Value 1 -Type DWord
Set-ItemProperty -Path $vbsPath -Name "RequirePlatformSecurityFeatures" -Value 1 -Type DWord
Write-Host "VBS core enabled." -ForegroundColor Green

# 2. Verify Enclave API Support via Windows Cryptography Subsystem
Write-Host "Testing Enclave API initialization..." -ForegroundColor Yellow
$enclaveSupport = (Get-ItemProperty -Path "HKLM:SYSTEMCurrentControlSetControlDeviceGuardScenariosHypervisorEnforcedCodeIntegrity" -ErrorAction SilentlyContinue)

Write-Host "Hyper-V isolated enclave testing environment ready." -ForegroundColor Green

Constructing the WSB Configuration File

Create an XML configuration file named EnclaveSandbox.wsb on your desktop:

<Configuration>
  <VGpu>Enable</VGpu>
  <Networking>Default</Networking>
  <MemoryInMB>8192</MemoryInMB>
  <MappedFolders>
    <MappedFolder>
      <HostFolder>C:SandboxEnclaveTest</HostFolder>
      <SandboxFolder>C:EnclaveShare</SandboxFolder>
      <ReadOnly>true</ReadOnly>
    </MappedFolder>
  </MappedFolders>
  <LogonCommand>
    <Command>powershell.exe -NoExit -ExecutionPolicy Bypass -File C:EnclaveShareInitEnclave.ps1</Command>
  </LogonCommand>
</Configuration>

Verifying Enclave Functionality Inside the Sandbox

To verify that software enclaves operate correctly inside Windows Sandbox:

  1. Double-click EnclaveSandbox.wsb to boot the virtual container.
  2. The PowerShell window executes and initializes VBS settings.
  3. Launch an enclave-enabled test binary inside the sandbox.
  4. Verify that the application successfully calls IsEnclaveTypeSupported(ENCLAVE_TYPE_VBS) and receives a non-zero success return code.
  5. Attempt to inspect enclave memory using user-mode diagnostic utilities; confirm that reading enclave memory pages returns access violation errors, proving hypervisor isolation is active.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.