fix: strip skill-injected env vars from ACP harness spawn env (#36280)#36316
fix: strip skill-injected env vars from ACP harness spawn env (#36280)#36316vincentkoc merged 5 commits intoopenclaw:mainfrom
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a60ac95d1d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Greptile SummaryThis PR fixes a credential-leak bug where skill-injected env vars (e.g., Key points:
Confidence Score: 5/5
Last reviewed commit: a60ac95 |
Skill apiKey entries (e.g., openai-image-gen with primaryEnv=OPENAI_API_KEY) are set on process.env during agent runs and only reverted after the run completes. ACP harnesses like Codex CLI inherit these vars, causing them to silently use API billing instead of their own auth (e.g., OAuth). The fix tracks which env vars are actively injected by skill overrides in a module-level Set (activeSkillEnvKeys) and strips them in resolveAcpClientSpawnEnv() before spawning ACP child processes. Fixes openclaw#36280
a60ac95 to
2894f9d
Compare
|
Rebased this branch onto current The active diff is now just the ACP env-leak fix, targeted lifecycle coverage for skill-injected env keys, and the changelog entry with attribution. I also fixed the stale Local verification on the rebased branch:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2894f9da73
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…aw#36280) (openclaw#36316) * fix: strip skill-injected env vars from ACP harness spawn env Skill apiKey entries (e.g., openai-image-gen with primaryEnv=OPENAI_API_KEY) are set on process.env during agent runs and only reverted after the run completes. ACP harnesses like Codex CLI inherit these vars, causing them to silently use API billing instead of their own auth (e.g., OAuth). The fix tracks which env vars are actively injected by skill overrides in a module-level Set (activeSkillEnvKeys) and strips them in resolveAcpClientSpawnEnv() before spawning ACP child processes. Fixes openclaw#36280 * ACP: type spawn env for stripped keys * Skills: cover active env key lifecycle * Changelog: note ACP skill env isolation * ACP: preserve shell marker after env stripping --------- Co-authored-by: Vincent Koc <[email protected]>
…aw#36280) (openclaw#36316) * fix: strip skill-injected env vars from ACP harness spawn env Skill apiKey entries (e.g., openai-image-gen with primaryEnv=OPENAI_API_KEY) are set on process.env during agent runs and only reverted after the run completes. ACP harnesses like Codex CLI inherit these vars, causing them to silently use API billing instead of their own auth (e.g., OAuth). The fix tracks which env vars are actively injected by skill overrides in a module-level Set (activeSkillEnvKeys) and strips them in resolveAcpClientSpawnEnv() before spawning ACP child processes. Fixes openclaw#36280 * ACP: type spawn env for stripped keys * Skills: cover active env key lifecycle * Changelog: note ACP skill env isolation * ACP: preserve shell marker after env stripping --------- Co-authored-by: Vincent Koc <[email protected]>
…aw#36280) (openclaw#36316) * fix: strip skill-injected env vars from ACP harness spawn env Skill apiKey entries (e.g., openai-image-gen with primaryEnv=OPENAI_API_KEY) are set on process.env during agent runs and only reverted after the run completes. ACP harnesses like Codex CLI inherit these vars, causing them to silently use API billing instead of their own auth (e.g., OAuth). The fix tracks which env vars are actively injected by skill overrides in a module-level Set (activeSkillEnvKeys) and strips them in resolveAcpClientSpawnEnv() before spawning ACP child processes. Fixes openclaw#36280 * ACP: type spawn env for stripped keys * Skills: cover active env key lifecycle * Changelog: note ACP skill env isolation * ACP: preserve shell marker after env stripping --------- Co-authored-by: Vincent Koc <[email protected]>
…aw#36280) (openclaw#36316) * fix: strip skill-injected env vars from ACP harness spawn env Skill apiKey entries (e.g., openai-image-gen with primaryEnv=OPENAI_API_KEY) are set on process.env during agent runs and only reverted after the run completes. ACP harnesses like Codex CLI inherit these vars, causing them to silently use API billing instead of their own auth (e.g., OAuth). The fix tracks which env vars are actively injected by skill overrides in a module-level Set (activeSkillEnvKeys) and strips them in resolveAcpClientSpawnEnv() before spawning ACP child processes. Fixes openclaw#36280 * ACP: type spawn env for stripped keys * Skills: cover active env key lifecycle * Changelog: note ACP skill env isolation * ACP: preserve shell marker after env stripping --------- Co-authored-by: Vincent Koc <[email protected]>
…aw#36280) (openclaw#36316) * fix: strip skill-injected env vars from ACP harness spawn env Skill apiKey entries (e.g., openai-image-gen with primaryEnv=OPENAI_API_KEY) are set on process.env during agent runs and only reverted after the run completes. ACP harnesses like Codex CLI inherit these vars, causing them to silently use API billing instead of their own auth (e.g., OAuth). The fix tracks which env vars are actively injected by skill overrides in a module-level Set (activeSkillEnvKeys) and strips them in resolveAcpClientSpawnEnv() before spawning ACP child processes. Fixes openclaw#36280 * ACP: type spawn env for stripped keys * Skills: cover active env key lifecycle * Changelog: note ACP skill env isolation * ACP: preserve shell marker after env stripping --------- Co-authored-by: Vincent Koc <[email protected]>
…aw#36280) (openclaw#36316) * fix: strip skill-injected env vars from ACP harness spawn env Skill apiKey entries (e.g., openai-image-gen with primaryEnv=OPENAI_API_KEY) are set on process.env during agent runs and only reverted after the run completes. ACP harnesses like Codex CLI inherit these vars, causing them to silently use API billing instead of their own auth (e.g., OAuth). The fix tracks which env vars are actively injected by skill overrides in a module-level Set (activeSkillEnvKeys) and strips them in resolveAcpClientSpawnEnv() before spawning ACP child processes. Fixes openclaw#36280 * ACP: type spawn env for stripped keys * Skills: cover active env key lifecycle * Changelog: note ACP skill env isolation * ACP: preserve shell marker after env stripping --------- Co-authored-by: Vincent Koc <[email protected]>
…aw#36280) (openclaw#36316) (cherry picked from commit ae96a81)
…aw#36280) (openclaw#36316) (#1733) (cherry picked from commit ae96a81) Co-authored-by: Drew Wagner <[email protected]>
Summary
Fixes #36280 — Skill
apiKeyentries leak as provider env vars (e.g.,OPENAI_API_KEY) to ACP harness child processes, causing Codex CLI to silently use API billing instead of OAuth.Root Cause
applySkillConfigEnvOverrides()sets skill API keys onprocess.env(e.g.,OPENAI_API_KEYfromopenai-image-gen'sprimaryEnv) at the start of an agent run and only reverts them in thefinallyblock after the run completes. During the run,resolveAcpClientSpawnEnv()spreadsprocess.envinto the child process env, so ACP harnesses like Codex CLI inherit the leaked keys.Fix
Track injected keys: Added a module-level
activeSkillEnvKeysSet inenv-overrides.tsthat tracks which env vars are currently injected by skill overrides. The set is populated when keys are applied and cleared when the reverter runs.Strip on ACP spawn: Extended
resolveAcpClientSpawnEnv()to accept an optionalstripKeysset. The call site increateAcpClient()passes the active skill env keys so they're stripped from the child process environment.No config changes needed: The fix is automatic — no user configuration required.
Changed Files
src/agents/skills/env-overrides.ts— AddedactiveSkillEnvKeystracking +getActiveSkillEnvKeys()exportsrc/acp/client.ts— ExtendedresolveAcpClientSpawnEnv()withstripKeysoption; call site passes skill env keyssrc/acp/client.test.ts— 2 new tests forstripKeysbehaviorsrc/agents/skills/env-overrides.test.ts— New test file forgetActiveSkillEnvKeys()Testing
All existing tests pass. New tests verify:
baseEnvis not mutated