Windows Sandbox
Published Dec 18 2018 04:18 PM 2M Views
Microsoft

Windows Sandbox is a new lightweight desktop environment tailored for safely running applications in isolation.

 

How many times have you downloaded an executable file, but were afraid to run it? Have you ever been in a situation which required a clean installation of Windows, but didn’t want to set up a virtual machine?

 

At Microsoft we regularly encounter these situations, so we developed Windows Sandbox: an isolated, temporary, desktop environment where you can run untrusted software without the fear of lasting impact to your PC. Any software installed in Windows Sandbox stays only in the sandbox and cannot affect your host. Once Windows Sandbox is closed, all the software with all its files and state are permanently deleted.

 

Windows Sandbox has the following properties:

  • Part of Windows – everything required for this feature ships with Windows 10 Pro and Enterprise. No need to download a VHD!
  • Pristine – every time Windows Sandbox runs, it’s as clean as a brand-new installation of Windows
  • Disposable – nothing persists on the device; everything is discarded after you close the application
  • Secure – uses hardware-based virtualization for kernel isolation, which relies on the Microsoft’s hypervisor to run a separate kernel which isolates Windows Sandbox from the host
  • Efficient – uses integrated kernel scheduler, smart memory management, and virtual GPU

 

Prerequisites for using the feature

  • Windows 10 Pro or Enterprise Insider build 18305 or later
  • AMD64 architecture
  • Virtualization capabilities enabled in BIOS
  • At least 4GB of RAM (8GB recommended)
  • At least 1 GB of free disk space (SSD recommended)
  • At least 2 CPU cores (4 cores with hyperthreading recommended)

 

Quick start

  1. Install Windows 10 Pro or Enterprise, Insider build 18305 or newer
  2. Enable virtualization:
    • If you are using a physical machine, ensure virtualization capabilities are enabled in the BIOS.
    • If you are using a virtual machine, enable nested virtualization with this PowerShell cmdlet:
    • Set-VMProcessor -VMName <VMName> -ExposeVirtualizationExtensions $true
  3. Open Windows Features, and then select Windows Sandbox. Select OK to install Windows Sandbox. You might be asked to restart the computer.
  4. Optional Windows Features dlg.png
  5. Using the Start menu, find Windows Sandbox, run it and allow the elevation
  6. Copy an executable file from the host
  7. Paste the executable file in the window of Windows Sandbox (on the Windows desktop)
  8. Run the executable in the Windows Sandbox; if it is an installer go ahead and install it
  9. Run the application and use it as you normally do
  10. When you’re done experimenting, you can simply close the Windows Sandbox application. All sandbox content will be discarded and permanently deleted
  11. Confirm that the host does not have any of the modifications that you made in Windows Sandbox.

 Windows Sandbox Screenshot - open.jpg

 

Windows Sandbox respects the host diagnostic data settings. All other privacy settings are set to their default values.

 

Windows Sandbox internals

Since this is the Windows Kernel Internals blog, let’s go under the hood. Windows Sandbox builds on the technologies used within Windows Containers. Windows containers were designed to run in the cloud. We took that technology, added integration with Windows 10, and built features that make it more suitable to run on devices and laptops without requiring the full power of Windows Server.

 

Some of the key enhancements we have made include:

 

Dynamically generated Image

At its core Windows Sandbox is a lightweight virtual machine, so it needs an operating system image to boot from. One of the key enhancements we have made for Windows Sandbox is the ability to use a copy of the Windows 10 installed on your computer, instead of downloading a new VHD image as you would have to do with an ordinary virtual machine.

 

We want to always present a clean environment, but the challenge is that some operating system files can change. Our solution is to construct what we refer to as “dynamic base image”: an operating system image that has clean copies of files that can change, but links to files that cannot change that are in the Windows image that already exists on the host. The majority of the files are links (immutable files) and that's why the small size (~100MB) for a full operating system. We call this instance the “base image” for Windows Sandbox, using Windows Container parlance.

 

When Windows Sandbox is not installed, we keep the dynamic base image in a compressed package which is only 25MB. When installed the dynamic base package it occupies about 100MB disk space.

 Dynamic Image.PNG

Smart memory management

Memory management is another area where we have integrated with the Windows Kernel. Microsoft’s hypervisor allows a single physical machine to be carved up into multiple virtual machines which share the same physical hardware. While that approach works well for traditional server workloads, it isn't as well suited to running devices with more limited resources. We designed Windows Sandbox in such a way that the host can reclaim memory from the Sandbox if needed.

 

Additionally, since Windows Sandbox is basically running the same operating system image as the host we also allow Windows sandbox to use the same physical memory pages as the host for operating system binaries via a technology we refer to as “direct map”. In other words, the same executable pages of ntdll, are mapped into the sandbox as that on the host. We take care to ensure this done in a secure manner and no secrets are shared. 

 Direct Map.PNG

Integrated kernel scheduler

With ordinary virtual machines, Microsoft’s hypervisor controls the scheduling of the virtual processors running in the VMs. However, for Windows Sandbox we use a new technology called “integrated scheduler” which allows the host to decide when the sandbox runs. 

 

For Windows Sandbox we employ a unique scheduling policy that allows the virtual processors of the sandbox to be scheduled in the same way as threads would be scheduled for a process. High-priority tasks on the host can preempt less important work in the sandbox. The benefit of using the integrated scheduler is that the host manages Windows Sandbox as a process rather than a virtual machine which results in a much more responsive host, similar to Linux KVM.

 

The whole goal here is to treat the Sandbox like an app but with the security guarantees of a Virtual Machine. 

 

Snapshot and clone

As stated above, Windows Sandbox uses Microsoft’s hypervisor. We're essentially running another copy of Windows which needs to be booted and this can take some time. So rather than paying the full cost of booting the sandbox operating system every time we start Windows Sandbox, we use two other technologies; “snapshot” and “clone.”

 

Snapshot allows us to boot the sandbox environment once and preserve the memory, CPU, and device state to disk. Then we can restore the sandbox environment from disk and put it in the memory rather than booting it, when we need a new instance of Windows Sandbox. This significantly improves the start time of Windows Sandbox. 

 

Graphics virtualization

Hardware accelerated rendering is key to a smooth and responsive user experience, especially for graphics-intense or media-heavy use cases. However, virtual machines are isolated from their hosts and unable to access advanced devices like GPUs. The role of graphics virtualization technologies, therefore, is to bridge this gap and provide hardware acceleration in virtualized environments; e.g. Microsoft RemoteFX.

 

More recently, Microsoft has worked with our graphics ecosystem partners to integrate modern graphics virtualization capabilities directly into DirectX and WDDM, the driver model used by display drivers on Windows.

 

At a high level, this form of graphics virtualization works as follows:

  • Apps running in a Hyper-V VM use graphics APIs as normal.
  • Graphics components in the VM, which have been enlightened to support virtualization, coordinate across the VM boundary with the host to execute graphics workloads.
  • The host allocates and schedules graphics resources among apps in the VM alongside the apps running natively. Conceptually they behave as one pool of graphics clients.

This process is illustrated below:

 

GPU virtualization for Sandbox - diagram.png 

 

This enables the Windows Sandbox VM to benefit from hardware accelerated rendering, with Windows dynamically allocating graphics resources where they are needed across the host and guest. The result is improved performance and responsiveness for apps running in Windows Sandbox, as well as improved battery life for graphics-heavy use cases.

 

To take advantage of these benefits, you’ll need a system with a compatible GPU and graphics drivers (WDDM 2.5 or newer). Incompatible systems will render apps in Windows Sandbox with Microsoft’s CPU-based rendering technology.

 

Battery pass-through

Windows Sandbox is also aware of the host’s battery state, which allows it to optimize power consumption. This is critical for a technology that will be used on laptops, where not wasting battery is important to the user.

 

Filing bugs and suggestions

As with any new technology, there may be bugs. Please file them so that we can continually improve this feature. 

 

File bugs and suggestions at Windows Sandbox's Feedback Hub (select Add new feedback), or follows these steps:

  1. Open the Feedback Hub
  2. Select Report a problem or Suggest a feature.
  3. Fill in the Summarize your feedback and Explain in more details boxes with a detailed description of the issue or suggestion.
  4. Select an appropriate category and subcategory by using the dropdown menus. There is a dedicated option in Feedback Hub to file "Windows Sandbox" bugs and feedback. It is located under "Security and Privacy" subcategory "Windows Sandbox".
  5. Feedback Hub.png
  6. Select Next 
  7. If necessary, you can collect traces for the issue as follows: Select the Recreate my problem tile, then select Start capture, reproduce the issue, and then select Stop capture.
  8. Attach any relevant screenshots or files for the problem.
  9. Submit

Conclusion

We look forward to you using this feature and receiving your feedback!

 

Cheers, 

Hari Pulapaka, Margarit Chenchev, Erick Smith, & Paul Bozzay

(Windows Sandbox team)

317 Comments
Copper Contributor

Bonjour, j'avais le sandbox jusque hier où j'ai remarqué que je ne l'avais plus, il n'est plus non plus dans systeme32..  Où peut-on télécharger le .exe ? svp

@Alama32 Hi,

you don't download .exe for it. you enable it in Control panel, Windows features.

what do you see in the optional features section? Windows Sandbox is checked?

Copper Contributor

Dear Sir/Mam,

為何沒有繁體中文版?

簡體字我雖然看得懂,但總是閱讀起來很不OK!

 

Larson Hsiao

Again...complaining.

Sorry!

 

 

Copper Contributor

I updated to win 10 Pro, but i don't have it. here is my proof

Alex2938_1-1628124851049.png

 

Alex2938_0-1628124819151.png

 

Copper Contributor

Great to see so many helpful questions and especially answers from the Sandbox team. Here's one for you, which I've not found covered anywhere that I've looked: as discussed in other posts, the .wsb config option allows us to access host files/folders from within the sandbox/guest, but does anyone have a suggestion for the reverse: accessing sandbox/guest folders from within the host?

 

FWIW, I'm wanting to compare a folder on the host to the same folder within the sandbox (once certain software is installed within the sandbox, thus affecting that folder within the guest), using a compare tool installed on the host.

 

I realize of course that I COULD copy/paste things out of the sandbox to the host (and vice-versa), or perhaps setup up an FTP server in the guest, and then do the comparison on the host. That's a hassle for this need. So is installing comparison software within the guest (where the host folder COULD be accessed).

 

Any ideas, anyone? I’ve tried to access the sandbox folder using a UNC path from the host, and I’ve tried setting up a share. None seem to work, but I could have made a mistake, of course. Thanks.

Copper Contributor

@Alex2938 

 

Looking at your optional features list, it appears you're missing other Pro features such as the Virtual Machine Platform and the Windows Hypervisor Platform. Are you also missing "Hyper-V" further up in the list?

Richwood_0-1635311968815.png

 

If you performed an upgrade from Home to Pro, it seems your Windows has not properly updated to a full Windows 10 Pro system.

 

Try this to repair your system -

 

Open a Windows Terminal as Administrator and enter the following commands one-by-one -

 

DISM /Online /Cleanup-Image /CheckHealth

 

DISM /Online /Cleanup-Image /ScanHealth

 

DISM /Online /Cleanup-Image /RestoreHealth

Copper Contributor

So, I've enabled all the pre-requisites and Windows Sandbox; but when I attempt to start it I just get the blue and white logo splash screen...nothing happens from there.  I looked at the hyper-v manager and nothing shows up there either.  I found a tutorial that setup a config file that opened the downloads folder in read-only mode and tried double clicking on that .wsb file and still just get the blue/white splash screen.  I'm running windows 10 pro Version 21H2 (OS Buld 19044.1387).  I need some help on trouble shooting this - I'm about to chalk it off as just another "nice to have" piece of software that doesn't work!

Copper Contributor

John, are you confirming that it fails BOTH if you try to run a .wsb file and ALSO if you just run it via the Windows Start menu shortcut for it? And though it shouldn't be needed, what if you right-click that shortcut and run it "as administrator"? BTW, that shortcut ends up running WindowsSandbox.exe, as found (by default) in C:\Windows\System32\. What happens if you run that directly?

 

I have not heard of any more useful debugging techniques for when it won't launch, the way you describe. Since it shows the splashscreen, it surely seems that the process is running. It would seem some lower-level problem, perhaps even something about permissions. Or someone might well have you dig more into hyper-v, like you mentioned.

 

I will just say that it IS running fine for me on all systems I have (several), including ones running the exact same Windows update level you indicate. So it is indeed "nice to have" software that does in fact "work". I've never had it fail the way you describe, nor have I seen anyone else report it--but certainly some could have, somewhere. I hope someone who recognizes the problem or knows more about debugging it may reply. I just wanted to offer what little I could here, especially the opening paragraph, if it may help.

Copper Contributor

heee and not app sandbox  for Windows 10 Pro

Arkha75_0-1638612597986.jpeg

 

Copper Contributor

i am on a windows 11 and my virtualization on but i cant find it.

Copper Contributor

Is it possible to clone windows sandbox's virtual disk to a physical Hard disk and boot it as a host pc

Copper Contributor

i had this crazy idea just after the sandbox release

Copper Contributor

Hi @Hari_Pulapaka -- is there a way to retain the same hardware ID as that of the base when running the Sandbox?

@Arabiiscool No, Windows Sandbox's image is dynamically created using a small base file and other host OS files. There is no complete virtual disk sitting around, this is why Windows Sandbox barely increases disk space consumption after it's enabled.

Copper Contributor

Hello, I have Windows 11 pro, running Sandbox for a school assignment, but I can't run or find Windows local security policy in the Sandbox. 

 

Any suggestions on how to get local security policy to work in Sandbox?

 

 

Copper Contributor

Greetings,

my company started to deploy Windows Sandbox (Windows 11 Enterprise) for several users and instructing how to test safely different features.

I received a notification from the Security Team that it is mandatory to have internet access, but access to any Files Share / DFS should be restricted / denied.

I've checked all the possible configurations for Windows Sandbox but I am unable to find anything to achieve this goal.

There are not enough information regarding the "protected client" mode. In MS-Docs all I could find is:
"

  • Protected client: Places increased security settings on the RDP session to the sandbox

When Protected Client mode is enabled, Sandbox adds a new layer of security boundary by running inside an AppContainer Isolation execution environment.

AppContainer Isolation provides Credential, Device, File, Network, Process, and Window isolation."

 

The link regarding the AppContainer Isolation does not seem to provide what I'm looking for. I am aware with a full Hyper-v Server and a classic VM there are possible ways to achieve it, but it must be achieved with Windows Sandbox.

E.g.: A user starts Windows Sandbox, then it decided to connect to a Share (\\Myfileserver.contoso.com\Files) and enter the AD Credentials.
Since the Windows Sandbox User is Administrator I cannot find a way to prevent it (I could use a Logon Script to disable the SMB Service), but the user can simply re-enable and start the service again inside the Sandbox.

I tried to create on the Client an advanced FW rule to block all traffic for WIndowsSandbox.exe on port 445 but it was really a blind shoot and it didn't work. I suppose this should be done on the vEtherner Virtual Adaoter vSwitch, but even here I don't see the possibility to block the traffic.

 

Can anyone confirm that Windows Sandbox does not support Network Isolation in the way intended? From my understanding the only possible choice is enable or disable networking, but it cannot be configured in a granular way to block access to Intranet or specific services and still providing internet access.

 

Best Regards,

@Spider3 

This might be able to help you

Hyper-V firewall - Windows Security | Microsoft Learn

It can control Hyper-V, WSL containers, probably WSA container too, so maybe can also apply to Windows Sandbox

Version history
Last update:
‎Dec 12 2022 11:07 AM
Updated by: