Skip to content

fix(external): replace execSync with execFileSync to prevent command injection#309

Merged
jackwener merged 3 commits intojackwener:mainfrom
0xsline:fix/external-execsync-injection-clean
Mar 23, 2026
Merged

fix(external): replace execSync with execFileSync to prevent command injection#309
jackwener merged 3 commits intojackwener:mainfrom
0xsline:fix/external-execsync-injection-clean

Conversation

@0xsline
Copy link
Copy Markdown
Contributor

@0xsline 0xsline commented Mar 23, 2026

Summary

  • Replace execSync(cmd) with execFileSync(binary, args) in installExternalCli to prevent command injection from YAML config files
  • Add parseCommand() helper that safely tokenizes command strings, respecting quoted segments
  • Reject commands containing shell operators (&&, ||, |, ;, >, <, backticks) with a clear error message
  • Remove unused execSync import

Motivation

The cmd string passed to execSync originates from YAML config files (install.mac, install.linux, etc.). If a malicious YAML is loaded via plugin, this is a command injection vector. execFileSync does not invoke a shell, eliminating this risk.

Test plan

  • 309/309 existing tests pass
  • opencli doctor still works after change
  • External CLI auto-install (e.g. gh) still functions correctly

@jackwener
Copy link
Copy Markdown
Owner

Reviewed and pushed two follow-up fixes onto this branch:

  • keep the execFileSync hardening, but retry with .cmd on Windows so npm install -g ... keeps working
  • add focused tests for parseCommand / Windows fallback
  • restore the missing docs/adapters/desktop/doubao-app.md page so docs-build passes again

Local validation: npm run typecheck, npm test, npm run docs:build.

@jackwener jackwener force-pushed the fix/external-execsync-injection-clean branch from fbe9799 to ec3d892 Compare March 23, 2026 16:38
@jackwener
Copy link
Copy Markdown
Owner

@0xsline Thanks for the contribution. The core security direction was right; I pushed a small follow-up for Windows compatibility and rebased it onto current , then verified , , and . Merging now.

@jackwener jackwener merged commit 41aedf6 into jackwener:main Mar 23, 2026
12 checks passed
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.

2 participants