fix: harden command execution and replay script escaping#364
Conversation
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2cabd9b4cd
ℹ️ 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".
src/utils/exec.ts
Outdated
| const candidate = cmd.trim(); | ||
| if (!candidate || candidate.includes('\0')) return null; | ||
| if (path.isAbsolute(candidate)) return candidate; | ||
| if (candidate.includes('/') || candidate.includes('\\')) return null; |
There was a problem hiding this comment.
Permit relative executable paths in command normalization
normalizeExecutableLookup now rejects any non-absolute command containing / or \\, so valid relative executables like ./tool are rejected with INVALID_ARGS before spawn. This is a behavioral regression for existing call sites that accept user-provided binary paths without resolving them first (for example AGENT_DEVICE_MACOS_HELPER_BIN in src/platforms/ios/macos-helper.ts), and for any workflow that intentionally runs repo-local helpers from the current directory.
Useful? React with 👍 / 👎.
Summary
Harden command execution helpers so command lookup and process launches never go through a shell.
Use full JSON string serialization for replay/session context headers so device labels with quotes or backslashes round-trip safely.
Validation
pnpm test -- src/utils/tests/exec.test.ts src/daemon/tests/session-store.test.ts src/daemon/handlers/tests/session-replay-script.test.ts
pnpm format
pnpm check:unit
pnpm check:quick