fix: allowlist the pi subprocess environment (GHSA-38vh parity) - #135
Conversation
The pi subprocess inherited the full daemon env — including codeoid's own secrets (ZeroID root key, OAuth HMAC, Telegram token), the exact GHSA-38vh vector the Claude subprocess already guards against. - New shared buildSubprocessEnv (providers/env.ts): safe basics + proxy/ TLS trust + per-provider policy (exact/prefix/suffix) + the CODEOID_AGENT_ENV_ALLOW escape hatch. buildAgentEnv (claude) now delegates to it with its historical allowlist - buildPiEnv: major provider namespaces + PI_/LC_ prefixes + the *_API_KEY/*_API_TOKEN credential shapes (pi spans ~60 providers — enumerating each var is unmaintainable); AWS_/other uncommon vars are escape-hatch-only - Daemon-owned namespaces (CODEOID_/ZEROID_/TELEGRAM_) are DENIED even when a pattern matches — found during test-writing that CODEOID_API_KEY (the ZeroID root key) ends in _API_KEY and would have ridden pi's credential-suffix rule. Only the explicit operator escape hatch overrides the deny-list - Unit coverage for basics, deny-beats-pattern, escape-hatch precedence, and claude-delegation behavior; docs updated
|
Warning Review limit reached
Next review available in: 54 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (6)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #135 +/- ##
==========================================
+ Coverage 81.54% 81.57% +0.03%
==========================================
Files 94 95 +1
Lines 16376 16406 +30
==========================================
+ Hits 13354 13384 +30
Misses 3022 3022
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
What
The pi subprocess (#132) inherited the daemon's full environment — including codeoid's own secrets (ZeroID root key, OAuth HMAC, Telegram bot token). That's the same local-privilege-escalation vector (GHSA-38vh v3) the Claude subprocess already guards with
buildAgentEnv. This PR brings pi to parity and extracts the mechanism so future backends get it for free.buildSubprocessEnv(new sharedproviders/env.ts): safe basics (PATH/HOME/locale/proxy/TLS trust) + a per-provider policy (exact names, prefixes, suffixes) + the existingCODEOID_AGENT_ENV_ALLOWoperator escape hatch. Claude'sbuildAgentEnvnow delegates with its historical allowlist (behavior unchanged, covered by a delegation test).buildPiEnv: major provider namespaces (ANTHROPIC_,OPENAI_,GOOGLE_,GEMINI_), pi's ownPI_namespace, POSIX locale, and the conventional credential shapes*_API_KEY/*_API_TOKEN— pi spans ~60 providers, so shape-matching beats an unmaintainable enumeration. Uncommon vars (AWS_*for Bedrock,AZURE_*) are escape-hatch-only, documented indocs/providers-pi.md.CODEOID_API_KEY— the ZeroID root key — which ends in_API_KEYand would have ridden pi's credential-suffix rule straight into the subprocess. The fix is a deny-list for daemon-owned namespaces (CODEOID_,ZEROID_,TELEGRAM_) that beats every pattern match; only the explicit, exact-name operator escape hatch can override it. Leaking the root key now requires a deliberate operator action, never a pattern accident.Tests
provider-env.test.ts: shared basics pass / unlisted drop, escape-hatch precedence, pi credential prefixes + suffix shapes, AWS excluded by default, deny-beats-suffix forCODEOID_API_KEY, hatch-overrides-deny, and Claude delegation keeping its historical behavior. The pi integration suite (fake-pi) still passes under the allowlisted env, which also proves the allowlist keeps a working pi spawn. 1192 tests green; tsc + biome clean.🤖 Generated with Claude Code