Summary
Gradio apps running on Windows with Python 3.13+ are affected by an absolute path traversal issue that allows unauthenticated attackers to read arbitrary files from the server's file system.
A change in Python's os.path.isabs behavior causes Gradio's path-joining safety checks to misclassify root-relative paths, enabling crafted requests to bypass protections and access sensitive files, even when application-level authentication is enabled.
Affected context
This vulnerability affects Gradio applications that:
- Run on Windows operating systems
- Use Python 3.13 or later
- Rely on Gradio's file-serving logic that uses
os.path.isabsto validate paths
The issue is most relevant in deployments where Gradio exposes file download or static file endpoints and is reachable over the network, including setups that also configure additional authentication layers in front of Gradio.
Exploit preconditions
- Attack surface: Network-accessible Gradio endpoints that return files or serve static content.
- Required access: No prior authentication is required; unauthenticated HTTP requests can reach the vulnerable logic, even if Gradio's own auth is configured.
- Trigger point: User-controlled path or filename parameters are combined with a base directory and validated using
os.path.isabsbefore file access. - Why exploitation is possible: On Windows with Python 3.13+, root-relative paths like
/windows/win.iniare no longer treated as absolute byos.path.isabs. Gradio's logic assumes that non-absolute paths are safe when joined with a base directory. Attackers can therefore supply crafted root-relative paths that bypass the absolute-path check and cause the server to open files outside the intended directory.
Why this happens
The root cause is a path traversal bug stemming from incorrect assumptions about standard library behavior on Windows.
Gradio's path validation logic uses os.path.isabs to distinguish absolute from relative paths and relies on this distinction to prevent access outside of a configured base directory.
With Python 3.13+, os.path.isabs changed its semantics on Windows, and root-relative paths (e.g., /windows/win.ini) no longer count as absolute.
This mismatch between Gradio's security assumptions and the underlying API behavior maps to:
- CWE-36: Absolute Path Traversal, where user input influences file system paths without robust canonicalization and restriction.
- CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal'), because the application attempts but fails to constrain file access to a specific directory.
The abstract insecure pattern is trusting a single path API (such as isabs) as a security decision point instead of performing full normalization, canonicalization, and strict directory boundary checks.
Potential impact
- Attackers can read arbitrary files accessible to the Gradio process, including configuration files, logs, and source code.
- Exposure of secrets stored on disk, such as API keys, database credentials, or access tokens.
- Disclosure of system-specific files (e.g., Windows configuration files) that may aid in further compromise.
- Information leakage that facilitates other attacks such as lateral movement, privilege escalation, or targeted exploitation in the environment.
General mitigation guidance
Effective mitigation focuses on robust file path handling and defense-in-depth around file access:
- Implement strict directory whitelisting: resolve requested file paths to their canonical form and enforce that they reside within a designated root directory before opening.
- Avoid relying solely on
os.path.isabsor similar APIs for security decisions; use comprehensive normalization (realpath/abspath) followed by directory boundary checks. - Treat any user-controlled path segment (including query parameters, URL segments, and form fields) as untrusted and validate against a known safe list of filenames or IDs where possible.
- Segregate sensitive files and secrets from directories exposed to Gradio or any file-serving functionality.
- Run Gradio with least-privilege file system permissions so the process cannot read highly sensitive system or application files that are not needed for normal operation.
- Consider using indirection (e.g., mapping opaque file identifiers to approved files) rather than passing raw paths or filenames from clients.
How teams detect issues like this
Path traversal issues can often be detected before deployment through a combination of review and automated checks:
- Static analysis: Configure SAST tools or custom rules to flag uses of user-supplied input in file operations (
open,os.path.join,Path.open) without canonicalization and directory containment checks. - Code review: Look for patterns where:
- User input directly or indirectly influences file paths.
- Security checks rely on
os.path.isabs, prefix checks, or naive string operations (likestartswith) instead of true canonical path validation. - There is an assumption that "relative" paths are automatically safe when joined with a base directory.
- Dynamic testing: Employ security tests or DAST scanners that attempt path traversal payloads, including platform-specific forms like
/windows/win.inior..\..\patterns, to verify that the app consistently rejects out-of-scope file requests. - Policy enforcement: Incorporate secure file-access wrapper utilities that encapsulate canonicalization and directory checks, and enforce their use via code review guidelines or automated linting.

