GHSA-g85v-wf27-67xc #
Summary #
| Field | Value |
|---|---|
| CVE | CVE-2024-52587 |
| Affected Action | step-security/harden-runner |
| Severity | Low (CVSS 2.7) |
| Vulnerability Type | OS Command Injection (CWE-78) |
| Published | November 18, 2024 |
Vulnerability Description #
The step-security/harden-runner action (versions prior to v2.10.2) contains multiple command injection vulnerabilities in its internal implementation through environment variable manipulation. The action uses Node.js’s execSync function with shell-interpreted commands that include unsanitized environment variables.
CVSS v4 Metrics:
- Severity: Low (2.7/10)
- Attack Vector: Network
- Attack Complexity: Low
- Privileges Required: None
- User Interaction: None
- Impact: Low across Confidentiality, Integrity, and Availability
Affected Versions: All versions < 2.10.2
Patched Version: 2.10.2
Likelihood of Exploitation: Low
The advisory states: “due to the current execution order of pre-steps in GitHub Actions and the placement of harden-runner as the first step in a job, the likelihood of exploitation is low as the Harden-Runner action reads the environment variable during the pre-step stage.”
Current Status: No known exploits exist.
Six Specific Injection Points Identified:
setup.ts:169 - Uses
execSyncwith interpolatedprocess.env.USERvariable, allowing shell expression injection through user variable manipulationsetup.ts:229 - Similar vulnerability using
$USERfor shell-level interpolationarc-runner.ts:40-44 -
execSyncwith multiple string interpolations, potentially injectable viaRUNNER_TEMPthroughgetRunnerTempDir()arc-runner.ts:53 - Same weakness pattern as item 3
arc-runner.ts:57 - Identical vulnerability to items 3-4
arc-runner.ts:61 - Same injection vector as previous arc-runner instances
Vulnerable Code Pattern:
// Vulnerable code inside the action
execSync(`command ${process.env.USER} ${process.env.RUNNER_TEMP}`)
If an attacker can control the USER or RUNNER_TEMP environment variables (e.g., through a compromised runner or malicious actions running before harden-runner), they can inject arbitrary commands.
Vulnerable Pattern #
- name: Harden Runner
uses: step-security/harden-runner@v2.6.0
with:
egress-policy: audit
# The vulnerability is internal to the action's implementation
# There's no visible vulnerable pattern in the workflow file
The workflow appears normal, but the action contains vulnerable code internally.
sisakulint Detection Result #
script/actions/advisory/GHSA-g85v-wf27-67xc-vulnerable.yaml:9:3: dangerous trigger (critical): workflow uses privileged trigger(s) [pull_request_target] without any security mitigations. These triggers grant write access and secrets access to potentially untrusted code. Add at least one mitigation: restrict permissions (permissions: read-all or permissions: {}), use environment protection, add label conditions, or check github.actor. See https://sisaku-security.github.io/lint/docs/rules/dangeroustriggersrulecritical/ [dangerous-triggers-critical]
script/actions/advisory/GHSA-g85v-wf27-67xc-vulnerable.yaml:15:9: Action 'step-security/harden-runner@v2.6.0' has a known medium severity vulnerability (GHSA-mxr3-8whj-j74r): Harden-Runner allows evasion of 'disable-sudo' policy. Upgrade to version 2.12.0 or later. See: https://github.com/advisories/GHSA-mxr3-8whj-j74r [known-vulnerable-actions]
script/actions/advisory/GHSA-g85v-wf27-67xc-vulnerable.yaml:15:9: Action 'step-security/harden-runner@v2.6.0' has a known low severity vulnerability (GHSA-g85v-wf27-67xc): Harden-Runner has a command injection weaknesses in `setup.ts` and `arc-runner.ts`. Upgrade to version 2.10.2 or later. See: https://github.com/advisories/GHSA-g85v-wf27-67xc [known-vulnerable-actions]
Analysis #
| Detected | Rule | Category Match |
|---|---|---|
| Yes | known-vulnerable-actions | Yes |
| Yes | dangerous-triggers-critical | Yes |
sisakulint successfully detects this vulnerability through multiple rules:
- KnownVulnerableActionsRule - Identifies
step-security/harden-runner@v2.6.0as having the known vulnerability GHSA-g85v-wf27-67xc and alerts users to upgrade to version 2.10.2 or later - DangerousTriggersCriticalRule - Flags the unsafe
pull_request_targettrigger without security mitigations
Reason for Detection #
This vulnerability CAN be detected by static analysis because:
- Known Vulnerable Actions Database: sisakulint maintains a database of known vulnerable actions from GitHub Security Advisories
- Version-based detection: The vulnerability affects specific version ranges that can be identified from the
uses:declaration - Action-specific advisory: The advisory specifically identifies the vulnerable action and version
- Automated remediation: The tool can suggest upgrading to the patched version
Mitigation #
The vulnerability was fixed in version 2.10.2 of step-security/harden-runner. Users should:
Update to version 2.10.2 or later:
- uses: step-security/harden-runner@v2.10.2 with: egress-policy: auditPin actions to specific commit SHAs to prevent version rollback attacks
Audit the order of actions in workflows - Actions running before security tools can potentially manipulate the environment
Use trusted runners and avoid running untrusted code on the same runner as security tools
Technical Fix Details #
Recommended Remediation Approach:
The advisory suggests:
- Replace
execSynccalls withexecFileSyncto bypass shell evaluation and prevent command injection - For file operations in arc-runner, use native NodeJS
fsAPI calls instead of subprocess invocations - Eliminate shell interpretation of untrusted environment variables
Version 2.10.2 Changes:
Files Modified:
src/arc-runner.test.ts- Test file modifications, removed vulnerable test patternssrc/arc-runner.ts- Core functionality updates with sanitized executionsrc/cleanup.ts- Cleanup process changessrc/index.ts- Main entry point updatessrc/setup.ts- Setup process modifications with proper sanitizationdist/index.js,dist/post/index.js,dist/pre/index.js(and source maps) - Compiled bundles
Key Implementation Changes:
- Removed test code that referenced
process.env["isTest"]and unsafe endpoint handling - Simplified ARC (Actions Runner Controller) runner detection functionality
- Applied proper sanitization to environment variable usage before shell execution
- Updated bundled JavaScript files to reflect source code security improvements
EPSS Score: 1.158% (78th percentile) - Low probability of exploitation in the next 30 days
Credits: Vulnerability discovered and reported by @woodruffw, who provided thorough analysis and collaborated on the fix.