Skip to content

fix: harden command execution and replay script escaping#364

Merged
thymikee merged 3 commits intomainfrom
codex/fix-codeql-security-alerts
Apr 7, 2026
Merged

fix: harden command execution and replay script escaping#364
thymikee merged 3 commits intomainfrom
codex/fix-codeql-security-alerts

Conversation

@thymikee
Copy link
Copy Markdown
Contributor

@thymikee thymikee commented Apr 7, 2026

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

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 7, 2026

PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://callstackincubator.github.io/agent-device/pr-preview/pr-364/

Built to branch gh-pages at 2026-04-07 17:21 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

const candidate = cmd.trim();
if (!candidate || candidate.includes('\0')) return null;
if (path.isAbsolute(candidate)) return candidate;
if (candidate.includes('/') || candidate.includes('\\')) return null;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@thymikee thymikee merged commit 98069db into main Apr 7, 2026
15 of 16 checks passed
@thymikee thymikee deleted the codex/fix-codeql-security-alerts branch April 7, 2026 18:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant