{"id":"CVE-2023-50731","published":"2023-12-22T20:43:18Z","modified":"2024-08-02T22:16:47Z","title":"MindsDB has arbitrary file write in file.py","vendor":"mindsdb","product":"mindsdb","tier":"tail","description":{"text":"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 `save_file` method in `file-controller.py` which calls the `_handle_source` method in `file_handler.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 `_handle_source` 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.","provenance":"source","from":"CVE.org"},"cvss":{"score":9.1,"severity":"CRITICAL","version":"3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:H","provenance":"source","from":"CVE.org CNA"},"epss":{"score":0.01216,"percentile":0.68473,"provenance":"source"},"cwes":[{"id":"CWE-918","name":"Server-Side Request Forgery"}],"references":[{"url":"https://securitylab.github.com/advisories/GHSL-2023-182_GHSL-2023-184_mindsdb_mindsdb/","tags":["x_refsource_CONFIRM"]},{"url":"https://github.com/mindsdb/mindsdb/security/advisories/GHSA-j8w6-2r9h-cxhj","tags":["x_refsource_MISC"]},{"url":"https://github.com/mindsdb/mindsdb/blob/1821da719f34c022890c9ff25810218e71c5abbc/mindsdb/api/http/namespaces/file.py#L122-L125","tags":["x_refsource_MISC"]},{"url":"https://github.com/mindsdb/mindsdb/blob/1821da719f34c022890c9ff25810218e71c5abbc/mindsdb/api/http/namespaces/file.py#L138","tags":["x_refsource_MISC"]}],"priority":{"score":20.1,"factors":[{"name":"EPSS percentile","points":13.69},{"name":"CVSS severity","points":6.37}]},"vendorSlug":"mindsdb","affectedVersions":[{"vendor":"mindsdb","product":"mindsdb","versions":["< 23.11.4.1"]}],"affected":[{"ecosystem":"PyPI","package":"mindsdb","vulnerableRanges":["<23.11.4.1"],"patched":["23.11.4.1"],"from":["GHSA-j8w6-2r9h-cxhj","PYSEC-2023-279"],"provenance":"source"}],"summary":{"text":"MindsDB, an AI SQL server, contains a path injection flaw in the put method of mindsdb/api/http/namespaces/file.py, where the user-controlled name value is used to build a temporary file path without validation. An attacker with network access and no authentication or user interaction can write arbitrary file contents outside the intended directory (and can delete zip or tar.gz files on the server) in versions prior to 23.11.4.1.","provenance":"ai","model":"claude-haiku-5-5","generatedAt":"2026-11-20T07:16:59Z"},"euvd":{"id":"EUVD-2023-0150","exploited":false,"provenance":"source"},"lineage":{"packageHistory":[{"cve":"CVE-2023-30620","published":"2023-04-21","fixed":"23.2.1.0","kev":false,"link":{"from":"CVE-2023-30620","to":"CVE-2023-50731","relation":"successor","confidence":"low","kind":"sequence","evidence":[{"kind":"version-step","provenance":"source","package":"PyPI:mindsdb","fromFixed":"23.2.1.0","toFixed":"23.11.4.1","daysApart":245}]}},{"cve":"CVE-2023-49795","published":"2023-12-11","fixed":"23.11.4.1","kev":false},{"cve":"CVE-2023-49796","published":"2023-12-11","fixed":"23.11.4.1","kev":false},{"cve":"CVE-2023-50731","published":"2023-12-22","fixed":"23.11.4.1","kev":false},{"cve":"CVE-2024-24759","published":"2024-09-05","fixed":"23.12.4.2","kev":false,"link":{"from":"CVE-2023-50731","to":"CVE-2024-24759","relation":"successor","confidence":"low","kind":"sequence","evidence":[{"kind":"version-step","provenance":"source","package":"PyPI:mindsdb","fromFixed":"23.11.4.1","toFixed":"23.12.4.2","daysApart":258}]}},{"cve":"CVE-2024-45846","published":"2024-09-12","fixed":"24.7.4.1","kev":false},{"cve":"CVE-2024-45847","published":"2024-09-12","fixed":"24.7.4.1","kev":false}],"package":"PyPI:mindsdb"}}