AgentbeamBeta
AI agent vulnerability · Gradio

CVE-2024-1561: gradio vulnerable to Path Traversal

highCVSS 3.0 7.5GHSA-g9cj-cfpp-4g2x

Gradio before 4.13.0 lets a remote attacker call any method on a component through the /component_server endpoint. Using move_resource_to_block_cache(), they copy any readable file to a temporary directory and download it. Apps shared with launch(share=True) or hosted on Hugging Face are exposed. Upgrade to gradio 4.13.0.

Published Apr 16, 2024 · Updated May 10, 2024 · Analysis Nov 18, 2026

What an attacker can do

/component_server looked up an attribute on the component by name and called it with attacker-supplied arguments. The advisory picks out the move_resource_to_block_cache() method of the Block class, which copies a file from a path the caller gives into the app's cache. The attacker then fetches the copy from the cache, so any file the Gradio process can read is exposed.

No authentication is needed (CVSS 3.0 AV:N/AC:L/PR:N/UI:N, high confidentiality impact). Apps made reachable with launch(share=True) get a public link, so a remote attacker can read files on the host. The advisory also says Gradio apps on huggingface.co are affected, which can expose API keys and credentials stored in environment variables. Its EPSS score, about 0.09, is notably higher than many of the entries from the same date.

Who is affected

The pip package gradio is affected before 4.13.0. Apps are most exposed when launched with launch(share=True) or otherwise reachable from the internet, including Spaces on Hugging Face.

Check the version:

pip show gradio

Check the environment the app runs in, not only your workstation.

gradio

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

How to fix it

Upgrade to gradio 4.13.0:

pip install --upgrade gradio==4.13.0

The fix commit 24a58368 changes /component_server in gradio/routes.py so it only calls functions marked as server functions (an _is_server_fn flag). Anything else gets a 404 with the detail "Function not found." Until you upgrade, avoid launch(share=True) and keep the app off public networks. Rotate keys that sat in the environment of an exposed app.

How to tell if you were hit

Look in access logs for POST requests to /component_server whose body names methods other than those your components expose, such as move_resource_to_block_cache or preprocess. Check the Gradio cache directory for copies of system files, such as /etc/passwd or .env files, and look for later requests to fetch them.

Original advisory

From the GitHub Advisory Database (CC BY 4.0).

An issue was discovered in gradio-app/gradio, where the /component_server endpoint improperly allows the invocation of any method on a Component class with attacker-controlled arguments. Specifically, by exploiting the move_resource_to_block_cache() method of the Block class, an attacker can copy any file on the filesystem to a temporary directory and subsequently retrieve it. This vulnerability enables unauthorized local file read access, posing a significant risk especially when the application is exposed to the internet via launch(share=True), thereby allowing remote attackers to read files on the host machine. Furthermore, gradio apps hosted on huggingface.co are also affected, potentially leading to the exposure of sensitive information such as API keys and credentials stored in environment variables.

Questions

Which Gradio version fixes CVE-2024-1561?

4.13.0. Everything before it is affected.

Is launch(share=True) a problem?

Yes. The advisory calls out apps exposed that way, because the public link lets remote attackers read files on the host.

Are Hugging Face Spaces affected?

The advisory says Gradio apps hosted on huggingface.co are affected, which could expose API keys and credentials held in environment variables.

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