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

CVE-2024-4941: Local file inclusion in gradio

highCVSS 3.0 7.5GHSA-6v6g-j5fq-hpvw

Gradio's JSON component can be made to copy any readable server file into its cache, and the attacker then downloads it through the `/file=` endpoint. No login is needed. Gradio versions below 4.31.3 are affected. Upgrade to 4.31.3.

Published Jun 6, 2024 · Updated Jan 21, 2025 · Analysis Nov 2, 2026

What an attacker can do

postprocess() in gradio/components/json_component.py parses a user-controlled string as JSON. The result passes to processing_utils.move_files_to_cache(), which walks any object looking for a dictionary with a path key. For each match it copies the named file into Gradio's temporary directory. The attacker can then fetch it from /file=....

So an app that feeds user input into a gr.JSON output can be pushed into serving /etc/passwd, environment files, API keys, model weights or source code. The CVSS 3.0 vector is network, low complexity, no privileges, no user interaction, high confidentiality impact only. Writing files and code execution are not part of this flaw.

The discoverer found it in version 4.25. Many Gradio demos sit on public hosts, and they often hold provider API keys, so the leaked data can matter well beyond the demo.

Who is affected

pip package gradio older than 4.31.3. The path is reachable when an app uses the JSON component and passes user-influenced text to it.

pip show gradio

gradio

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

How to fix it

Upgrade to gradio 4.31.3 or later.

pip install --upgrade "gradio>=4.31.3"

The fix is commit ee1e294. The advisory lists no workaround. Until you upgrade, avoid passing user-controlled strings to JSON components, and run the app as a user that cannot read secrets.

How to tell if you were hit

Check web or proxy logs for requests to /file= that point at paths outside your app's expected outputs, such as system files or .env. Inspect Gradio's temporary cache directory for copies of files that do not belong there. Review inputs to JSON components for strings containing a "path" key.

Original advisory

From the GitHub Advisory Database (CC BY 4.0).

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.

Questions

Does the attacker need to authenticate?

No. The CVSS vector shows no privileges and no user interaction, and the attack goes over the network. If your Gradio app is reachable, so is the flaw.

Which files can be read?

Any file the Gradio process can read. The code copies the file named in the path key into a temporary directory, from where /file= serves it.

Which version fixes CVE-2024-4941?

Gradio 4.31.3. Everything below it is listed as vulnerable.

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