GHSA-qqf5-x7mj-v43p budibase: Database Connector SQL Injections in PostgreSQL, MS SQL, and MySQL
SummaryThis advisory covers three distinct SQL Injection vulnerabilities within Budibase's database connectors (PostgreSQL, Microsoft SQL Server, and MySQL). Because user-controlled schema and table configurations are interpolated directly into raw SQL queries without proper escaping or parameterization during database introspection, an authenticated administrator can break out of string delimiters. This allows for arbitrary DDL/DML execution, database compromise, and potential underlying OS command execution (e.g., via MS SQL `xp_cmdshell`).DetailsVulnerability Type & Title**PostgreSQL `SET search_path` SQL Injection**Description & Root CauseThe `schema` datasource config field is interpolated directly into a raw SQL statement without proper escaping. Double quotes inside the schema name are not escaped, allowing an attacker to break out of the string literal and inject arbitrary SQL.**Vulnerable Code:**
**File:** `packages/server/src/integrations/postgres.ts`, lines 355–358`node-postgres` sends this via the **simple query protocol**, which supports multi-statement execution with semicolons.Step-by-Step ReproductionEdit a PostgreSQL datasource configuration.Set the schema field to:
`public"; CREATE TABLE pwned AS SELECT usename, passwd FROM pg_shadow; --`Save or trigger a connection test.The query executes as:
`SET search_path TO "public"; CREATE TABLE pwned AS SELECT usename, passwd FROM pg_shadow; --;`PostgreSQL executes both statements.ImpactFull database compromise. The attacker can read `pg_shadow` hashes, call `pg_read_file()`, or execute any DDL/DML.Vulnerability Type & Title**Microsoft SQL Server Schema Introspection SQL Injection**Description & Root CauseThree methods used during schema introspection (`buildSchema`) interpolate user-controlled values directly into SQL strings using single-quote delimiters with no escaping.**Vulnerable Code:**
**File:** `packages/server/src/integrations/microsoftSqlServer.ts`, lines 388–414`schemaName` comes directly from `this.config.schema` (user config).Step-by-Step ReproductionEdit an MS SQL Server datasource configuration.Set the schema field to: `dbo'; EXEC xp_cmdshell('whoami'); --`Trigger schema introspection (fetch tables).The OS command executes on the SQL server if `xp_cmdshell` is enabled.ImpactArbitrary SQL execution, potentially leading to OS command execution via `xp_cmdshell`.Vulnerability Type & Title**MySQL `multipleStatements: true` + `DESCRIBE` Backtick Injection**Description & Root CauseThe MySQL integration enables `multipleStatements: true`, allowing semicolon-separated multi-statement execution. When introspecting tables, table names are interpolated into a `DESCRIBE` query wrapped in backticks, but the backticks are not escaped.**Vulnerable Code:**
**File:** `packages/server/src/integrations/mysql.ts`, lines 172, 305Step-by-Step ReproductionAn attacker (or malicious database user) creates a table named ``foo`; DROP TABLE users; --``.In Budibase, an admin triggers schema introspection for the database.Budibase reads the malicious table name from `INFORMATION_SCHEMA.TABLES` and inserts it into the `DESCRIBE` query.The backtick breaks out, and the secondary `DROP TABLE` payload executes.ImpactArbitrary SQL execution triggered during schema discovery. Requires prior database catalog manipulation.
CVSS v3.1 score: 8.4