How to Configure Windows Sandbox Mapped Folder Isolation and Read-Only Policy via XML in Windows 11

Windows Sandbox provides a disposable virtualized desktop that isolates suspicious applications and experimental binaries from your physical host. While mounting local host directories into the sandbox streamlines file transfers and script execution, granting unconstrained write access exposes host storage to accidental corruption, ransomware encryption, or rogue file modifications. By enforcing strict <ReadOnly>true</ReadOnly> boundaries within your .wsb XML configuration, you can safely share tools and installers while protecting host storage.

Understanding Folder Redirection and Isolation Directives

The <MappedFolders> element in a Windows Sandbox (.wsb) configuration file establishes a high-speed SMB bridge between the host file system and the sandbox container:

  • <HostFolder>: The absolute path of the target directory on your physical machine (e.g. C:\SecurityTools).
  • <SandboxFolder> (Optional): The destination mount path inside the sandbox desktop. If omitted, the folder appears on the Sandbox desktop automatically.
  • <ReadOnly>: When set to true, the host kernel prevents the sandbox process from writing, deleting, or altering files in the host path. Any write attempt inside the sandbox triggers an access denied error.

Authoring the Hardened WSB Configuration File

Create an XML configuration file named HardenedAnalysis.wsb on your Windows 11 host:

<Configuration>
  <VGpu>Disable</VGpu>
  <Networking>Disable</Networking>
  <MemoryInMB>4096</MemoryInMB>
  <MappedFolders>
    <MappedFolder>
      <HostFolder>C:SecTools</HostFolder>
      <SandboxFolder>C:Tools</SandboxFolder>
      <ReadOnly>true</ReadOnly>
    </MappedFolder>
  </MappedFolders>
  <LogonCommand>
    <Command>powershell.exe -NoExit -ExecutionPolicy Bypass -Command "Write-Host 'SecTools Mounted in Read-Only Mode' -ForegroundColor Yellow"</Command>
  </LogonCommand>
</Configuration>

Verifying Read-Only Enforcement Inside the Sandbox

To confirm that isolation boundaries are operating effectively:

  1. Double-click HardenedAnalysis.wsb to boot the sandbox session.
  2. Inside the sandbox, open PowerShell and navigate to the mounted folder:
    cd C:Tools
  3. Attempt to create a test file to verify write blocking:
    New-Item -Path ".	est_probe.txt" -ItemType "file"
  4. Verify that PowerShell returns an explicit permission error:
    New-Item : Access to the path 'C:Tools	est_probe.txt' is denied.
  5. Confirm that existing binaries in C:\Tools can be executed and read without restriction.

Combining Read-Only and Ephemeral Scratch Spaces

When testing malware or analyzing software installers that require write access for unpack operations, do not relax host directory permissions. Instead, instruct your automated logon script to copy files from the read-only host mount into an ephemeral sandbox folder (such as C:\Temp\WorkingDir). Any file modifications occur exclusively within volatile sandbox RAM and are automatically discarded upon exit.

Get the best tech tips delivered straight to your inbox.

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