Cause of and Solution for Commands Failing to Run When Strict Sandbox Mode Is Configured in Claude Code on Native Windows

Cause of and Solution for Commands Failing to Run When Strict Sandbox Mode Is Configured in Claude Code on Native Windows

In native Windows strict sandbox mode, Claude's preferred PowerShell tool is denied. Setting allowUnsandboxedCommands to true and denying the retry parameter lets it run while keeping control.
2026.12.03

This page has been translated by machine translation. View original

Introduction

Recently, several customers asked us: "Claude Code on Windows can no longer run any commands at all."

Upon checking, the affected customers' environments had strict sandbox mode configured through server-managed settings as follows:

  • sandbox.enabled: true
  • sandbox.allowUnsandboxedCommands: false
  • sandbox.failIfUnavailable: false

Since the same settings had apparently worked without problems until now, I suspected that some kind of specification change had been made to Claude Code.

So, I actually tested what happens when Claude Code with this configuration is run on native Windows.

Trying It Out

Environment

  • Windows Server 2022
  • Claude Code v2.1.334 (native install)
  • Claude Desktop v6.28899.6 (Code tab)
  • Git for Windows v2.56.1
  • An account in an organization that distributes strict sandbox mode via server-managed settings

I gave the following prompt to both the desktop app and the CLI.

node --version と python --version を実行して、結果を教えて

Results

Regardless of the platform, execution was denied. The error message also matched the one I had heard from the customers, so it seems the symptom was reproduced.

The command did not run. Strict sandbox mode is on, so no command may run outside the sandbox, and no sandbox is available on this computer. Only whoever manages the user's sandbox settings can change what strict mode allows here.

Looking at the tool execution history, Claude automatically chose the PowerShell tool, and that is what was being denied.

{"name": "PowerShell", "input": {"command": "node --version; python --version"}}

On the other hand, when I explicitly instructed it to use the Bash tool, the same command ran without any problems.

Cause

As a premise, the sandbox cannot be used in Claude Code on native Windows[1].

When Claude Code determines at startup that the sandbox is not enabled, it displays the following warning and starts the session with the sandbox off.

⚠ Sandbox disabled: sandbox is enabled but the Windows sandbox is not active on this session (feature gate off)
  Commands will run WITHOUT sandboxing. Network and filesystem restrictions will NOT be enforced.

Even in this state, commands from the Bash tool are executed as-is without a sandbox.

On the other hand, the PowerShell tool was designed so that execution outside the sandbox is denied when strict sandbox mode is applied.

When the PowerShell tool is enabled, Claude prefers PowerShell over Bash as the shell[2].
Because of this, it seems that every command appeared to fail in Windows environments.

Solutions

Set allowUnsandboxedCommands to true

Setting allowUnsandboxedCommands to true makes PowerShell tool commands run on Windows as well.

However, as a side effect, in environments such as macOS / Linux, commands that failed inside the sandbox can be retried outside the sandbox, which loosens control. For example, if communication to a domain not on the allowlist is denied, it could be retried from outside the sandbox and succeed in communicating.

To prevent retries, it is effective to reject the dangerouslyDisableSandbox parameter, which is automatically added on retry, with a deny rule.

{
  "sandbox": {
    "enabled": true,
    "allowUnsandboxedCommands": true
  },
  "permissions": {
    "deny": [
      "Bash(dangerouslyDisableSandbox:true)",
      "PowerShell(dangerouslyDisableSandbox:true)"
    ]
  }
}

When I tested it, the results were as follows.

Environment Instruction Without deny rule With deny rule
Windows Normal command Success Success
Windows Run with dangerouslyDisableSandbox: true specified in the PowerShell tool Success Denied
macOS Run with dangerouslyDisableSandbox: true specified in the Bash tool Success Denied

It seems the loosened control can be mostly restored this way.

However, with this configuration the sandbox can still be loosened from the repository's .claude/settings.json, so the loophole is not completely closed.

To also prevent this loophole, you need to set sandbox.network.allowManagedDomainsOnly to true in the managed settings, but since only administrators would then be able to change the domain allowlist settings, the operational burden increases.

Disable the PowerShell tool

On machines where Git for Windows is installed, there is also the option of setting the environment variable CLAUDE_CODE_USE_POWERSHELL_TOOL to 0.
This disables the PowerShell tool and runs commands through Git Bash, so commands will go through.

However, on machines without Git for Windows, the only shell is the PowerShell tool, so this method cannot be used[3].

Conclusion

In conclusion, if you are using strict sandbox mode in an environment where Windows and macOS are mixed, it seems best to set allowUnsandboxedCommands to true and add a rule that denies the dangerouslyDisableSandbox: true parameter.

If the sandbox were available on native Windows in the first place, things wouldn't be this complicated, so I can't help hoping that Claude Code adds support soon.

When I checked the internals of the latest Claude Code for this investigation, I saw signs that they seem to be working on support, so I personally suspect it will be supported in the near future!

脚注
  1. Configure the sandboxed Bash tool - Claude Code Docs ↩︎

  2. CHANGELOG.md - anthropics/claude-code ↩︎

  3. Advanced setup - Claude Code Docs ↩︎


Claudeならクラスメソッドにお任せください

クラスメソッドは、Anthropic社とリセラー契約を締結しています。各種製品ガイドから、業種別の活用法、フェーズごとのお悩み解決などサービス支援ページにまとめております。まずはご覧いただき、お気軽にご相談ください。

サービス詳細を見る

Share this article

AI白書