CVE-2024-1540: Gradio Gradio's CI Vulnerable To Command Vulnerability

HIGH
Advisory Identifier: GHSA-xcgp-r7r8-2hc9
CVSS 8.6
CWE-77
Published
Advisory Summary

CVE-2024-1540 is a HIGH (CVSS 8.6) gradio's ci vulnerable to command vulnerability (CWE-77: Improper Neutralization of Special Elements used in a Command ('Command Injection')) affecting Gradio libraries in the PyPI ecosystem. The issue involves gradio's ci vulnerable to command injection. Remediation is available by upgrading affected packages to version 4.18.0.

CVE-2024-1540 at a Glance

CVE Identifier CVE-2024-1540
GHSA Identifier GHSA-xcgp-r7r8-2hc9
Severity HIGH
CVSS v3.1 Base Score 8.6
CWE Classification CWE-77: Improper Neutralization of Special Elements used in a Command ('Command Injection')
Affected Product Gradio
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 8.6

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:L/A:L).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity Low (I:L)
Availability Low (A:L)

How to Fix CVE-2024-1540

To remediate this vulnerability, upgrade all affected Gradio dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

gradio fixed: 4.18.0
pip install gradio>=4.18.0
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

pip show gradio

How to Check if You Are Affected

To determine whether your Python environment is affected by CVE-2024-1540, inspect your installed packages using pip:

pip show gradio

Analyze the terminal output to locate any version of Gradio in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 4.18.0), your application is affected.

Note: The pip show gradio command checks currently installed packages in your active Python environment.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-77: Improper Neutralization of Special Elements used in a Command ('Command Injection'), where the product constructs all or part of a command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended command when it is sent to a downstream component. In Gradio, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

A command injection vulnerability exists in the deploy+test-visual.yml workflow of the gradio-app/gradio repository, due to improper neutralization of special elements used in a command. This vulnerability allows attackers to execute unauthorized commands, potentially leading to unauthorized modification of the base repository or secrets exfiltration. The issue arises from the unsafe handling of GitHub context information within a an action definition which is evaluated and substituted before script execution. Remediation involves setting untrusted input values to intermediate environment variables to prevent direct influence on script generation.

CVE-2024-1540 Affected Gradio Versions

1 component(s)
Fixed Versions:
4.18.0
Product / Package Ecosystem Affected Versions Fixed Version
gradio
PyPI
< 4.18.0
4.18.0

References

Frequently Asked Questions

What is CVE-2024-1540?
CVE-2024-1540 is a security vulnerability in Gradio involving Gradio's CI vulnerable to Command Injection under CWE-77: Improper Neutralization of Special Elements used in a Command ('Command Injection').
Which Gradio versions are affected?
Affected versions include releases prior to 4.18.0 across affected packages: gradio.
What version fixes CVE-2024-1540?
Upgrading to 4.18.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is gradio affected?
Yes, gradio is affected in releases prior to 4.18.0. Upgrade your dependency to 4.18.0 or later.
What is the CVSS score of CVE-2024-1540?
CVE-2024-1540 has a CVSS v3.1 base score of 8.6 (HIGH) with vector string CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:L/A:L.
What CWE is associated with CVE-2024-1540?
CVE-2024-1540 is classified under CWE-77: Improper Neutralization of Special Elements used in a Command ('Command Injection') (The product constructs all or part of a command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended command when it is sent to a downstream component.).
How can I check PyPI dependencies for CVE-2024-1540?
Run the dependency tree command: 'pip show gradio'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-xcgp-r7r8-2hc9",
  "modified" : "2024-04-16T15:50:40Z",
  "published" : "2024-03-27T18:32:38Z",
  "withdrawn" : "2024-03-27T21:57:19Z",
  "aliases" : [ "CVE-2024-1540" ],
  "summary" : "Gradio's CI vulnerable to Command Injection",
  "details" : "A command injection vulnerability exists in the deploy+test-visual.yml workflow of the gradio-app/gradio repository, due to improper neutralization of special elements used in a command. This vulnerability allows attackers to execute unauthorized commands, potentially leading to unauthorized modification of the base repository or secrets exfiltration. The issue arises from the unsafe handling of GitHub context information within a an action definition which is evaluated and substituted before script execution. Remediation involves setting untrusted input values to intermediate environment variables to prevent direct influence on script generation.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:L/A:L"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "gradio"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "4.18.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-1540"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/gradio-app/gradio/commit/d56bb28df80d8db1f33e4acf4f6b2c4f87cb8b28"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/gradio-app/gradio"
  }, {
    "type" : "WEB",
    "url" : "https://huntr.com/bounties/0e39e974-9a66-476f-91f5-3f37abb03d77"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-77" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-03-27T21:56:42Z",
    "nvd_published_at" : "2024-03-27T16:15:09Z"
  }
}