The vulnerability is a command injection flaw within the PostgreSQL integration of the Budibase server. The root cause is the improper construction of a shell command to execute pg_dump for schema exporting. User-controlled data, such as the database password, host, and database name, are directly concatenated into the command string. An attacker with the ability to modify these datasource configuration values can inject arbitrary shell commands, leading to remote code execution on the server.
The provided patch 9fdbff32fb9e69650ba899a799e13f80d9b09e93 addresses the vulnerability by completely removing the schema export functionality. The analysis of this patch identified two key functions in the execution path of the vulnerability:
-
PostgresIntegration.getExternalSchema in packages/server/src/integrations/postgres.ts: This is the function where the vulnerable pg_dump command is constructed and executed via child_process.exec.
-
getExternalSchema in packages/server/src/api/controllers/datasource.ts: This is the API controller that handles requests to the /api/datasources/:datasourceId/schema/external endpoint. It retrieves the datasource configuration and invokes the vulnerable getExternalSchema method on the connector.
During an exploit, both of these functions would likely appear in a runtime profile or stack trace, making them critical indicators for detecting attempts to trigger this vulnerability.