#15615: fix(security): restrict PATH override to exact match in node-host sanitizeEnv
stale
size: XL
## Summary
- `sanitizeEnv()` in node-host accepted any PATH value ending with the current base PATH
- This allowed prepending arbitrary directories (e.g., `/tmp/evil:/usr/local/bin:/usr/bin`)
- An authenticated caller could shadow allowlisted binaries with attacker-controlled executables
## Fix
- Only accept PATH overrides that exactly match the current base PATH
- Reject any attempt to prepend or modify PATH directories
## Test plan
- [x] Existing node-host tests pass
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR updates environment sanitization in the node-host runner to prevent PATH shadowing: instead of allowing any PATH value that ends with the base PATH, it now only accepts PATH overrides that exactly match the base PATH and rejects any prepending/modification attempts.
It also adjusts process command-queue logic/tests to ensure pending promises are rejected when clearing the command lane, avoiding hangs/leaked awaits when the queue is reset.
<h3>Confidence Score: 4/5</h3>
- This PR is largely safe to merge, with one behavioral edge case around PATH handling to confirm/fix.
- The security change correctly blocks PATH prepending, and the command-queue change cleanly rejects cleared queued entries with a test. The remaining concern is that PATH overrides are now silently ignored when empty or when basePath is empty, which can leave an unintended inherited PATH in effect and may not match the intended security posture.
- src/node-host/runner.ts
<sub>Last reviewed commit: 1c6a7fb</sub>
<!-- greptile_other_comments_section -->
**Context used:**
- Context from `dashboard` - CLAUDE.md ([source](https://app.greptile.com/review/custom-context?memory=fd949e91-5c3a-4ab5-90a1-cbe184fd6ce8))
- Context from `dashboard` - AGENTS.md ([source](https://app.greptile.com/review/custom-context?memory=0d0c8278-ef8e-4d6c-ab21-f5527e322f13))
<!-- /greptile_comment -->
Most Similar PRs
#9200: Fix: Strip dangerous env vars from baseEnv in host execution
by vishaltandale00 · 2026-02-05
82.2%
#21733: security(exec): platform-aware allowlist matching and restricted sa...
by Esubaalew · 2026-02-20
78.2%
#19931: Config: merge PATH env vars and bootstrap Windows bins
by Kemalau · 2026-02-18
77.8%
#8161: fix(sandbox): block dangerous environment variables from Docker con...
by yubrew · 2026-02-03
76.3%
#10714: fix: handle Windows PATH case-sensitivity in node register invoke
by Yida-Dev · 2026-02-06
74.6%
#7085: test: skip flaky workspace-paths & safe-bins tests on non-Linux/CI ...
by ThinkIbrokeIt · 2026-02-02
74.5%
#10708: fix: handle Windows PATH case-sensitivity in exec environment
by Yida-Dev · 2026-02-06
74.5%
#21668: fix(config): block dangerous environment variable keys from config ...
by AI-Reviewer-QS · 2026-02-20
74.3%
#6064: fix(daemon): prefer bundled node from install-cli.sh over system node
by joyshmitz · 2026-02-01
74.2%
#8517: Browser: sandbox download/trace paths
by coygeek · 2026-02-04
74.1%