Skip to content
Path traversal Disclosed report Intermediate CVE-2024-4941

Local file inclusion in gradio

The JSON component in gradio-app/gradio version 4.25 improperly validates user input in its postprocess function, allowing a user-controlled string to be parsed as JSON. If the parsed object contains a path key, the specified file is moved to a temporary directory and can later be retrieved via the /file=.. endpoint, enabling an attacker to read files on the remote system.

gradio-app/gradio

Originally disclosed on huntr

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.

From the GitHub Advisory Database (GHSA-6v6g-j5fq-hpvw, CC BY 4.0).

The original report as published on the GitHub Advisory Database. Images and videos are our own copies; raw HTML is shown as text. View it on GitHub Advisory Database.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

The postprocess function in the JSON component parses user-controlled input as JSON and then calls move_files_to_cache, which traverses the object and copies any file referenced by a path key without validating that the path is safe or intended.

Impact

An attacker could read arbitrary files on the remote system, which poses a significant security risk.

What the attacker needed

Access to the JSON component; ability to submit JSON input

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

This is a local file inclusion bug. The application takes user input, treats it as JSON, and if that JSON has a 'path' field, it copies whatever file is at that path into a temporary folder. Later, anyone can download that file through a special URL, so an attacker can read sensitive files on the server.

What is Path traversal?

Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.

More from gradio-app/gradio

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Path traversal and file inclusion

The lesson behind this report.

Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.