Description
In scrub mode (auto-enabled when CI markers are present), the bash subprocess environment sanitizer strips well-known third-party provider keys (ANTHROPIC_API_KEY, OPENAI_API_KEY, cloud credentials, ...), but not MCode's own BYOK key variable MCODE_PROVIDER_API_KEY. In CI, every bash command the agent runs can read the user's own provider key, while equivalent Anthropic/OpenAI keys are protected.
Source evidence
Audited against the 0.4.12 source preview (release/extraction.json sourceRevision 9b9885e42a3cf1a3df1cfa52a46e4fdb034cfcee); line numbers refer to that revision.
BASH_SUBPROCESS_SCRUB selection rule (comment): "the parent process needs these for API calls / lazy SDK reads, but bash subprocesses never legitimately do" — packages/agent-core/src/bash-subprocess-env.ts:66-74; the list itself at lines 75-108.
MCODE_PROVIDER_API_KEY is the default BYOK env var name read by the parent for provider calls: packages/tui/src/cli/provider-command.ts:54 and :106.
- It is neither in
BASH_SUBPROCESS_SCRUB nor in Layer A's runtime-boundary strip (packages/shared/src/runtime-boundary-env.ts:25-95 covers only MAVIS_* / legacy runtime identity keys).
- Mode resolution: CI markers (
CI, GITHUB_ACTIONS) auto-select scrub — packages/agent-core/src/bash-subprocess-env.ts:166-187.
By the list's own stated rule, MCODE_PROVIDER_API_KEY qualifies exactly like ANTHROPIC_API_KEY: needed by the parent per-request, never legitimately needed by a bash subprocess.
Expected behavior
In scrub (and strict) mode, the runtime's own provider key variable is withheld from bash subprocesses, consistent with the other provider keys.
Suggested fix
Add MCODE_PROVIDER_API_KEY to BASH_SUBPROCESS_SCRUB (it is already matched by SENSITIVE_ENV_NAME_RE for strict mode, so only the scrub list needs the entry).
Note: custom --api-key-env <NAME> values cannot be covered by a fixed list; the default name is what can be fixed cheaply. A host-side option to extend the scrub list with the configured key-env name would cover the custom case.
Environment
Found by source audit; not runtime-reproduced. No real credentials involved.
Description
In
scrubmode (auto-enabled when CI markers are present), the bash subprocess environment sanitizer strips well-known third-party provider keys (ANTHROPIC_API_KEY,OPENAI_API_KEY, cloud credentials, ...), but not MCode's own BYOK key variableMCODE_PROVIDER_API_KEY. In CI, every bash command the agent runs can read the user's own provider key, while equivalent Anthropic/OpenAI keys are protected.Source evidence
Audited against the 0.4.12 source preview (
release/extraction.jsonsourceRevision9b9885e42a3cf1a3df1cfa52a46e4fdb034cfcee); line numbers refer to that revision.BASH_SUBPROCESS_SCRUBselection rule (comment): "the parent process needs these for API calls / lazy SDK reads, but bash subprocesses never legitimately do" —packages/agent-core/src/bash-subprocess-env.ts:66-74; the list itself at lines 75-108.MCODE_PROVIDER_API_KEYis the default BYOK env var name read by the parent for provider calls:packages/tui/src/cli/provider-command.ts:54and:106.BASH_SUBPROCESS_SCRUBnor in Layer A's runtime-boundary strip (packages/shared/src/runtime-boundary-env.ts:25-95covers onlyMAVIS_*/ legacy runtime identity keys).CI,GITHUB_ACTIONS) auto-selectscrub—packages/agent-core/src/bash-subprocess-env.ts:166-187.By the list's own stated rule,
MCODE_PROVIDER_API_KEYqualifies exactly likeANTHROPIC_API_KEY: needed by the parent per-request, never legitimately needed by a bash subprocess.Expected behavior
In
scrub(andstrict) mode, the runtime's own provider key variable is withheld from bash subprocesses, consistent with the other provider keys.Suggested fix
Add
MCODE_PROVIDER_API_KEYtoBASH_SUBPROCESS_SCRUB(it is already matched bySENSITIVE_ENV_NAME_REforstrictmode, so only thescrublist needs the entry).Note: custom
--api-key-env <NAME>values cannot be covered by a fixed list; the default name is what can be fixed cheaply. A host-side option to extend the scrub list with the configured key-env name would cover the custom case.Environment
Found by source audit; not runtime-reproduced. No real credentials involved.