Skip to content

[DOCS] CLAUDE_CODE_SUBPROCESS_ENV_SCRUB=1 environment variable is missing from the docs #38559

Closed

Description

@coygeek

Documentation Type

other

Documentation Location

https://code.claude.com/docs/en/env-vars

Section/Topic

Page URL Why affected
Environment variables https://code.claude.com/docs/en/env-vars Primary reference for all CLAUDE_CODE_* vars; CLAUDE_CODE_SUBPROCESS_ENV_SCRUB is absent from the table
Security https://code.claude.com/docs/en/security Documents built-in protections; credential scrubbing from subprocesses is a security control
Hooks https://code.claude.com/docs/en/hooks Hook commands run as subprocesses; users configuring hooks need to know this option exists
MCP https://code.claude.com/docs/en/mcp MCP stdio servers are explicitly called out as affected; no mention of the scrub flag

Current Documentation

The environment variables reference page (env-vars) lists all supported CLAUDE_CODE_* variables in a table. CLAUDE_CODE_SUBPROCESS_ENV_SCRUB is not listed anywhere in the table or in any prose on that page. The security, hooks, and MCP pages likewise make no mention of this flag or the credential-stripping behavior it enables.

What's Wrong or Missing?

CLAUDE_CODE_SUBPROCESS_ENV_SCRUB should be documented in the environment variables reference with a clear description of:

  • What setting it to 1 does (strips Anthropic API keys and cloud provider credentials from the environment inherited by subprocesses)
  • Which subprocess types are affected (Bash tool executions, hook commands, MCP stdio servers)
  • Which credential families are scrubbed (Anthropic keys such as ANTHROPIC_API_KEY, and cloud provider credentials such as AWS, GCP, and Azure env vars)

The security page should cross-reference this variable as part of the built-in protections for credential isolation in agentic contexts.

Suggested Improvement

  1. Open https://code.claude.com/docs/en/env-vars
  2. Search the page (Ctrl+F / Cmd+F) for SUBPROCESS_ENV_SCRUB
  3. Observe: no results
  4. Open https://code.claude.com/docs/en/security and repeat
  5. Observe: no results

Impact

Medium - Makes feature difficult to understand

Additional Context

  • Type: Missing documentation
  • Severity: High — a security-relevant feature added in v2.1.83 is entirely undiscoverable through the official docs

