[BUG] /sandbox reports as unsupported in Linux when run under WSL2
Open 💬 17 comments Opened Oct 29, 2025 by ianfiske
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet (issue by another user was erroneously closed without investigation)
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
> /sandbox
⎿ Error: Sandboxing is currently only supported on macOS and
Linux
even though
$ uname -a
Linux 6.6.87.2-microsoft-standard-WSL2 #1 SMP PREEMPT_DYNAMIC Thu Jun 5 18:30:46 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux
What Should Happen?
/sandbox should enable sandbox mode
Error Messages/Logs
Steps to Reproduce
Start Ubuntu in WSL2 under Windows 11.
start claude
do /sandbox
Claude Model
Sonnet (default)
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.0.28
Platform
Anthropic API
Operating System
Ubuntu/Debian Linux
Terminal/Shell
VS Code integrated terminal
Additional Information
I am re-opening https://github.com/anthropics/claude-code/issues/10038 because this was closed without a valid explanation.
WSL2 _is_ Linux and all other Linux commands do work. Please confirm if sandbox functionality can be enabled in WSL2. This is a major feature for Windows users who rely on WSL to give a great developer experience inside of Windows.
17 Comments
Found 1 possible duplicate issue:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
I can confirm that the bug is present even after running
sudo apt install bubblewrapin WSL (as bubblewrap is documented as being the underlying mechanism for sandboxing).From Claude Code itself:
<hr/>
Technical Analysis of WSL2 Sandbox Detection Issue
I've done some reverse engineering of the Claude Code binary to understand why sandboxing is rejected on WSL2 despite it being functionally equivalent to native Linux.
Investigation Findings
Platform Detection Logic (from
cli.js):The code checks if the platform is in the allowed list
["macos","linux"], and for Linux specifically, it verifies thatbwrapandsocatare available.System Status on WSL2:
All prerequisites are met:
process.platformreturns"linux"bwrapis installed and availablesocatis installed and availableRoot Cause:
Despite Node.js correctly identifying WSL2 as Linux (
process.platform === "linux"), Claude Code appears to have an additional check that explicitly rejects WSL environments. This is likely done by:/proc/versionfor "microsoft" or "WSL" strings, ORos.release()which returns"6.6.87.2-microsoft-standard-WSL2", ORThe platform detection function
HB()must be returning something other than"linux"when it detects WSL, causing theF0Q()check to fail.Conclusion:
This appears to be an intentional but overly restrictive check. WSL2 is a legitimate Linux environment with full system call compatibility, and the required sandboxing tools (
bwrap,socat) work correctly on it.Recommendation: Relax the platform check to allow WSL2, or at minimum provide a way for users to override this restriction with an environment variable or config flag.
This might be because of :
Claude code looks at that kernel release string, sees "microsoft" or "WSL", and throws the error?
It would be great to fix as WSL2 is microVM and bubblewrap should work on it without issues
Are there any updates regarding this? It seems to be a pretty large security hole for a large community of users.
I asked Claude Code to patch out it's own WSL2 check, and it seems to work. The first attempt was pretty heavy-handed, but the second try was more surgical and swapped out
Microsoft->Micros0ftandwsl->ws1in 10 locations.Perhaps not a _good_ idea, but...might be fine until we get an official patch. 🤷
I'm having the same issue, can't use sandbox on wsl2😵
Getting this issue too. Any news?
Also having this issue - would really appreciate a permanent fix:)
I'm also facing the same issue on OS release 5.15.167.4-microsoft-standard-WSL2. Any news on the same?
+1
+1
Editing the binary works just fine:
After that the sandbox is fine. No warranty on the quality of the sandbox. Maybe there is a good reason it is turned off on wsl2.
For whatever reason using LD_PRELOAD to hide the strings WSL and Microsoft from
uname()does not fix it.The official docs claim WSL2 support via bubblewrap. https://code.claude.com/docs/en/sandboxing#os-level-enforcement
This is a recent fix. The latest binaries work with wsl2 out of the box.
Claude Code 2.1.71 on WSL2
bwrap and socat verified installed
settings.json correctly configured at ~/.claude/settings.json with both enabled: true and mode: auto-allow
/sandbox menu shows dependencies installed but no Mode/Overrides options
/config shows no sandbox entry at all
--sandbox CLI flag doesn't exist
Settings file is being read (correct Linux $HOME, correct ownership) but sandbox key is silently ignored