WSL Ubuntu Sandbox Guide

Technology: sandbox · Category: tooling · Last reviewed: 2026-10-20

Source: https://tech-stack.codeamanilabs.org/guide/sandbox

Insight:

A WSL sandbox is three commands used as a discipline: wsl --install --name to stand up a second Ubuntu, wsl --export/--import as snapshot-and-restore, and wsl --unregister to nuke it, so an experiment you don't trust never lands in the distro holding your keys and your ~/code. Microsoft's own WSL security model now says it plainly: WSL "is not a security sandbox for running untrusted code", a distro is not a security boundary from the Windows user or from that user's other distros, and wsl.conf switches are not containment. So treat a second distro as a hygiene sandbox (clean, reproducible, accident-proof), not a security one. For code you actually distrust, step up to a separately managed VM: a Docker Sandboxes microVM (sbx), Windows Sandbox or Hyper-V on Pro editions, or a disposable cloud box.

███████╗ █████╗ ███╗   ██╗██████╗ ██████╗  ██████╗ ██╗  ██╗
██╔════╝██╔══██╗████╗  ██║██╔══██╗██╔══██╗██╔═══██╗╚██╗██╔╝
███████╗███████║██╔██╗ ██║██║  ██║██████╔╝██║   ██║ ╚███╔╝
╚════██║██╔══██║██║╚██╗██║██║  ██║██╔══██╗██║   ██║ ██╔██╗
███████║██║  ██║██║ ╚████║██████╔╝██████╔╝╚██████╔╝██╔╝ ██╗
╚══════╝╚═╝  ╚═╝╚═╝  ╚═══╝╚═════╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝

WSL Ubuntu Sandbox Guide

Focus: Standing up a disposable Ubuntu on Windows for experiments: spin-up, snapshot, blast-radius reduction, and a one-command nuke, so a risky install or a customer repro never lands in your real dev distro. It also covers when a WSL distro is the wrong tool and which separately managed VM to use instead.

Not this guide: cloud code-execution sandboxes for AI agents (Vercel Sandbox, E2B, Daytona, Cloudflare Sandbox, Anthropic's code execution tool). Those are hosted services with SDKs; this folder is about local, on-your-laptop isolation on Windows.

Overview

The wsl/ guide covers WSL as your primary dev environment. This one covers the opposite posture: a distro you expect to break. The core workflow is four verbs on the same wsl.exe binary you already have. No extra tooling, no VM images to download.

Verb Command Cost
Spin up wsl --install Ubuntu-26.04 --name lab ~1 min, one download
Snapshot wsl --export lab lab-clean.tar.gz --format tar.gz seconds to minutes, one file
Restore wsl --import lab-2 D:\wsl\lab-2 lab-clean.tar.gz seconds
Nuke wsl --unregister lab instant, unrecoverable

Read this before you trust it with anything

WSL's own security model document (in the microsoft/WSL repo, doc/docs/technical-documentation/security.md) is blunt, and it overrides any looser framing you may have read elsewhere, including earlier versions of this guide:

WSL provides a Linux environment that is deeply integrated with Windows. It is not a security sandbox for running untrusted code.

Code running in WSL should be treated as having the same trust level as code running under the Windows account that launched it. WSL distributions provide functional process and file system separation, but a distribution is not a security boundary from the Windows host or from other distributions running for the same user.

And on the hardening switches this guide recommends:

Unless a setting is explicitly documented as a security control, do not use it as a containment boundary. [...] These settings change the available integration features, but they do not turn a distribution into a sandbox or isolate it from Windows resources available to the user.

The architecture explains why. All WSL 2 distros for a user run inside one shared utility VM. Per Microsoft Learn, distros "share the same network namespace, device tree (other than /dev/pts), CPU/Kernel/Memory/Swap, /init binary, but have their own PID namespace, Mount namespace, User namespace, Cgroup namespace, and init process." The Hyper-V boundary between that VM and Windows is real. But WSL deliberately punches integration holes through it (DrvFs/Plan9 file sharing, interop, localhost relays) on your behalf, so you can't rely on the VM wall as containment.

What a WSL sandbox is good for: keeping your dev distro clean, making experiments reproducible from a known base, and containing accidents (a bad apt pin, a curl | bash that rewrites your shell profile, a toolchain that fights your real one).

What it is not for: code you believe is hostile. That needs a separately managed VM (see the tier table).

flowchart TB
  H["Windows 11 host<br/>your files, creds, Windows identity"]
  H -->|"Hyper-V VM boundary, with WSL integration bridged through it"| VM
  VM["WSL 2 utility VM<br/>one kernel · one network namespace · one .wslconfig"]
  VM --> DEV["Ubuntu · dev distro<br/>~/code · SSH keys · .env.local"]
  VM --> LAB["Ubuntu-lab · sandbox distro<br/>own mount / PID / user / cgroup ns"]
  LAB --> SNAP["wsl --export lab<br/>lab-clean.tar.gz"]
  SNAP --> REST["wsl --import lab-2<br/>rebuild from clean"]
  LAB --> NUKE["wsl --unregister lab<br/>gone in one second"]
  H --> SBX["Separately managed VM<br/>sbx microVM · Windows Sandbox · Hyper-V · cloud VM<br/>for untrusted code"]

Which tier do you actually need?

Tier What you get Reset cost Reach for it when
Second WSL distro Own ext4 VHDX plus mount/PID/user/cgroup namespaces. Not a security boundary. wsl --unregister, instant A whole toolchain, a repro that needs systemd, an install script from a source you trust but don't want on your dev distro
Snapshot + import The above, plus a known-good starting point Re-import a tarball, under a minute You need to run the same experiment five times from a clean base
Container (docker run or wslc run) Own network namespace (--network none) and per-container cgroup caps Automatic on --rm One process, one command, no persistent state. Microsoft: a container "does not make WSL a security boundary from the Windows host."
Docker Sandboxes (sbx) A microVM per sandbox with its own Docker daemon, filesystem and network, plus deny-by-default network presets Delete the sandbox Running an AI coding agent or an unfamiliar install script you actually distrust, on any Windows 11 edition with Windows Hypervisor Platform
Windows Sandbox (wsb) Disposable Windows VM with a separate kernel. Networking can be disabled in a .wsb file Close the window Detonating a Windows binary or attachment. Pro/Enterprise/Education only, not on Home
Full Hyper-V VM or disposable cloud VM Separate kernel, separate network stack, checkpoints Restore a checkpoint or destroy the VM Real malware analysis, kernel modules, anything that must not share your Windows identity. Hyper-V Manager also needs Pro or higher; on Home, use a cloud VM

Official Documentation

Resource URL
WSL security model (what WSL is and isn't a boundary for) https://github.com/microsoft/WSL/blob/master/doc/docs/technical-documentation/security.md
Basic WSL commands (export / import / unregister) https://learn.microsoft.com/windows/wsl/basic-commands
Advanced settings: .wslconfig and wsl.conf https://learn.microsoft.com/windows/wsl/wsl-config
WSL 2 architecture (what's shared, what isn't) https://learn.microsoft.com/windows/wsl/about
Enterprise setup: images, firewall, file-access model https://learn.microsoft.com/windows/wsl/enterprise
WSL containers (wslc.exe + API) https://learn.microsoft.com/windows/wsl/wsl-container
WSL container settings (settings.yaml) https://learn.microsoft.com/windows/wsl/wsl-container-settings
Import a custom distro from a tarball https://learn.microsoft.com/windows/wsl/use-custom-distro
Manage disk space / sparse VHDX https://learn.microsoft.com/windows/wsl/disk-space
Hyper-V Firewall (filtering WSL traffic) https://learn.microsoft.com/windows/security/operating-system-security/network-security/windows-firewall/hyper-v-firewall
WSL releases (check what your build supports) https://github.com/microsoft/WSL/releases
docker run reference https://docs.docker.com/reference/cli/docker/container/run/
Docker none network driver https://docs.docker.com/engine/network/drivers/none/
Docker Sandboxes (sbx) https://docs.docker.com/ai/sandboxes/
Windows Sandbox https://learn.microsoft.com/windows/security/application-security/application-isolation/windows-sandbox/

Versions verified 2026-10-20

Component Version Source
WSL, latest stable 3.0.3 (2026-10-09). 3.0.1 (2026-09-29) made WSL containers GA github.com/microsoft/WSL/releases
WSL, latest pre-release 3.0.4 (2026-10-20) same
WSL 2.7 servicing branch 2.7.14 (2026-09-11) same
WSL kernel shipped in 3.0.3 6.18.54.1 3.0.3 release notes
Docker Engine 29.9.1 (2026-10-14) github.com/moby/moby/releases
Docker Sandboxes CLI (Docker.sbx on winget) 0.48.0 winget show Docker.sbx
ubuntu Docker image tags 26.04, 24.04, 22.04, latest Docker Hub

Run wsl --version first. The flags below were read from a local wsl --help (2.6.3). A much older inbox WSL may not have --manage, --install --name, or --export --format, and WSL containers need 2.9.3 or later. wsl --update gets you current.


Quickstart: a throwaway Ubuntu in 60 seconds

# Stand up a SECOND Ubuntu named "lab". --name is what makes a second
# copy of an already-installed distro possible.
wsl.exe --install Ubuntu-26.04 --name lab --no-launch

# Enter it
wsl.exe -d lab

# ...break things...

# Nuke it. Instant. Unrecoverable. That's the point.
wsl.exe --unregister lab

From PowerShell, drop the .exe. Everything below uses wsl (PowerShell form) except where a Linux-side command is being run.

Confirm what's installed and which VM version each distro is on:

wsl.exe --list --verbose
wsl.exe --version          # verify your WSL build supports the flags below
wsl.exe --list --online    # real, current distro names for --install

As of 2026-10-20, --list --online offers Ubuntu (the moving "latest" entry), Ubuntu-26.04, Ubuntu-24.04, Ubuntu-22.04, Debian, kali-linux, archlinux, FedoraLinux-44, FedoraLinux-43, openSUSE-Tumbleweed, openSUSE-Leap-16.0, RLCPlus-9/RLCPlus-10 (Rocky Linux Plus), plus the AlmaLinux, SUSE Linux Enterprise, Oracle Linux and eLxr families. Use the NAME column verbatim. Pin a versioned name (Ubuntu-26.04) in scripts; Ubuntu moves.

Placing and sizing the sandbox

Put the sandbox VHDX somewhere you don't mind filling up, and cap it:

wsl --install Ubuntu-26.04 `
  --name lab `
  --location D:\wsl\lab `
  --vhd-size 40GB `
  --no-launch
Install flag Effect
--name <Name> Registers under a custom name, which is how you run N copies of one distro
--location <Path> Where the ext4.vhdx lives (default is [general] distributionInstallPath, itself defaulting to %LocalAppData%\wsl)
--vhd-size <Size> Caps the virtual disk (default defaultVhdSize is 1 TB)
--no-launch, -n Register without launching, so you can write wsl.conf before first boot
--fixed-vhd Fixed-size rather than dynamically expanding disk
--from-file <Path> Install from a local distro file instead of the store
--web-download Download from the internet instead of the Microsoft Store
--version <1|2> Force WSL 1 or WSL 2 for this distro

Snapshot and restore

This is the part that turns a second distro into a sandbox. Get the environment to a known-good state, export it, and from then on every experiment starts from that file.

Take the golden snapshot

# Terminate first so the filesystem is quiescent
wsl --terminate lab

# tar is the portable format; tar.gz / tar.xz trade CPU for size
wsl --export lab D:\wsl\snapshots\lab-clean.tar.gz --format tar.gz

--format accepts tar, tar.gz, tar.xz, and vhd. Microsoft Learn's basic-commands page still documents only the older --vhd switch on export. The binary accepts both, and --format vhd is the current spelling. A .vhdx export restores fastest (no untar) but is far larger and WSL 2 only.

<FileName> can be - for stdout (and - for stdin on import), so an export can be streamed into another tool. Do this from cmd or a POSIX shell, not PowerShell, whose object pipeline mangles binary streams:

# Git Bash / WSL: stream a snapshot straight to a compressor
export WSL_UTF8=1
wsl.exe --export lab - | zstd -T0 -19 -o /d/wsl/snapshots/lab-clean.tar.zst

Restore into a fresh distro

wsl --import lab-2 D:\wsl\lab-2 D:\wsl\snapshots\lab-clean.tar.gz --version 2
wsl -d lab-2
Import flag Effect
--version <1|2> WSL version for the new distro
--vhd The source file is a .vhdx, not a tar. WSL copies it to <InstallLocation>

For a .vhdx you want to attach without copying (fast, but the file becomes the live disk):

wsl --import-in-place lab-3 D:\wsl\images\lab.vhdx

The VHD must be formatted ext4.

The reset loop

# One experiment, start to finish
wsl --unregister lab
wsl --import lab D:\wsl\lab D:\wsl\snapshots\lab-clean.tar.gz --version 2
wsl -d lab -- bash -lc './experiment.sh'

Because --unregister deletes the root filesystem outright, this loop takes a few seconds. Treat lab-clean.tar.gz as immutable and never export over it from a dirty distro. A full script is in examples/reset-lab.ps1.

Post-import housekeeping

An imported distro has no launcher executable, which breaks the usual ubuntu config --default-user trick. Use wsl --manage instead:

wsl --manage lab --set-default-user amani     # imported distros boot as root otherwise
wsl --manage lab --set-sparse true            # auto-reclaim freed disk space
wsl --manage lab --resize 60GB                # grow (or shrink) the VHDX
wsl --manage lab --move E:\wsl\lab            # relocate the distro's disk

Or set it inside the distro before you snapshot, in /etc/wsl.conf:

[user]
default=amani

Reducing the blast radius

A fresh distro automounts your Windows drives and can launch Windows binaries as you. Turn that off in /etc/wsl.conf before you take the golden snapshot. Per the security model quoted above, this reduces accident surface; it is not containment. It stops a sloppy script from writing to /mnt/c/Users/you. It does not stop code that is trying to get out.

# Inside the sandbox distro
sudo tee /etc/wsl.conf >/dev/null <<'EOF'
# Do not mount C:\ (and friends) into the sandbox at all.
[automount]
enabled = false
mountFsTab = false

# Do not let Linux processes launch Windows binaries, and keep the
# Windows PATH out of $PATH.
[interop]
enabled = false
appendWindowsPath = false

[network]
hostname = lab
generateResolvConf = true

[user]
default = amani

[boot]
systemd = true
EOF

Then, from Windows:

wsl --terminate lab   # settings only apply after the distro fully stops

The same file is in examples/wsl.conf. What each switch buys you:

Setting Without it With it
[automount] enabled=false /mnt/c exposes your entire Windows profile (SSH keys, .env.local, browser profiles), writable as your Windows user Drives aren't mounted automatically. They can still be mounted manually, which is why this is hygiene, not a wall
[interop] enabled=false A script can run powershell.exe, explorer.exe, or any Windows binary as you The normal Windows-launch workflow is disabled
[interop] appendWindowsPath=false Windows PATH entries leak into $PATH, so a typo can silently invoke a Windows tool Clean Linux-only PATH
[boot] systemd=true No service manager, so many repros won't reproduce Real systemctl, matching production

Microsoft's enterprise guidance explains why automount matters: when a Linux binary in WSL touches a Windows file, it does so with the permissions of the Windows user who ran wsl.exe. Root inside the sandbox is not Windows admin, but it is you on Windows, for every file you can reach.

What you still don't get

For anything genuinely hostile, use a separately managed VM: sbx, Windows Sandbox, Hyper-V, or a disposable cloud box. Don't use a WSL distro.


Resource limits with .wslconfig

.wslconfig lives on the Windows side at %UserProfile%\.wslconfig and governs the whole WSL 2 VM. Its job here is to keep a runaway make -j$(nproc) in the sandbox from freezing Windows.

# %UserProfile%\.wslconfig   -  applies to the VM shared by ALL WSL 2 distros
[wsl2]
memory=8GB              # default: 50% of host RAM
processors=4            # default: all logical processors
swap=4GB                # default: 25% of memory, rounded up to the nearest GB
swapFile=D:\\wsl\\swap.vhdx   # default: %Temp%\swap.vhdx
defaultVhdSize=64GB     # cap new distro disks (default 1 TB)
vmIdleTimeout=60000     # ms of idle before the VM shuts down (Windows 11)
nestedVirtualization=true
localhostForwarding=true

[general]
instanceIdleTimeout=15000          # ms a distro sits idle before it stops; -1 disables
distributionInstallPath=D:\\wsl    # default home for new distros

[experimental]
autoMemoryReclaim=gradual   # disabled | gradual | dropCache (default)
sparseVhd=true              # every new VHDX is sparse, so disk comes back on delete

Notes that will save you an hour:

Per-experiment limits

Since .wslconfig can't cap a single distro, cap the workload instead, with systemd-run inside the sandbox:

# Needs [boot] systemd=true in the sandbox's wsl.conf
sudo systemd-run --scope \
  -p MemoryMax=2G -p CPUQuota=200% -p TasksMax=512 \
  ./experiment.sh

(--user scopes work too, but only where systemd has delegated the memory and pids controllers to the user slice. sudo is the version that always applies.)

Or run the experiment in a container, which is the next section.


Networking isolation

WSL's network knobs are all in [wsl2], and all global:

[wsl2]
networkingMode=mirrored   # nat (default) | mirrored | consomme | none   (bridged is deprecated)
firewall=true             # Windows Firewall + Hyper-V rules filter WSL traffic (default)
dnsTunneling=true         # DNS via virtualization rather than packets, VPN-friendly
autoProxy=true            # inherit the Windows HTTP proxy

Containers: the lighter tier

When the experiment is one process rather than a whole environment, a container is faster, tighter, and self-cleaning. Keep the security model in mind: a container inside WSL "inherit[s] the security properties of [its] container runtime configuration and WSL." It gets its own network namespace and cgroup caps. It doesn't get a new trust boundary from Windows.

Docker

From inside your normal distro (or via Docker Desktop's WSL integration):

# Ephemeral, network-isolated Ubuntu shell. Gone the moment you exit.
docker run --rm -it --network none ubuntu:26.04 bash

A hardened version for running something you don't fully trust:

docker run --rm -it \
  --network none \
  --memory 2g --cpus 2 --pids-limit 512 \
  --cap-drop ALL \
  --security-opt no-new-privileges \
  --read-only --tmpfs /tmp:rw,noexec,nosuid,size=256m \
  --user 1000:1000 \
  -v "$PWD/artifacts:/out:rw" \
  -w /out \
  ubuntu:26.04 bash
Flag Why it's there
--rm Container and its writable layer are removed on exit, so no cleanup discipline is required
--network none Loopback-only network namespace. A second WSL distro can't give you this.
--memory / --cpus / --pids-limit Real cgroup caps, so a fork bomb hits the limit, not your laptop
--cap-drop ALL + --security-opt no-new-privileges No CAP_*, no setuid escalation
--read-only + --tmpfs /tmp Immutable root, plus scratch space that can't execute
--user 1000:1000 Not root. Without user-namespace remapping, container root maps to root on the shared kernel
-v ...:/out One narrow, explicit path for results to escape through

examples/vet-npm-offline.sh wraps this into a "download online, then install offline and watch" recipe for vetting an unfamiliar npm package.

WSL containers (wslc.exe): no Docker Desktop needed

WSL containers went generally available in WSL 3.0.1 (2026-09-29) and need WSL 2.9.3+. wslc.exe ships inside WSL. There's no separate engine to install, and the CLI deliberately mirrors Docker's:

wslc version
wslc run --rm -it ubuntu:26.04 bash
wslc run --rm --network none ubuntu:26.04 bash -c "id && ip addr"
wslc container list --all
wslc container prune
wslc image prune

What's documented (Microsoft Learn plus the 2.9.3 release notes):

session:
  cpuCount: 4              # default: all logical processors
  memorySize: 8GB          # default: 50% of Windows memory
  maxStorageSize: 100GB    # default: 1TB
  storagePath: D:\wslc     # default: %LOCALAPPDATA%
  defaultBindingAddress: 127.0.0.1   # where -p binds by default (keep it local)
  hostLoopback: none       # default host.wslc.internal; none stops containers resolving the host by name
  idleTimeout: 30          # seconds before an idle session VM stops

Session settings are read when the session starts. Run wslc system session terminate to apply changes. An invalid setting prints a warning with the file and line number and falls back to the default.

Use wslc when you want Docker-style throwaway containers on a machine without Docker Desktop. Don't treat it as a stronger boundary than Docker. Microsoft documents its sessions as process-isolated from each other, but the security model's container caveat still applies. Docker flags beyond those listed above (--cap-drop, --read-only, --user) weren't verified against wslc for this review, so check wslc run --help before you rely on them.


Stepping up: separately managed VMs for untrusted code

This is the tier the WSL security model actually tells you to use: "a separately managed virtual machine outside WSL with appropriately restricted access."

Docker Sandboxes (sbx)

Docker's agent sandbox. Each sandbox is a microVM with its own Docker daemon, filesystem and network. Docker Desktop and Docker Engine are not required.

# One-time: Windows 11, 64-bit Intel/AMD, Windows Hypervisor Platform (elevated)
Enable-WindowsOptionalFeature -Online -FeatureName HypervisorPlatform -All
winget install -h Docker.sbx          # per-user install, no admin

sbx run --name vet-lab claude         # or another agent from the agents list
sbx policy ls                         # show network rules
sbx policy allow network registry.npmjs.org

On first run you pick a network preset: Open (no restrictions), Balanced (default deny, with common dev sites allowed), or Locked Down (everything blocked unless you allow it). Use Locked Down for vetting, then allow exactly the registry you need. Central org policy (network, filesystem, MCP) is a separate paid Docker subscription. Local pricing and a GA/beta label weren't stated on the pages checked.

Windows Sandbox

A disposable Windows VM with its own kernel. It's not available on Windows Home. Networking is on by default, so turn it off in a .wsb file, and map folders read-only:

<Configuration>
  <Networking>Disable</Networking>
  <ClipboardRedirection>Disable</ClipboardRedirection>
  <AudioInput>Disable</AudioInput>
  <ProtectedClient>Enable</ProtectedClient>
  <MappedFolders>
    <MappedFolder>
      <HostFolder>D:\quarantine</HostFolder>
      <SandboxFolder>C:\quarantine</SandboxFolder>
      <ReadOnly>true</ReadOnly>
    </MappedFolder>
  </MappedFolders>
</Configuration>

ProtectedClient runs the sandbox inside AppContainer isolation, which adds a layer at the cost of copy/paste. The same file is in examples/quarantine.wsb. On Windows 11 24H2+ there's also a CLI: wsb start --config "<Configuration><Networking>Disable</Networking></Configuration>" (Microsoft's CLI page writes the value as Disabled; the .wsb reference lists Disable). Only one instance runs at a time, and it always uses the host's own Windows build.

Hyper-V or a disposable cloud VM

For real malware analysis or kernel work, use a full VM with checkpoints. Hyper-V Manager needs Pro or higher. On Windows 11 Home (codeAmani's main dev box), the practical choices are sbx or a short-lived cloud VM you destroy afterwards.


The nuke-and-rebuild script

Keep this next to the golden snapshot. It's the whole workflow in one file. A commented copy is in examples/reset-lab.ps1.

# D:\wsl\reset-lab.ps1
param(
  # No default for $Name: --unregister has no undo, so the caller must say it out loud.
  [Parameter(Mandatory)][string]$Name,
  [string]$Root     = "D:\wsl\lab",
  [string]$Snapshot = "D:\wsl\snapshots\lab-clean.tar.gz"
)

$env:WSL_UTF8 = 1   # otherwise wsl.exe output is UTF-16 and every match fails

if (-not (Test-Path $Snapshot)) { throw "No snapshot at $Snapshot" }
if ($Name -match '^Ubuntu') { throw "Refusing to nuke an Ubuntu* distro; sandbox names should not start with Ubuntu" }

# Only tear down if it is actually registered.
if ((wsl --list --quiet) -contains $Name) {
  wsl --terminate  $Name
  wsl --unregister $Name
  if ($LASTEXITCODE -ne 0) { throw "unregister failed for $Name" }
}

New-Item -ItemType Directory -Force -Path $Root | Out-Null
wsl --import $Name $Root $Snapshot --version 2
if ($LASTEXITCODE -ne 0) { throw "import failed from $Snapshot" }

wsl --manage $Name --set-sparse true

Write-Host "Sandbox '$Name' rebuilt from $Snapshot"
wsl --list --verbose

And the one-way door, spelled out because it deserves it:

wsl --unregister lab

--unregister deletes the distro's root filesystem. There is no recycle bin, no undo, and no prompt. Type the distro name carefully: wsl --unregister Ubuntu and wsl --unregister lab are very close in muscle memory.


Scripting wsl.exe from agents and CI

wsl.exe emits UTF-16LE with no BOM by default, which turns into interleaved NUL bytes in any pipeline that assumes UTF-8 (the classic "why is my output U b u n t u"). Set WSL_UTF8 to 1. It's a plain setting, not a secret:

export WSL_UTF8=1
wsl.exe --list --verbose
$env:WSL_UTF8 = 1
wsl --list --verbose

Two more scripting notes:

Setting Value Where
WSL_UTF8 1 Shell environment. Makes wsl.exe print UTF-8
MSYS_NO_PATHCONV 1 Git Bash only. Stops path mangling of Windows paths

codeAmani notes

A sandbox is where risky things go, not where secrets go.

Official docs: