CVE-2023-51449: Gradio Gradio Makes The `/file` Secure Vulnerability

HIGH
Advisory Identifier: GHSA-6qm2-wpxq-7qh2
CVSS 8.6
CWE-22
Published
Advisory Summary

CVE-2023-51449 is a HIGH (CVSS 8.6) gradio makes the `/file` secure vulnerability (CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')) affecting Gradio libraries in the PyPI ecosystem. The issue involves gradio makes the `/file` secure against file traversal and server-side request forgery attacks. Remediation is available by upgrading affected packages to version 4.11.0.

CVE-2023-51449 at a Glance

CVE Identifier CVE-2023-51449
GHSA Identifier GHSA-6qm2-wpxq-7qh2
Severity HIGH
CVSS v3.1 Base Score 8.6
CWE Classification CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
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.1/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-2023-51449

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.11.0
pip install gradio>=4.11.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-2023-51449, 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.11.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-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal'), where the product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory. 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

Older versions of `gradio` contained a vulnerability in the `/file` route which made them susceptible to file traversal attacks in which an attacker could access arbitrary files on a machine running a Gradio app with a public URL (e.g. if the demo was created with `share=True`, or on Hugging Face Spaces) if they knew the path of files to look for. This was not possible through regular URLs passed into a browser, but it was possible through the use of programmatic tools such as `curl` with the `--pass-as-is` flag. Furthermore, the `/file` route in Gradio apps also contained a vulnerability that made it possible to use it for SSRF attacks. Both of these vulnerabilities have been fixed in `gradio==4.11.0`

CVE-2023-51449 Affected Gradio Versions

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

References

Frequently Asked Questions

What is CVE-2023-51449?
CVE-2023-51449 is a security vulnerability in Gradio involving Gradio makes the `/file` secure against file traversal and server-side request forgery attacks under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal').
Which Gradio versions are affected?
Affected versions include releases prior to 4.11.0 across affected packages: gradio.
What version fixes CVE-2023-51449?
Upgrading to 4.11.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.11.0. Upgrade your dependency to 4.11.0 or later.
What is the CVSS score of CVE-2023-51449?
CVE-2023-51449 has a CVSS v3.1 base score of 8.6 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:L/A:L.
What CWE is associated with CVE-2023-51449?
CVE-2023-51449 is classified under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') (The product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.).
How can I check PyPI dependencies for CVE-2023-51449?
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-6qm2-wpxq-7qh2",
  "modified" : "2024-02-16T21:52:40Z",
  "published" : "2023-12-21T18:24:28Z",
  "aliases" : [ "CVE-2023-51449" ],
  "summary" : "Gradio makes the `/file` secure against file traversal and server-side request forgery attacks",
  "details" : "Older versions of `gradio` contained a vulnerability in the `/file` route which made them susceptible to file traversal attacks in which an attacker could access arbitrary files on a machine running a Gradio app with a public URL (e.g. if the demo was created with `share=True`, or on Hugging Face Spaces) if they knew the path of files to look for. \n\nThis was not possible through regular URLs passed into a browser, but it was possible through the use of programmatic tools such as `curl` with the `--pass-as-is` flag. \n\nFurthermore,  the `/file` route in Gradio apps also contained a vulnerability that made it possible to use it for SSRF attacks.\n\nBoth of these vulnerabilities have been fixed in `gradio==4.11.0`",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/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.11.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/gradio-app/gradio/security/advisories/GHSA-6qm2-wpxq-7qh2"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2023-51449"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/gradio-app/gradio/commit/1b9d4234d6c25ef250d882c7b90e1f4039ed2d76"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/gradio-app/gradio/commit/7ba8c5da45b004edd12c0460be9222f5b5f5f055"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/gradio-app/gradio"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pypa/advisory-database/tree/main/vulns/gradio/PYSEC-2023-249.yaml"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-22" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2023-12-21T18:24:28Z",
    "nvd_published_at" : "2023-12-22T21:15:09Z"
  }
}