CVE-2024-47164
JSON

2.3low

The `is_in_or_equal` function may be bypassed in Gradio

Severity
2.3low CVSS:4.0 by GitHub_M
Exploit likelihood
0.70% (higher than 54% of CVEs; EPSS, by FIRST)
Published
Last changed
Assigned by
GitHub_M
Also known as
GHSA-77xq-6g77-h274PYSEC-2024-213

Description

Gradio is an open-source Python package designed for quick prototyping. This vulnerability relates to the **bypass of directory traversal checks** within the `is_in_or_equal` function. This function, intended to check if a file resides within a given directory, can be bypassed with certain payloads that manipulate file paths using `..` (parent directory) sequences. Attackers could potentially access restricted files if they are able to exploit this flaw, although the difficulty is high. This primarily impacts users relying on Gradio’s blocklist or directory access validation, particularly when handling file uploads. Users are advised to upgrade to `gradio>=5.0` to address this issue. As a workaround, users can manually sanitize and normalize file paths in their Gradio deployment before passing them to the `is_in_or_equal` function. Ensuring that all file paths are properly resolved and absolute can help mitigate the bypass vulnerabilities caused by the improper handling of `..` sequences or malformed paths.

Affected

Product or packageVersionsReported by
gradio-app gradio< 5.0CVE List
gradio (PyPI)before 5.0.0GitHub Advisory Database, PyPA Advisory Database
gradio_project gradiobefore 5.0.0NVD

All scores

GitHub_M2.3low CVSS:4.0CVSS:4.0/AV:N/AC:H/AT:P/PR:L/UI:N/VC:L/VI:N/VA:N/SC:N/SI:N/SA:N
GitHub6.5medium CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:N
GitHubmedium CVSS:4.0CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:L/VI:L/VA:N/SC:N/SI:N/SA:N
NVD6.5medium CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:N
PyPA Advisory Database6.5medium CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:N

Classification

CWE-22

SSVC (CISA-ADP): exploitation none, automatable no, technical impact partial.

What each source says

CVE List

Gradio is an open-source Python package designed for quick prototyping. This vulnerability relates to the **bypass of directory traversal checks** within the `is_in_or_equal` function. This function, intended to check if a file resides within a given directory, can be bypassed with certain payloads that manipulate file paths using `..` (parent directory) sequences. Attackers could potentially access restricted files if they are able to exploit this flaw, although the difficulty is high. This primarily impacts users relying on Gradio’s blocklist or directory access validation, particularly when handling file uploads. Users are advised to upgrade to `gradio>=5.0` to address this issue. As a workaround, users can manually sanitize and normalize file paths in their Gradio deployment before passing them to the `is_in_or_equal` function. Ensuring that all file paths are properly resolved and absolute can help mitigate the bypass vulnerabilities caused by the improper handling of `..` sequences or malformed paths.

GitHub Advisory Database
Impact

What kind of vulnerability is it? Who is impacted?

This vulnerability relates to the bypass of directory traversal checks within the is_in_or_equal function. This function, intended to check if a file resides within a given directory, can be bypassed with certain payloads that manipulate file paths using .. (parent directory) sequences. Attackers could potentially access restricted files if they are able to exploit this flaw, although the difficulty is high. This primarily impacts users relying on Gradio’s blocklist or directory access validation, particularly when handling file uploads.

Patches

Yes, please upgrade to gradio>=5.0 to address this issue.

Workarounds

Is there a way for users to fix or remediate the vulnerability without upgrading?

As a workaround, users can manually sanitize and normalize file paths in their Gradio deployment before passing them to the is_in_or_equal function. Ensuring that all file paths are properly resolved and absolute can help mitigate the bypass vulnerabilities caused by the improper handling of .. sequences or malformed paths.

NVD (es)

Gradio es un paquete Python de código abierto diseñado para la creación rápida de prototipos. Esta vulnerabilidad se relaciona con la **omisión de comprobaciones de recorrido de directorio** dentro de la función `is_in_or_equal`. Esta función, destinada a comprobar si un archivo reside dentro de un directorio determinado, se puede omitir con ciertas cargas útiles que manipulan las rutas de archivo mediante secuencias `..` (directorio principal). Los atacantes podrían acceder potencialmente a archivos restringidos si pueden explotar esta falla, aunque la dificultad es alta. Esto afecta principalmente a los usuarios que dependen de la lista de bloqueo de Gradio o la validación de acceso al directorio, en particular al manejar cargas de archivos. Se recomienda a los usuarios que actualicen a `gradio&gt;=5.0` para solucionar este problema. Como workaround, los usuarios pueden desinfectar y normalizar manualmente las rutas de archivo en su implementación de Gradio antes de pasarlas a la función `is_in_or_equal`. Asegurarse de que todas las rutas de archivo se resuelvan correctamente y sean absolutas puede ayudar a mitigar las vulnerabilidades de omisión causadas por el manejo inadecuado de secuencias `..` o rutas malformadas.

References

Sources

SourceRecordLicence
CVE ListCVE-2024-47164 changed 2024-10-11CVE Terms of Use
GitHub Advisory DatabaseGHSA-77xq-6g77-h274 changed 2025-01-21CC-BY-4.0
NVDCVE-2024-47164 changed 2026-06-17Public domain
PyPA Advisory DatabasePYSEC-2024-213 changed 2025-01-19CC-BY-4.0