CVE-2021-43831: Gradio: path traversal exposes host filesystem to users
HIGHPoC AVAILABLENUCLEI TEMPLATEAny team running Gradio < 2.5.0 for ML demos or model prototyping is exposing their host filesystem to anyone with the link — including cloud credentials, model weights, and training data. Patch to 2.5.0+ immediately and audit what was accessible on any public-facing Gradio instance. If the instance ran on a cloud VM, rotate all credentials and API keys stored on that host.
What is the risk?
High risk for AI/ML teams running shared demo environments. The CVSS Scope:Changed modifier is critical here — the vulnerable Gradio process can expose files belonging to the underlying OS, not just its own data. Low attack complexity and low privilege requirement mean any user with the Gradio URL can attempt exploitation without technical sophistication. ML demo environments are particularly dangerous targets because they frequently co-locate model weights, training datasets, .env files with API keys (HuggingFace tokens, OpenAI keys, cloud credentials), and SSH keys on the same host.
What systems are affected?
| Package | Ecosystem | Vulnerable Range | Patched |
|---|---|---|---|
| Gradio | pip | — | No patch |
Do you use Gradio? You're affected.
How severe is it?
What is the attack surface?
What should I do?
6 stepsImmediate: Upgrade all Gradio instances to >= 2.5.0 (patch released 2021-12-15).
If upgrade not immediately possible: restrict Gradio interfaces to authenticated internal networks only — remove public sharing links.
Credential rotation: assume any Gradio instance running < 2.5.0 was compromised; rotate all secrets accessible on the host (API keys, cloud credentials, SSH keys).
Detection: audit web server logs for Gradio instances for unusual file path parameters or directory traversal sequences (../, %2e%2e%2f).
Inventory: identify all Gradio deployments in your environment using package management tools (pip list, requirements.txt scanning).
Preventive control: enforce file sandbox restrictions (chroot, Docker with limited mounts) for any ML demo/serving framework.
How is it classified?
Which compliance frameworks are affected?
This CVE is relevant to:
Frequently Asked Questions
What is CVE-2021-43831?
Any team running Gradio < 2.5.0 for ML demos or model prototyping is exposing their host filesystem to anyone with the link — including cloud credentials, model weights, and training data. Patch to 2.5.0+ immediately and audit what was accessible on any public-facing Gradio instance. If the instance ran on a cloud VM, rotate all credentials and API keys stored on that host.
Is CVE-2021-43831 actively exploited?
Proof-of-concept exploit code is publicly available for CVE-2021-43831, increasing the risk of exploitation.
How to fix CVE-2021-43831?
1. Immediate: Upgrade all Gradio instances to >= 2.5.0 (patch released 2021-12-15). 2. If upgrade not immediately possible: restrict Gradio interfaces to authenticated internal networks only — remove public sharing links. 3. Credential rotation: assume any Gradio instance running < 2.5.0 was compromised; rotate all secrets accessible on the host (API keys, cloud credentials, SSH keys). 4. Detection: audit web server logs for Gradio instances for unusual file path parameters or directory traversal sequences (../, %2e%2e%2f). 5. Inventory: identify all Gradio deployments in your environment using package management tools (pip list, requirements.txt scanning). 6. Preventive control: enforce file sandbox restrictions (chroot, Docker with limited mounts) for any ML demo/serving framework.
What systems are affected by CVE-2021-43831?
This vulnerability affects the following AI/ML architecture patterns: ml demos and prototyping, model serving, inference servers, training pipelines, data science workstations.
What is the CVSS score for CVE-2021-43831?
CVE-2021-43831 has a CVSS v3.1 base score of 7.7 (HIGH). The EPSS exploitation probability is 3.85%.
What is the AI security impact?
Affected AI Architectures
MITRE ATLAS Techniques
AML.T0025Exfiltration via Cyber MeansAML.T0035AI Artifact CollectionAML.T0037Data from Local SystemAML.T0049Exploit Public-Facing ApplicationCompliance Controls Affected
What are the technical details?
Original Advisory
Gradio is an open source framework for building interactive machine learning models and demos. In versions prior to 2.5.0 there is a vulnerability that affects anyone who creates and publicly shares Gradio interfaces. File paths are not restricted and users who receive a Gradio link can access any files on the host computer if they know the file names or file paths. This is limited only by the host operating system. Paths are opened in read only mode. The problem has been patched in gradio 2.5.0.
Exploitation Scenario
An adversary conducting ML supply chain reconnaissance shares a legitimate Gradio-powered model demo link (or finds one publicly exposed). With knowledge of common file paths, they craft requests targeting /etc/passwd to enumerate users, then ~/.ssh/id_rsa for SSH keys, /home/user/.env or /opt/app/.env for API credentials (HuggingFace tokens, OpenAI keys), and ~/.config/gcloud/credentials.json for cloud access. Since Gradio interfaces are frequently run by data scientists on personal workstations or shared GPU instances with broad file system access, the adversary can exfiltrate proprietary model weights, training datasets, and cloud credentials — enabling lateral movement, IP theft, or training data poisoning in follow-on operations.
Weaknesses (CWE)
CWE-22Improper Limitation of a Pathname to a Restricted DirectoryPrimaryCWE-22Improper Limitation of a Pathname to a Restricted DirectoryCWE-22 — Improper Limitation of a Pathname to a Restricted Directory: 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.
- [Implementation] Assume all input is malicious. Use an "accept known good" input validation strategy, i.e., use a list of acceptable inputs that strictly conform to specifications. Reject any input that does not strictly conform to specifications, or transform it into something that does. When performing input validation, consider all potentially relevant properties, including length, type of input, the full range of acceptable values, missing or extra inputs, syntax, consistency across related fields, and conformance to business rules. As an example of business rule logic, "boat" may be syntactically valid because it only contains alphanumeric characters, but it is not valid if the input is only expected to contain colors such as "red" or "blue." Do not rely exclusively on looking for malicious or malformed inputs. This is likely to miss at least one undesirable input, especially if the code's environment changes. This can give attackers enough room to bypass the intended validation. However, denylis
- [Architecture and Design] For any security checks that are performed on the client side, ensure that these checks are duplicated on the server side, in order to avoid CWE-602. Attackers can bypass the client-side checks by modifying values after the checks have been performed, or by changing the client to remove the client-side checks entirely. Then, these modified values would be submitted to the server.
Source: MITRE CWE corpus.
CVSS Vector
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:N/A:NReferences
Timeline
Scanner Template Available
A Nuclei vulnerability scanner template exists for this CVE. You can scan your infrastructure for this vulnerability immediately.
View template on GitHubnuclei -t http/cves/2021/CVE-2021-43831.yaml -u https://target.example.comRelated Vulnerabilities
CVE-2024-471679.8Gradio: unauthenticated SSRF in /queue/join, internal pivot
Same package: gradioCVE-2024-392369.8Gradio: code injection via component metadata (CVSS 9.8)
Same package: gradioCVE-2023-258239.8Gradio: hardcoded SSH key leaks via share=True demos
Same package: gradioCVE-2024-09649.4Gradio: unauthenticated LFI exposes full server filesystem
Same package: gradioCVE-2023-342399.1Gradio: path traversal + SSRF exposes model files & infra
Same package: gradio