Skip to content

fix: eliminate shell injection patterns across clis#830

Open
jackwener wants to merge 5 commits intomainfrom
fix/shell-injection-cleanup
Open

fix: eliminate shell injection patterns across clis#830
jackwener wants to merge 5 commits intomainfrom
fix/shell-injection-cleanup

Conversation

@jackwener
Copy link
Copy Markdown
Owner

Summary

  • spotify/spotify.ts: openBrowser(url) was interpolating external URLs into shell commands (open "${url}"). Replaced with execFileSync('open', [url]) to prevent shell injection via crafted URLs.
  • chatgpt/ax.ts: activateChatGPT() used execSync with shell string interpolation for osascript calls. Replaced both with execFileSync('osascript', [...]).
  • chatgpt/ask.ts: Poll loop used execSync(\sleep ${pollInterval}`). Replaced with spawnSync('sleep', [String(pollInterval)])`.
  • record.ts: Fixed misleading "idempotent injection" comment — the function unpatch+re-patches on each call (safe to call multiple times, but not idempotent).

Follows up on #826 which fixed the same class of issues in engine.ts and fix.ts.

Test plan

  • npx tsc --noEmit passes
  • npm test — 541 passed, 1 skipped

- spotify/spotify.ts: replace shell-interpolated `open "${url}"` with
  execFileSync to prevent URL-based shell injection
- chatgpt/ax.ts: replace execSync shell strings with execFileSync for
  osascript calls (activate + delay)
- chatgpt/ask.ts: replace execSync `sleep` with spawnSync to avoid
  shell interpolation
- record.ts: fix misleading "idempotent injection" comment — the
  function is safe to call multiple times but not strictly idempotent
Same shell injection pattern as fix.ts — prompt with $, backticks,
or other metacharacters would be expanded by the shell when
interpolated into the command string.
- autoresearch/debug.ts: prompt via stdin instead of shell interpolation
- autoresearch/engine.ts: git commit via execFileSync instead of shell
  string with quote escaping
- autoresearch/eval-skill.ts: use execFileSync with argument array,
  pass prompt via stdin
- src/plugin.ts: use execFileSync for esbuild PATH lookup
@jackwener jackwener force-pushed the fix/shell-injection-cleanup branch from 015c159 to a359d2c Compare April 6, 2026 07:11
git add fails with fatal error when a pathspec glob doesn't match
any files (e.g. 'extension/src/**/*.ts' in repos without that dir).
Try each glob individually and skip non-matching ones silently.

Fixes regression from #826.
Windows `start` is a cmd.exe builtin, not an executable —
execFileSync('start', ...) would ENOENT. Route through
cmd.exe with /c flag instead.
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