fix: replace execSync string interpolation with execFileSync to prevent command injection#48
Merged
shreyas-lyzr merged 1 commit intoopen-gitagent:mainfrom Mar 25, 2026
Conversation
…nt command injection execSync with template strings passes user-supplied URL, branch, repo, and subPath values through the shell, allowing an attacker to inject arbitrary shell commands (e.g. a malicious git URL like `foo; rm -rf /`). Switch to execFileSync with explicit argument arrays in git-cache.ts and registry-provider.ts so arguments are never interpreted by the shell. Also replace the remaining execSync rm -rf call with rmSync.
b4350f8 to
2058a95
Compare
Contributor
|
Reviewed and merged. Clean security fix — execSync with string interpolation → execFileSync with array args eliminates command injection on user-supplied repo URLs and branch names. Also good catch replacing |
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.
What
Replace
execSynccalls that use template-string interpolation withexecFileSync(argument array form) insrc/utils/git-cache.tsandsrc/utils/registry-provider.ts. Also replace a leftoverexecSync(\rm -rf ...`)withrmSync`.Why
execSyncwith template strings passes values through the shell. User-supplied inputs — the git repository URL (--source), branch name (--branch), GitHub skill ref (owner/repo#path) — are interpolated directly into the shell command string. An attacker controlling these values can inject arbitrary shell commands, for example:execFileSyncwith an explicit argument array bypasses the shell entirely, so metacharacters in any argument are treated as literal data.Affected call sites (all severity 10):
git-cache.tsline 34 —git ls-remotewith user-supplied URLgit-cache.tsline 95 —git clonewith user-supplied URL + branchregistry-provider.tsline 189 —git clone --sparsewith user-supplied reporegistry-provider.tsline 190 —git sparse-checkoutwith user-supplied subPathregistry-provider.tsline 197 —rm -rf(replaced withrmSync)registry-provider.tsline 204 —git clonewith user-supplied repoHow Tested
npm run buildpassesgitagent validatepasses on example agentsManually verified the argument arrays produce identical git invocations with a local test repo.
Checklist