⚠️ SECURITY-#6: Fix shell injection risk and missing timeout in hasCli()/checkCliVersion() - #16
Merged
Merged
Conversation
…asCli/checkCliVersion
FernandoCelmer
commented
Aug 15, 2026
FernandoCelmer
left a comment
Member
Author
There was a problem hiding this comment.
Code issues found: 0
The fix is correct and well-scoped. Switching cp.exec() to cp.execFile() for both hasCli() and checkCliVersion() eliminates the shell injection surface introduced by interpolating pycodeloop.command into a shell string, and the 5 s timeout prevents indefinite startup stalls.
A few observations worth noting for the record:
installCli()/updateCli(): correctly left untouched. Their commands are constructed frombuildInstallCommand/buildUpdateCommand, which are fully hardcoded — no user input reaches them. They already carry a 180 s timeout.addUserScriptsDirToPath(): also usescp.execwith a Python one-liner, but the string is built exclusively fromprocess.platform— not user-controlled. No change needed.- SIGTERM vs SIGKILL:
execFilesendsSIGTERMon timeout by default. A process that ignoresSIGTERMcould outlive the 5 s window, but this is an acceptable tradeoff for a developer-controlled binary. AddingkillSignal: "SIGKILL"would make it more robust, though it is not a blocker.
Clean fix. Ready to merge.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
src/features/chat/chat.controller.ts: replacedcp.exec()calls that interpolated the user-controlledpycodeloop.commandsetting into a shell string withcp.execFile()calls using an explicit argument array, plus a 5 s timeout.Motivation and Context
hasCli()andcheckCliVersion()passedpycodeloop.command— a user-editable VS Code setting — directly into a shell string viacp.exec(). A value containing"or$()could break out of the quoted shell word and execute arbitrary commands. Additionally, neither call had a timeout, so a hung binary would stall extension startup indefinitely.installCli()andupdateCli()were not changed: their commands come frombuildInstallCommand/buildUpdateCommand(fully hardcoded, not user-controlled) and already carry a 180 s timeout.Closes #6
Types of changes
Checklist