Activity

  1. coygeek commented on Apr 1, 2026

    @coygeek
    Author

    Issue #38559 Verification

    Title: [DOCS] CLAUDE_CODE_SUBPROCESS_ENV_SCRUB=1 environment variable is missing from the docs
    Issue Date: 2026-03-25
    Verification Date: 2026-04-01
    Status: PARTIALLY RESOLVED


    Issue Summary

    This issue reports that Claude Code's docs did not document the CLAUDE_CODE_SUBPROCESS_ENV_SCRUB environment variable in the environment-variables reference and did not cross-reference its subprocess credential-scrubbing behavior from the security, hooks, and MCP pages.


    Verification Results

    Claim 1: The env-vars page does not document CLAUDE_CODE_SUBPROCESS_ENV_SCRUB

    Status: RESOLVED

    At https://code.claude.com/docs/en/env-vars, line 123: "| CLAUDE_CODE_SUBPROCESS_ENV_SCRUB| Set to1to strip Anthropic and cloud provider credentials from subprocess environments (Bash tool, hooks, MCP stdio servers). The parent Claude process keeps these credentials for API calls, but child processes cannot read them, reducing exposure to prompt injection attacks that attempt to exfiltrate secrets via shell expansion.claude-code-actionsets this automatically whenallowed_non_write_users is configured".

    At https://code.claude.com/docs/en/changelog, line 182: "* Added CLAUDE_CODE_SUBPROCESS_ENV_SCRUB=1 to strip Anthropic and cloud provider credentials from subprocess environments (Bash tool, hooks, MCP stdio servers)".

    Verdict: The environment-variables reference now documents the variable, what setting it to 1 does, and which subprocess types it affects.


    Claim 2: The security page does not cross-reference this credential-scrubbing protection

    Status: UNRESOLVED

    At https://code.claude.com/docs/en/security, lines 23-30: "### Built-in protections", "* **Sandboxed bash tool**: [Sandbox](https://code.claude.com/docs/en/sandboxing) bash commands with filesystem and network isolation, reducing permission prompts while maintaining security. Enable with /sandbox to define boundaries where Claude Code can work autonomously", and the rest of the built-in protections list other security controls.

    At https://code.claude.com/docs/en/security, lines 42-44: "* **Permission system**: Sensitive operations require explicit approval", "* **Context-aware analysis**: Detects potentially harmful instructions by analyzing the full request", and "* **Input sanitization**: Prevents command injection by processing user inputs".

    At https://code.claude.com/docs/en/security, line 66: "* **Secure credential storage**: API keys and tokens are encrypted. See [Credential Management](https://code.claude.com/docs/en/authentication)".

    Verdict: The security page documents several built-in protections, but it still does not mention CLAUDE_CODE_SUBPROCESS_ENV_SCRUB or describe subprocess credential stripping as one of those protections.


    Claim 3: The hooks page does not mention the flag for hook subprocesses

    Status: UNRESOLVED

    At https://code.claude.com/docs/en/hooks, lines 13-17: "Hooks are user-defined shell commands, HTTP endpoints, or LLM prompts that execute automatically at specific points in Claude Code's lifecycle." and "For command hooks, input arrives on stdin."

    At https://code.claude.com/docs/en/hooks, lines 267-270: "* **[Command hooks](#command-hook-fields)** (type: "command"): run a shell command. Your script receives the event's [JSON input](#hook-input-and-output) on stdin and communicates results back through exit codes and stdout."

    At https://code.claude.com/docs/en/hooks, line 344: "Handlers run in the current directory with Claude Code's environment."

    Verdict: The hooks reference explains that command hooks are subprocesses and run with Claude Code's environment, but it still does not mention CLAUDE_CODE_SUBPROCESS_ENV_SCRUB or explain that this variable can strip sensitive credentials from those hook environments.


    Claim 4: The mcp page does not mention the flag for MCP stdio servers

    Status: UNRESOLVED

    At https://code.claude.com/docs/en/mcp, lines 284-286: "### Option 3: Add a local stdio server" and "Stdio servers run as local processes on your machine."

    At https://code.claude.com/docs/en/mcp, lines 293-305: "claude mcp add --transport stdio --env AIRTABLE_API_KEY=YOUR_KEY airtable" and "claude mcp add --transport stdio --env KEY=value myserver -- python server.py --port 8080 → runs python server.py --port 8080 with KEY=value in environment`".

    At https://code.claude.com/docs/en/mcp, lines 503-505: "Claude Code supports environment variable expansion in .mcp.json files, allowing teams to share configurations while maintaining flexibility for machine-specific paths and sensitive values like API keys."

    Verdict: The MCP page documents stdio servers as local subprocesses and discusses passing environment variables to them, but it still does not mention CLAUDE_CODE_SUBPROCESS_ENV_SCRUB or explain that stdio subprocesses are part of this credential-scrubbing feature.


    Current State

    Claim Status
    The env-vars page does not document CLAUDE_CODE_SUBPROCESS_ENV_SCRUB RESOLVED
    The security page does not cross-reference this credential-scrubbing protection UNRESOLVED
    The hooks page does not mention the flag for hook subprocesses UNRESOLVED
    The mcp page does not mention the flag for MCP stdio servers UNRESOLVED

    Suggested Fix

    Keep the current env-vars entry, and add short cross-references on the affected evergreen pages.

    • In security, add CLAUDE_CODE_SUBPROCESS_ENV_SCRUB to the built-in protections or prompt-injection section as an opt-in control that strips Anthropic and cloud-provider credentials from subprocess environments.
    • In hooks, note that command hooks run as subprocesses and that CLAUDE_CODE_SUBPROCESS_ENV_SCRUB=1 prevents those hook processes from inheriting Anthropic and cloud-provider credentials.
    • In mcp, note in the stdio-server section that the same variable applies to MCP stdio subprocesses.

    References


    Conclusion & Recommendation

    Primary Concern: Users still cannot find this subprocess credential-scrubbing protection from the related security, hooks, and MCP documentation pages.

    Resolution Status: UNRESOLVED

    Recommendation: KEEP OPEN

    The main environment-variables reference now documents CLAUDE_CODE_SUBPROCESS_ENV_SCRUB, so the issue is no longer fully current. However, the cross-references requested for the security, hooks, and MCP pages are still missing, so the broader documentation gap remains open.


  2. reopened this on Apr 1, 2026
  3. coygeek commented on Apr 28, 2026

    @coygeek
    Author

    Issue #38559 Verification

    Title: [DOCS] CLAUDE_CODE_SUBPROCESS_ENV_SCRUB=1 environment variable is missing from the docs
    Issue Date: (opened prior to verification)
    Verification Date: 2026-04-27
    Status: RESOLVED


    Issue Summary

    The reporter identified that CLAUDE_CODE_SUBPROCESS_ENV_SCRUB — a security-relevant environment variable introduced in v2.1.83 that strips Anthropic and cloud provider credentials from subprocess environments — was entirely absent from the official documentation pages (env-vars, security, hooks, MCP).


    Verification Results

    Claim 1: CLAUDE_CODE_SUBPROCESS_ENV_SCRUB is missing from the env-vars page

    • Status: RESOLVED
    • Evidence: The variable now appears in the environment variables reference table at env-vars.md line 140 with a full description: "Set to 1 to strip Anthropic and cloud provider credentials from subprocess environments (Bash tool, hooks, MCP stdio servers). The parent Claude process keeps these credentials for API calls, but child processes cannot read them, reducing exposure to prompt injection attacks that attempt to exfiltrate secrets via shell expansion. On Linux, this also runs Bash subprocesses in an isolated PID namespace so they cannot read host process environments via /proc; as a side effect, ps, pgrep, and kill cannot see or signal host processes. claude-code-action sets this automatically when allowed_non_write_users is configured"
    • Verdict: Fully documented with behavior, scope, platform specifics, and side effects.

    Claim 2: The security page should cross-reference this variable

    • Status: NOT ADDRESSED (minor)
    • Evidence: The security page does not explicitly mention CLAUDE_CODE_SUBPROCESS_ENV_SCRUB by name. However, the env-vars page provides the authoritative reference with security context built into the description.
    • Verdict: The primary concern (discoverability) is resolved. A cross-reference from the security page would be a nice-to-have enhancement but is not essential.

    Claim 3: The hooks and MCP pages should mention this option

    • Status: NOT ADDRESSED (minor)
    • Evidence: Neither the hooks page nor the MCP page explicitly reference this variable. The env-vars page lists all affected subprocess types (Bash tool, hooks, MCP stdio servers).
    • Verdict: The primary documentation gap is resolved. Cross-references from hooks/MCP pages are optional enhancements.

    Current State

    Location Documented? Details
    Environment variables Yes Full entry in the table (line 140) with behavior, scope, Linux PID namespace details, and auto-configuration by claude-code-action
    Changelog Yes Mentioned in two changelog entries (v2.1.83 and a later subprocess sandboxing entry)
    Security No No explicit cross-reference (minor gap)
    Hooks No No explicit cross-reference (minor gap)
    MCP No No explicit cross-reference (minor gap)

    Suggested Fix

    N/A — the primary documentation gap has been resolved. The env-vars page now contains a thorough entry for CLAUDE_CODE_SUBPROCESS_ENV_SCRUB.


    References


    Conclusion & Recommendation

    • Primary Concern: The environment variable CLAUDE_CODE_SUBPROCESS_ENV_SCRUB is now fully documented in the env-vars reference page with comprehensive details covering behavior, affected subprocess types, platform-specific behavior (Linux PID namespace), and auto-configuration by claude-code-action.
    • Resolution Status: The core issue — complete absence from documentation — is resolved.
    • Recommendation: Close as completed. Optional follow-up: consider adding cross-references from the security, hooks, and MCP pages for improved discoverability.
  4. github-actions commented on Jun 19, 2026

    @github-actions

    This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.

  5. locked as resolved and limited conversation to collaborators on Jun 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions