The vulnerability lies in several import functions (importChatflows, importTools, importVariables, importAssistants) within the Flowise server. These functions are responsible for importing data from user-provided JSON files. The root cause of the SQL injection is the improper construction of SQL queries where a user-controlled id field from the JSON file is directly concatenated into the WHERE clause of a database query. This allows an authenticated user to craft a malicious id to execute arbitrary SQL commands, leading to data leakage from the database, as demonstrated by the provided Proof of Concept which extracts credentials.
The patch addresses this vulnerability by introducing a validation step at the beginning of each import function. It iterates through the items to be imported and uses a validate function to ensure that each id is a valid UUID. If an invalid ID is found, the operation is aborted, preventing the malicious input from ever reaching the database query construction logic. This fix effectively closes the SQL injection vector.