claude-code - 💡(How to fix) Fix CLAUDE_CODE_SUBPROCESS_ENV_SCRUB should not override permission mode

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

When CLAUDE_CODE_SUBPROCESS_ENV_SCRUB is set, Claude Code forces the permission mode back to default, even when --dangerously-skip-permissions is explicitly passed. This couples two orthogonal concerns.

Error Message

$ claude --dangerously-skip-permissions
⚠ Permission mode forced to default — CLAUDE_CODE_SUBPROCESS_ENV_SCRUB is set (allowed_non_write_users hardening). Declare allowedTools explicitly, or set CLAUDE_CODE_SUBPROCESS_ENV_SCRUB=0 to opt out.

Root Cause

When CLAUDE_CODE_SUBPROCESS_ENV_SCRUB is set, Claude Code forces the permission mode back to default, even when --dangerously-skip-permissions is explicitly passed. This couples two orthogonal concerns.

Code Example

$ claude --dangerously-skip-permissions
Permission mode forced to defaultCLAUDE_CODE_SUBPROCESS_ENV_SCRUB is set (allowed_non_write_users hardening). Declare allowedTools explicitly, or set CLAUDE_CODE_SUBPROCESS_ENV_SCRUB=0 to opt out.
RAW_BUFFERClick to expand / collapse

Summary

When CLAUDE_CODE_SUBPROCESS_ENV_SCRUB is set, Claude Code forces the permission mode back to default, even when --dangerously-skip-permissions is explicitly passed. This couples two orthogonal concerns.

Observed behavior

$ claude --dangerously-skip-permissions
⚠ Permission mode forced to default — CLAUDE_CODE_SUBPROCESS_ENV_SCRUB is set (allowed_non_write_users hardening). Declare allowedTools explicitly, or set CLAUDE_CODE_SUBPROCESS_ENV_SCRUB=0 to opt out.

Expected behavior

CLAUDE_CODE_SUBPROCESS_ENV_SCRUB should only control whether sensitive environment variables are scrubbed before being passed to subprocesses. It should not override the user's explicit permission mode selection.

These protect against different threat vectors:

  • Env scrubbing: prevents secrets (API keys, tokens) from leaking to subprocesses
  • Permission mode: controls whether tools require user approval before execution

Coupling them means users who want env scrubbing (reasonable security hygiene) are forced to also lose control over their permission model, with no way to opt into one without the other.

Suggested fix

Decouple the two behaviors:

  • CLAUDE_CODE_SUBPROCESS_ENV_SCRUB controls env var sanitization only
  • --dangerously-skip-permissions (or allowedTools) controls the permission model independently

extent analysis

TL;DR

Decoupling the CLAUDE_CODE_SUBPROCESS_ENV_SCRUB environment variable from the permission mode selection is likely to resolve the issue.

Guidance

  • Review the current implementation to identify where the coupling between CLAUDE_CODE_SUBPROCESS_ENV_SCRUB and permission mode selection is occurring.
  • Modify the code to ensure that CLAUDE_CODE_SUBPROCESS_ENV_SCRUB only controls environment variable sanitization, without affecting the permission model.
  • Introduce a separate mechanism to control the permission model independently, allowing users to opt into env scrubbing without losing control over their permission settings.
  • Verify the changes by testing the --dangerously-skip-permissions flag with CLAUDE_CODE_SUBPROCESS_ENV_SCRUB set, to ensure the permission mode is not forced to default.

Example

No code snippet is provided as the issue does not contain sufficient implementation details.

Notes

The suggested fix assumes that the current implementation can be modified to decouple the two behaviors. If the issue is due to a third-party library or external dependency, additional steps may be required to resolve the issue.

Recommendation

Apply a workaround by setting CLAUDE_CODE_SUBPROCESS_ENV_SCRUB=0 to opt out of env scrubbing, allowing for independent control over the permission model, until a permanent fix is implemented.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

CLAUDE_CODE_SUBPROCESS_ENV_SCRUB should only control whether sensitive environment variables are scrubbed before being passed to subprocesses. It should not override the user's explicit permission mode selection.

These protect against different threat vectors:

  • Env scrubbing: prevents secrets (API keys, tokens) from leaking to subprocesses
  • Permission mode: controls whether tools require user approval before execution

Coupling them means users who want env scrubbing (reasonable security hygiene) are forced to also lose control over their permission model, with no way to opt into one without the other.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix CLAUDE_CODE_SUBPROCESS_ENV_SCRUB should not override permission mode