VAITP Dataset

← Back to the dataset

CVE-2024-47165

CORS validation flaw in Gradio allows unauthorized requests from null origin.

  • CVSS 6.9
  • CWE-285
  • Configuration Issues
  • Local

Gradio is an open-source Python package designed for quick prototyping. This vulnerability relates to **CORS origin validation accepting a null origin**. When a Gradio server is deployed locally, the `localhost_aliases` variable includes "null" as a valid origin. This allows attackers to make unauthorized requests from sandboxed iframes or other sources with a null origin, potentially leading to data theft, such as user authentication tokens or uploaded files. This impacts users running Gradio locally, especially those using basic authentication. Users are advised to upgrade to `gradio>=5.0` to address this issue. As a workaround, users can manually modify the `localhost_aliases` list in their local Gradio deployment to exclude "null" as a valid origin. By removing this value, the Gradio server will no longer accept requests from sandboxed iframes or sources with a null origin, mitigating the potential for exploitation.

CVSS base score
6.9
Published
2024-10-10
OWASP
A01 Broken Access Control
Orthogonal defect classification
Checking
Code defect classification
Incorrect Check
Category
Configuration Issues
Subcategory
Cross-Site Request Forgery (CSRF)
Accessibility scope
Local
Impact
Data Theft
Affected component
Gradio
Fixed by upgrading
Yes

Solution

Upgrade to `gradio>=5.0`.

Vulnerable code sample

import gradio as gr

gr.Interface.localhost_aliases = ["localhost", "127.0.0.1", "null"]

def greet(name):
    """Vulnerable function that demonstrates the security issue."""
    return f"Hello {name}!"

iface = gr.Interface(fn=greet, inputs="text", outputs="text")

iface.launch()

Patched code sample

import gradio as gr

gr.Interface.localhost_aliases = ["localhost", "127.0.0.1"]

def greet(name):
    """Secure function that fixes the vulnerability."""
    return f"Hello {name}!"

iface = gr.Interface(fn=greet, inputs="text", outputs="text")

iface.launch()

Payload

fetch('http://localhost:7860/api/predict', {
    method: 'POST',
    headers: {
        'Content-Type': 'application/json',
        'Origin': 'null'
    },
    body: JSON.stringify({data: ['sensitive data']})
});

Cite this entry

@misc{vaitp:cve202447165,
  title        = {{CORS validation flaw in Gradio allows unauthorized requests from null origin.}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2024},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2024-47165},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2024-47165/}}
}
Introducing the "VAITP dataset": a specialized repository of Python vulnerabilities and patches, meticulously compiled for the use of the security research community. As Python's prominence grows, understanding and addressing potential security vulnerabilities become crucial. Crafted by and for the cybersecurity community, this dataset offers a valuable resource for researchers, analysts, and developers to analyze and mitigate the security risks associated with Python. Through the comprehensive exploration of vulnerabilities and corresponding patches, the VAITP dataset fosters a safer and more resilient Python ecosystem, encouraging collaborative advancements in programming security.

The supreme art of war is to subdue the enemy without fighting.

Sun Tzu – “The Art of War”

:: Shaping the future through research and ingenuity ::