OS Command Injection in @argos-ci/core via CI Branch Names
The @argos-ci/core package is vulnerable to OS command injection when processing unvalidated branch or reference names in environments where hasRemoteContentAccess is disabled, allowing arbitrary code execution on CI runners.
The @argos-ci/core package (version 6.2.0 and earlier) contains an OS command injection vulnerability located in the git interaction logic. When a project is configured with hasRemoteContentAccess: false, the Argos upload process triggers local Git commands, including git fetch and git merge-base, via Node.js execSync calls. The vulnerability arises because the branch name (input.ref) and other input parameters are interpolated into command strings without any sanitization or escaping.
Since execSync spawns a /bin/sh shell to execute the command, shell metacharacters provided in the CI branch name (such as $(), backticks, or ;) are interpreted and executed by the shell before the git process begins. An attacker who can influence the CI environment variables or the branch name of a triggered build - such as via a pull request - can execute arbitrary OS commands on the CI runner. This allows for the theft of repository secrets, tampering with build artifacts, or lateral movement within the CI infrastructure.
Attack Chain
- Attacker creates a malicious pull request or branch name containing shell metacharacters, such as
main$(touch /tmp/pwned). - The CI pipeline initiates an Argos upload process within an environment where
hasRemoteContentAccessis set tofalse. - The
argosCLI reads the malicious environment variable (e.g.,GITHUB_HEAD_REForARGOS_BRANCH) and passes it into the internalconfigobject. - The
upload.tsmodule callsgetMergeBaseCommitSha()using the attacker-controlled branch name as theheadparameter. - The
gitFetch()function inpackages/core/src/ci-environment/git.tsreceives the malicious string as therefinput. - The
execSync()function interpolates the malicious branch string into a shell command template literal. - The underlying
/bin/shshell evaluates the embedded command substitution, executing the attacker's payload on the CI runner.
Impact
Successful exploitation results in full OS command execution on the build runner with the permissions of the CI agent process. This typically includes access to sensitive environment variables (API keys, cloud credentials, and repository secrets). Organizations using Argos in CI environments without external remote access verification are at risk, particularly those that process builds from untrusted contributors or forks.
Recommendation
- Upgrade to a version of
@argos-ci/corethat replaces vulnerableexecSynctemplate-literal invocations withexecFileSyncusing discrete argument arrays to prevent shell interpolation. - In the interim, implement strict input validation on all CI branch and reference environment variables to allow only alphanumeric characters, dashes, and underscores.
- Review CI pipeline configurations to ensure that runners executing
argos uploaddo not have access to sensitive secrets, or migrate to workflows that utilizehasRemoteContentAccess: trueto avoid the vulnerable local Git code path.
Immediate actions
Audit CI pipeline configurations for Argos projects to determine if hasRemoteContentAccess is set to false
Mitigations
Upgrade @argos-ci/core to the latest patched version
CWE-78 / OS Command Injection