CVE-2024-4941: Gradio Local File Inclusion Vulnerability

HIGH
Advisory Identifier: GHSA-6v6g-j5fq-hpvw
CVSS 7.5
CWE-20 CWE-22
Published
Advisory Summary

CVE-2024-4941 is a HIGH (CVSS 7.5) local file inclusion vulnerability (CWE-20: Improper Input Validation) affecting Gradio libraries in the PyPI ecosystem. The issue involves local file inclusion in gradio. Remediation is available by upgrading affected packages to version 4.31.3.

CVE-2024-4941 at a Glance

CVE Identifier CVE-2024-4941
GHSA Identifier GHSA-6v6g-j5fq-hpvw
Severity HIGH
CVSS v3.1 Base Score 7.5
CWE Classification CWE-20: Improper Input Validation
Affected Product Gradio
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 7.5

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:N/A:N).

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 None (I:N)
Availability None (A:N)

How to Fix CVE-2024-4941

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.31.3
pip install gradio>=4.31.3
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-4941, 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.31.3), 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-20: Improper Input Validation, where the product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly. 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 local file inclusion vulnerability exists in the JSON component of gradio-app/gradio and was discovered in version 4.25. The vulnerability arises from improper input validation in the `postprocess()` function within `gradio/components/json_component.py`, where a user-controlled string is parsed as JSON. If the parsed JSON object contains a `path` key, the specified file is moved to a temporary directory, making it possible to retrieve it later via the `/file=..` endpoint. This issue is due to the `processing_utils.move_files_to_cache()` function traversing any object passed to it, looking for a dictionary with a `path` key, and then copying the specified file to a temporary directory. The vulnerability can be exploited by an attacker to read files on the remote system, posing a significant security risk.

CVE-2024-4941 Affected Gradio Versions

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

References

Frequently Asked Questions

What is CVE-2024-4941?
CVE-2024-4941 is a security vulnerability in Gradio involving Local file inclusion in gradio under CWE-20: Improper Input Validation.
Which Gradio versions are affected?
Affected versions include releases prior to 4.31.3 across affected packages: gradio.
What version fixes CVE-2024-4941?
Upgrading to 4.31.3 (or the latest patched release for your respective branch) resolves the vulnerability.
Is gradio affected?
Yes, gradio is affected in releases prior to 4.31.3. Upgrade your dependency to 4.31.3 or later.
What is the CVSS score of CVE-2024-4941?
CVE-2024-4941 has a CVSS v3.1 base score of 7.5 (HIGH) with vector string CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N.
What CWE is associated with CVE-2024-4941?
CVE-2024-4941 is classified under CWE-20: Improper Input Validation (The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.).
How can I check PyPI dependencies for CVE-2024-4941?
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-6v6g-j5fq-hpvw",
  "modified" : "2025-10-15T15:49:07Z",
  "published" : "2024-06-06T18:30:58Z",
  "aliases" : [ "CVE-2024-4941" ],
  "summary" : "Local file inclusion in gradio",
  "details" : "A local file inclusion vulnerability exists in the JSON component of gradio-app/gradio and was discovered in version 4.25. The vulnerability arises from improper input validation in the `postprocess()` function within `gradio/components/json_component.py`, where a user-controlled string is parsed as JSON. If the parsed JSON object contains a `path` key, the specified file is moved to a temporary directory, making it possible to retrieve it later via the `/file=..` endpoint. This issue is due to the `processing_utils.move_files_to_cache()` function traversing any object passed to it, looking for a dictionary with a `path` key, and then copying the specified file to a temporary directory. The vulnerability can be exploited by an attacker to read files on the remote system, posing a significant security risk.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "gradio"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "4.31.3"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-4941"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/gradio-app/gradio/commit/ee1e2942e0a1ae84a08a05464e41c8108a03fa9c"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/gradio-app/gradio"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pypa/advisory-database/tree/main/vulns/gradio/PYSEC-2024-184.yaml"
  }, {
    "type" : "WEB",
    "url" : "https://huntr.com/bounties/39889ce1-298d-4568-aecd-7ae40c2ca58e"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-20", "CWE-22" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-06-06T22:13:47Z",
    "nvd_published_at" : "2024-06-06T18:15:18Z"
  }
}