CVE-2023-50731: GHSL-2023-182_GHSL-2023-184: Server-side request forgery (SSRF), arbitrary file write and limited file write vulnerabilities in mindsdb/mindsdb - CVE-2023-49795, CVE-2023-50731, CVE-2023-49796
Impact
Issue: Arbitrary file write in file.py (GHSL-2023-183)
Patches
Use mindsdb staging branch or v23.11.4.1
Other sources
MindsDB is a SQL Server for artificial intelligence. Prior to version 23.11.4.1, the put method in mindsdb/mindsdb/api/http/namespaces/file.py does not validate the user-controlled name value, which is used in a temporary file name, which is afterwards opened for writing on lines 122-125, which leads to path injection. Later in the method, the temporary directory is deleted on line 151, but since we can write outside of the directory using the path injection vulnerability, the potentially dangerous file is not deleted. Arbitrary file contents can be written due to f.write(chunk) on line 125. Mindsdb does check later on line 149 in the savefile method in file-controller.py which calls the handlesource method in filehandler.py if a file is of one of the types csv, json, parquet, xls, or xlsx. However, since the check happens after the file has already been written, the files will still exist (and will not be removed due to the path injection described earlier), just the handlesource method will return an error. The same user-controlled source source is used also in another path injection sink on line 138. This leads to another path injection, which allows an attacker to delete any zip or tar.gz files on the server.
— MITRE
Three vulnerabilities that can be exploited by unauthenticated users were found in MindsDB: a Server-side request forgery (SSRF) vulnerability, an arbitrary file write vulnerability and a limited file write vulnerability.
— GitHub Security Lab
Affected Software
Event History
Frequently Asked Questions
What is the severity of CVE-2023-50731?
CVE-2023-50731 has a high severity level due to its potential to allow arbitrary file write operations.
How do I fix CVE-2023-50731?
To fix CVE-2023-50731, upgrade to MindsDB version 23.11.4.1 or use the staging branch.
Which versions of MindsDB are affected by CVE-2023-50731?
Versions of MindsDB prior to 23.11.4.1 are affected by CVE-2023-50731.
What kind of vulnerability is CVE-2023-50731?
CVE-2023-50731 is an arbitrary file write vulnerability in the file.py component of MindsDB.
Where can I find more information about CVE-2023-50731?
You can refer to the MindsDB GitHub repository for detailed information regarding CVE-2023-50731.