CVE-2021-43831: Gradio Files On The Host Computer Vulnerability

CRITICAL
Advisory Identifier: GHSA-rhq2-3vr9-6mcr
CVSS 8.3
CWE-22
Published
Advisory Summary

CVE-2021-43831 is a CRITICAL (CVSS 8.3) files on the host computer vulnerability (CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')) affecting Gradio libraries in the PyPI ecosystem. The issue involves files on the host computer can be accessed from the gradio interface. Remediation is available by upgrading affected packages to version 2.5.0.

CVE-2021-43831 at a Glance

CVE Identifier CVE-2021-43831
GHSA Identifier GHSA-rhq2-3vr9-6mcr
Severity CRITICAL
CVSS v3.1 Base Score 8.3
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.3

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

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

How to Fix CVE-2021-43831

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: 2.5.0
pip install gradio>=2.5.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-2021-43831, 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 2.5.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

### Impact This is a vulnerability that affects anyone who creates and publicly shares Gradio interfaces using `gradio<2.4.8`. Because of the way that static files were being served, someone who generated a public Gradio link and shared it with others would potentially be exposing the files on the computer that generated the link, while the link was active. An attacker would be able to view the contents of a file on the computer if they knew the exact relative filepath. We do not have any evidence that this was ever exploited, but we treated the issue seriously and immediately took steps to mitigate it (see below) ### Response 1. We worked with @haby0 to immediately patch the issue and released a new version, `gradio 2.5.0`, within 24 hours of the issue being brought to our attention 2. We enabled a notification that is printed to anyone using an older version of gradio telling them to upgrade (see screenshot below) 3. We expanded our test suite to test for this vulnerability ensuring that our patch does not get reverted in future releases of `gradio` ![image](https://user-images.githubusercontent.com/1778297/146251425-f36b519b-6d4a-4dfb-8d89-c1ed005979d3.png) ### Patches The problem has been patched in `gradio>=2.5.0`.

CVE-2021-43831 Affected Gradio Versions

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

References

Frequently Asked Questions

What is CVE-2021-43831?
CVE-2021-43831 is a security vulnerability in Gradio involving Files on the host computer can be accessed from the Gradio interface 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 2.5.0 across affected packages: gradio.
What version fixes CVE-2021-43831?
Upgrading to 2.5.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is gradio affected?
Yes, gradio is affected in releases prior to 2.5.0. Upgrade your dependency to 2.5.0 or later.
What is the CVSS score of CVE-2021-43831?
CVE-2021-43831 has a CVSS v3.1 base score of 8.3 (CRITICAL) with vector string CVSS:3.1/AV:A/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:L.
What CWE is associated with CVE-2021-43831?
CVE-2021-43831 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-2021-43831?
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-rhq2-3vr9-6mcr",
  "modified" : "2024-11-18T16:26:18Z",
  "published" : "2022-01-21T23:43:33Z",
  "aliases" : [ "CVE-2021-43831" ],
  "summary" : "Files on the host computer can be accessed from the Gradio interface",
  "details" : "### Impact\nThis is a vulnerability that affects anyone who creates and publicly shares Gradio interfaces using `gradio<2.4.8`. Because of the way that static files were being served, someone who generated a public Gradio link and shared it with others would potentially be exposing the files on the computer that generated the link, while the link was active. An attacker would be able to view the contents of a file on the computer if they knew the exact relative filepath. We do not have any evidence that this was ever exploited, but we treated the issue seriously and immediately took steps to mitigate it (see below)\n\n### Response\n1. We worked with @haby0 to immediately patch the issue and released a new version, `gradio 2.5.0`, within 24 hours of the issue being brought to our attention \n2. We enabled a notification that is printed to anyone using an older version of gradio telling them to upgrade (see screenshot below)\n3. We expanded our test suite to test for this vulnerability ensuring that our patch does not get reverted in future releases of `gradio`\n\n![image](https://user-images.githubusercontent.com/1778297/146251425-f36b519b-6d4a-4dfb-8d89-c1ed005979d3.png)\n\n### Patches\nThe problem has been patched in `gradio>=2.5.0`.\n",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:A/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:L"
  }, {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:H/VA:L/SC:N/SI:N/SA:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "gradio"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "2.5.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/gradio-app/gradio/security/advisories/GHSA-rhq2-3vr9-6mcr"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-43831"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/gradio-app/gradio/commit/41bd3645bdb616e1248b2167ca83636a2653f781"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/gradio-app/gradio"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pypa/advisory-database/tree/main/vulns/gradio/PYSEC-2021-873.yaml"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-22" ],
    "severity" : "CRITICAL",
    "github_reviewed" : true,
    "github_reviewed_at" : "2022-01-18T21:15:21Z",
    "nvd_published_at" : "2021-12-15T20:15:00Z"
  }
}