fix(exec): protect pathPrepend against posix login-shell RC overrides#81403
Conversation
|
Codex review: needs changes before merge. Workflow note: Future ClawSweeper reviews update this same comment in place. How this review workflow works
Summary Reproducibility: yes. source inspection gives a high-confidence reproduction path: current main applies PR rating Rank-up moves:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. Real behavior proof Risk before merge
Maintainer options:
Copy recommended automerge instructionNext step before merge Security Review findings
Review detailsBest possible solution: Land the shell-time PATH prepend approach after the docs and whitespace cleanup, with maintainer acceptance that Do we have a high-confidence way to reproduce the issue? Yes, source inspection gives a high-confidence reproduction path: current main applies Is this the best way to solve the issue? Yes with cleanup: applying the prepend inside the shell command via an environment variable is the right runtime boundary for this bug. The remaining fixes are docs placement and whitespace validation, not a different product design. Label changes:
Label justifications:
Full review comments:
Overall correctness: patch is correct Acceptance criteria:
What I checked:
Likely related people:
Codex review notes: model gpt-5.5, reasoning high; reviewed against 016c34ff1d2a. |
There was a problem hiding this comment.
Pull request overview
This PR aims to ensure tools.exec.pathPrepend retains highest PATH precedence on POSIX hosts even when shell startup files (e.g., ~/.zshenv) rewrite PATH, by moving the prepend enforcement into the shell command that ultimately runs.
Changes:
- Add
removePathPrepend()helper to strip existing prepended entries from a PATH string. - Thread
pathPrependthrough exec host/gateway execution and wrap POSIX commands with anexport PATH=...prologue. - Add/update unit tests and docs describing the new precedence protection behavior.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/infra/path-prepend.ts | Adds removePathPrepend() to remove configured prepends from an existing PATH string. |
| src/infra/path-prepend.test.ts | Adds coverage for removePathPrepend() behavior (normal, tampered, duplicates, whitespace). |
| src/agents/bash-tools.exec.ts | Threads pathPrepend into runtime/gateway execution and clears inherited OPENCLAW_PREPEND_PATH before applying prepends. |
| src/agents/bash-tools.exec-runtime.ts | Introduces a POSIX command wrapper intended to re-prepend PATH after shell startup and strips duplicates from base env. |
| src/agents/bash-tools.exec-host-gateway.ts | Passes pathPrepend through gateway allowlist execution into runExecProcess(). |
| src/agents/bash-tools.exec-runtime.test.ts | Adds a unit test asserting the wrapped command string contains the PATH export prologue. |
| src/agents/bash-tools.test.ts | Adds a new PATH-handling test intended to simulate RC-file PATH overrides. |
| docs/tools/exec.md | Documents that tools.exec.pathPrepend is applied inside the shell command to prevent RC startup overrides. |
815f531 to
0989a5c
Compare
0989a5c to
918bf13
Compare
|
ClawSweeper PR egg ✨ Hatched: ✨ glimmer Gilded Signal Puff Hatch commandComment Hatchability rules:
Rarity: ✨ glimmer. What is this egg doing here?
|
918bf13 to
7c79e0f
Compare
7c79e0f to
874fa90
Compare
|
Merged via squash.
Thanks @medns! |
…openclaw#81403) Merged via squash. Prepared head SHA: 874fa90 Co-authored-by: medns <[email protected]> Co-authored-by: odysseus0 <[email protected]> Reviewed-by: @odysseus0
…openclaw#81403) Merged via squash. Prepared head SHA: 874fa90 Co-authored-by: medns <[email protected]> Co-authored-by: odysseus0 <[email protected]> Reviewed-by: @odysseus0
…openclaw#81403) Merged via squash. Prepared head SHA: 874fa90 Co-authored-by: medns <[email protected]> Co-authored-by: odysseus0 <[email protected]> Reviewed-by: @odysseus0
…openclaw#81403) Merged via squash. Prepared head SHA: 874fa90 Co-authored-by: medns <[email protected]> Co-authored-by: odysseus0 <[email protected]> Reviewed-by: @odysseus0
…openclaw#81403) Merged via squash. Prepared head SHA: 874fa90 Co-authored-by: medns <[email protected]> Co-authored-by: odysseus0 <[email protected]> Reviewed-by: @odysseus0
…openclaw#81403) Merged via squash. Prepared head SHA: 874fa90 Co-authored-by: medns <[email protected]> Co-authored-by: odysseus0 <[email protected]> Reviewed-by: @odysseus0
…openclaw#81403) Merged via squash. Prepared head SHA: 874fa90 Co-authored-by: medns <[email protected]> Co-authored-by: odysseus0 <[email protected]> Reviewed-by: @odysseus0
…openclaw#81403) Merged via squash. Prepared head SHA: 874fa90 Co-authored-by: medns <[email protected]> Co-authored-by: odysseus0 <[email protected]> Reviewed-by: @odysseus0
…openclaw#81403) Merged via squash. Prepared head SHA: 874fa90 Co-authored-by: medns <[email protected]> Co-authored-by: odysseus0 <[email protected]> Reviewed-by: @odysseus0
…openclaw#81403) Merged via squash. Prepared head SHA: 874fa90 Co-authored-by: medns <[email protected]> Co-authored-by: odysseus0 <[email protected]> Reviewed-by: @odysseus0
…openclaw#81403) Merged via squash. Prepared head SHA: 874fa90 Co-authored-by: medns <[email protected]> Co-authored-by: odysseus0 <[email protected]> Reviewed-by: @odysseus0
Summary
tools.exec.pathPrependentries can be unexpectedly overridden or pushed down the priority list by user login-shell configuration files (like~/.zshenvor/etc/zshenv) during shell startup.pathPrependconfig is intended to guarantee that specific tools (likeconfig/binor user-defined overrides) take absolute precedence during execution, but RC file execution defeats this guarantee.OPENCLAW_PREPEND_PATHnatively into thePATHright before the target command executes (export PATH="${OPENCLAW_PREPEND_PATH}:$PATH"; unset OPENCLAW_PREPEND_PATH; <command>).Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
Real behavior proof (required for external PRs)
tools.exec.pathPrependworks reliably regardless of user~/.zshenvsetups.~/.zshenvtools.exec.pathPrependto["/custom/bin"].~/.zshenvto containexport PATH="/evil/bin:$PATH"./exec host=gatewayand thenecho $PATHin an OpenClaw Chat.Terminal output of the executed command inside the OpenClaw environment: