fix(core): prevent OS command injection via CI branch names (GHSA-4x45-gxvp-6283)#319
Merged
Merged
Conversation
…5-gxvp-6283) Attacker-controlled CI branch/ref strings were interpolated into execSync() template literals in the git CI-environment helpers. Since execSync runs the command through /bin/sh -c, shell metacharacters such as $() were evaluated before git ran, letting anyone who could influence a branch name (e.g. via a PR) execute arbitrary commands on the CI runner. Replace the shell-interpolating execSync calls with execFileSync using argument arrays, which spawn git directly and never invoke a shell. Covers all four injectable sinks: gitFetch, gitMergeBase, listShas and listParentCommits. Adds a regression test that feeds a $() payload through getMergeBaseCommitSha and asserts the injected command does not run. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
Summary
Fixes GHSA-4x45-gxvp-6283 — OS command injection (CWE-78, CVSS 7.5) in
@argos-ci/core.Attacker-controlled CI branch/ref strings flowed unsanitized into
execSync()template literals inpackages/core/src/ci-environment/git.ts. BecauseexecSyncruns the command through/bin/sh -c, shell metacharacters such as$(), backticks, and;were evaluated beforegitran. An attacker who could influence a branch name (e.g. by opening a PR, or viaGITHUB_HEAD_REF/ARGOS_BRANCH) could execute arbitrary commands on the CI runner whenever a project hadhasRemoteContentAccess: false.Fix
Replaced every shell-interpolating
execSyncthat handles user data withexecFileSync("git", [...args]), which spawnsgitdirectly with an argument array and never invokes a shell. This covers all four injectable sinks (the advisory named two):gitFetch— the primary sinkgitMergeBase— the secondary sinklistShas— interpolated a ref/pathlistParentCommits— interpolatedinput.shaStatic, no-input calls (
rev-parse,config --get) were left as-is since they carry no injectable data.Test
Added a regression test in
git.test.tsmirroring the PoC: it sets up a temp git repo with a realorigin, callsgetMergeBaseCommitShawith a branch name containing$(touch <marker>), and asserts the marker file is not created.Verified the test is meaningful — it fails against the original vulnerable code (the marker gets created) and passes with the fix.
tscandprettierare clean.🤖 Generated with Claude Code