{"id":1047,"cve":"CVE-2024-47165","cve_url":"https:\/\/www.cvedetails.com\/cve\/CVE-2024-47165\/","cwe":"CWE-285","cwe_number":285,"cwe_url":"https:\/\/cwe.mitre.org\/data\/definitions\/285","cvss_score":6.9,"published":"2024-10-10","owasp":"A01 Broken Access Control","odc":"Checking","cdc":"Incorrect Check","category":"Configuration Issues","subcategory":"Cross-Site Request Forgery (CSRF)","scope":"Local","impact":"Data Theft","summary":"CORS validation flaw in Gradio allows unauthorized requests from null origin.","permalink":"https:\/\/netpack.pt\/vaitp\/vulnerability\/CVE-2024-47165\/","description":"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.","solution":"Upgrade to `gradio>=5.0`.","affected_component":"Gradio","fixed_by_upgrading":true,"vulnerable_code":"import gradio as gr\n\ngr.Interface.localhost_aliases = [\"localhost\", \"127.0.0.1\", \"null\"]\n\ndef greet(name):\n    \"\"\"Vulnerable function that demonstrates the security issue.\"\"\"\n    return f\"Hello {name}!\"\n\niface = gr.Interface(fn=greet, inputs=\"text\", outputs=\"text\")\n\niface.launch()","patched_code":"import gradio as gr\n\ngr.Interface.localhost_aliases = [\"localhost\", \"127.0.0.1\"]\n\ndef greet(name):\n    \"\"\"Secure function that fixes the vulnerability.\"\"\"\n    return f\"Hello {name}!\"\n\niface = gr.Interface(fn=greet, inputs=\"text\", outputs=\"text\")\n\niface.launch()","payload_needed":true,"payload":"```javascript\nfetch('http:\/\/localhost:7860\/api\/predict', {\n    method: 'POST',\n    headers: {\n        'Content-Type': 'application\/json',\n        'Origin': 'null'\n    },\n    body: JSON.stringify({data: ['sensitive data']})\n});\n```","payload_status":"available","published_fix":[],"references":null}