CVE-2024-8021
Executive Summary
CVE-2024-8021 is an open redirect vulnerability in Gradio, a popular Python library for building machine learning web demos. The flaw allows an attacker to bypass URL validation by encoding the redirect target, leading to a 302 redirect to an attacker-controlled site. This can be exploited for phishing attacks, credential theft, and erosion of user trust. The vulnerability has a CVSS score of 5.4 (Medium) and is confirmed exploitable with a public Nuclei template. No official patch has been released at this time.
This record — and 170,000+ others — are available via the ValtersIT API. One endpoint replaces five: NVD + GitHub CVE + CISA KEV + EPSS + Nuclei + Exploit-DB, unified.
No signup required
Supply Chain & Package Security
Gradio is distributed via PyPI (pip install gradio). Users should monitor for patched versions and verify package integrity using checksums. The open redirect can be weaponized in supply chain attacks by tricking users into visiting malicious sites that mimic legitimate Gradio interfaces.
CVSS Breakdown & Threat Level
- CVSS Score: 5.4 (Medium)
- Vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:L/I:L/A:N
- Attack Vector: Network
- Attack Complexity: Low
- Privileges Required: None
- User Interaction: Required
- Scope: Unchanged
- Confidentiality Impact: Low
- Integrity Impact: Low
- Availability Impact: None
The threat level is medium due to the requirement for user interaction (clicking a crafted link) and the limited impact on confidentiality and integrity. However, the ease of exploitation and potential for phishing campaigns elevate the risk.
Deep Dive & Mechanics
The vulnerability resides in Gradio's file serving endpoint. When a request is made to /file= followed by a URL-encoded path, the application performs a redirect without proper validation. By encoding the target URL (e.g., http://oast.pro as http%3A%2F%2Foast.pro), an attacker can bypass any existing allowlist or blocklist checks.
The Nuclei template confirms the bypass works by sending a GET request to /file=http%3A%2F%2Foast.pro/ and checking for a 302 redirect with a Location header pointing to the attacker-controlled domain.
Vulnerable vs. Patched Code
Vulnerable Code (Conceptual):
# Gradio's file handler performs a redirect without validating the target
@app.route('/file=<path:filepath>')
def file_redirect(filepath):
# No validation of filepath before redirect
return redirect(filepath)
Patched Code (Expected):
# Patched version validates the redirect target
from urllib.parse import urlparse
ALLOWED_DOMAINS = ['example.com', 'gradio.app']
@app.route('/file=<path:filepath>')
def file_redirect(filepath):
parsed = urlparse(filepath)
if parsed.netloc and parsed.netloc not in ALLOWED_DOMAINS:
abort(400, "Invalid redirect target")
return redirect(filepath)
Exploitation & Lab Setup
Red Team
Prerequisites:
- Python 3.x
- Gradio installed (
pip install gradio) - A listener on a public endpoint (e.g.,
oast.proor a custom domain)
Exploit Steps:
- Start a Gradio server (default port 7860).
- Craft a malicious URL:
http://target:7860/file=http%3A%2F%2Foast.pro%2F - Send the request using curl or a browser:
curl -v "http://localhost:7860/file=http%3A%2F%2Foast.pro%2F" - Observe the 302 redirect to
http://oast.pro/.
Nuclei Template (Provided):
id: CVE-2024-8021
info:
name: Gradio - Open Redirect
author: DhiyaneshDK
severity: medium
description: |
Gradio allows an open redirect bypass via URL encoding, enabling attackers to redirect users to malicious sites. This can lead to phishing attacks and loss of trust in the application.
impact: |
Attackers can craft malicious URLs with encoded redirects that send users to phishing sites or malicious domains, leading to credential theft and undermining trust in the Gradio application.
remediation: |
Update Gradio to a version that addresses the open redirect vulnerability via URL encoding bypass.
reference:
- https://huntr.com/bounties/adc23067-ec04-47ef-9265-afd452071888
classification:
epss-score: 0.02447
epss-percentile: 0.85249
metadata:
verified: true
max-request: 1
vendor: gradio_project
product: gradio
shodan-query:
- http.html:"__gradio_mode__"
- http.title:"gradio"
fofa-query:
- body="__gradio_mode__"
- title="gradio"
google-query: intitle:"gradio"
tags: cve,cve2024,redirect,oast,gradio,vuln
http:
- raw:
- |
GET /file=http%3A%2F%2Foast.pro/ HTTP/1.1
Host: {{Hostname}}
matchers-condition: and
matchers:
- type: regex
regex:
- '(?m)^(?:Location\s*?:\s*?)(?:https?://|//)(?:[a-zA-Z0-9\-_\.@]*)oast\.pro.*$'
part: header
- type: status
status:
- 302
Blue Team
Detection Steps:
- Monitor web server logs for requests to
/file=with encoded URLs. - Look for 302 responses with
Locationheaders pointing to external domains. - Use the provided YARA and Sigma rules to detect exploitation attempts.
Lab Setup for Testing:
- Deploy a vulnerable Gradio instance in an isolated environment.
- Use the Nuclei template to verify the vulnerability.
- Implement the detection rules and test with benign and malicious requests.
Indicators of Compromise (IOCs)
- URL Pattern:
/file=http%3A%2F%2F[malicious-domain]%2F - HTTP Response: 302 redirect with
Locationheader containing an external domain. - Network Traffic: Outbound connections to attacker-controlled domains after redirect.
- Log Entries:
GET /file=http%3A%2F%2F*with status 302.
Detection Engineering
YARA Rule
rule CVE_2024_8021_Gradio_Open_Redirect {
meta:
description = "Detects Gradio open redirect exploitation attempts"
author = "Valters IT"
date = "2025-04-10"
reference = "CVE-2024-8021"
strings:
$url_pattern = "/file=http%3A%2F%2F"
$redirect_header = "Location: http"
condition:
$url_pattern and $redirect_header
}
Sigma Rule
title: Gradio Open Redirect Exploitation
id: 7b8f3c2a-1d4e-5f6a-7b8c-9d0e1f2a3b4c
status: experimental
description: Detects HTTP requests targeting Gradio's open redirect vulnerability
author: Valters IT
date: 2025-04-10
logsource:
category: webserver
product: apache
service: access
detection:
selection:
cs-uri-query|contains: "/file=http%3A%2F%2F"
sc-status: 302
condition: selection
falsepositives:
- Legitimate file serving with encoded paths (rare)
level: medium
Suricata Rule
alert http any any -> any any (msg:"CVE-2024-8021 Gradio Open Redirect"; flow:to_server,established; content:"/file=http%3A%2F%2F"; http_uri; classtype:attempted-recon; sid:1000001; rev:1;)
Remediation & Mitigation
- Immediate: Implement a reverse proxy (e.g., Nginx) to block requests containing
/file=http%3A%2F%2Fin the URI. - Short-term: Disable the file serving endpoint if not required, or restrict it to internal networks.
- Long-term: Update Gradio to a patched version once released. Monitor the official repository for updates.
- User Awareness: Educate users not to click on suspicious links containing encoded URLs.
Valters IT Signature
Report generated by Valters IT DevSecOps & CTI Division
{/* [Security Hash: 09284550D8183171FD40B4E4] */}
💣 PoC CODE AVAILABLE
Exploit code for this CVE is tracked in our database.
Access poc_code via API Pro.