Repository navigation
PTY child process inherits the daemon environment unsanitized - #1554
Conversation
Spawned agent CLIs (claude, codex, gemini, pi, opencode) previously inherited the daemon's full environment, exposing any secrets present there to third-party binaries. CommandBuilder::env_clear() now wipes the inherited environment before spawn; a fixed base allowlist (HOME, PATH, TERM, SHELL, LANG, USER) plus each agent's declared auth env vars are the only variables forwarded, and only when actually set. Co-Authored-By: Claude <[email protected]>
Code Review SummaryThis is a small, well-scoped fix for a real security gap: PTY-spawned agent CLIs previously inherited the daemon's entire environment (confirmed — I independently re-ran Requirements Check
FindingsCritical IssuesNone. Suggested Improvements
Nitpicks
Answers to the specific review questions
RecommendationAPPROVE. This closes a genuine, previously-confirmed security gap with a minimal, correct, well-tested change. No critical or blocking issues found. The two Suggested Improvements ( |
|
Review recommendation: APPROVE. (Note: |
- Added TMPDIR to BASE_ENV_ALLOWLIST — some Node/Bun-based agent CLIs rely on it for scratch files; the daemon-side value is safe to forward and costs nothing to include. - Replaced raw set_var/remove_var pairs in tests with an EnvVarGuard that removes the var on Drop, so a panic mid-test no longer leaks a fake env var into later tests in the same process. Skipped (non-blocking, judged not worth the change): USER/SHELL in the base allowlist being unused by the current 5 agent CLIs — harmless to keep, and useful if a future agent CLI's shell-out behavior needs them. Addresses reviewer recommendations from PR #1554 review.
Addressed review feedbackBoth non-blocking suggestions from the review were applied in 474913f:
Skipped: none — both suggestions were small and cheap enough to just do.
Re-Review DecisionDecision: NO RE-REVIEW NEEDED Rationale: Both changes are minor, low-risk, mechanical (one const addition, one test-only refactor with no behavior change to production code). No new functionality, no architectural changes, no critical/important findings were in play — the original review already recommended APPROVE. Ready for merge pending maintainer approval (self-approval is blocked by GitHub for the PR author). |
Closes #1521