DBHub: MySQL and MariaDB comment interpretation bypasses read-only SQL validation
The read-only mode can be bypassed on the MySQL and MariaDB connectors in DBHub. In read-only mode, a caller can still execute arbitrary write and DDL statements (for example, DROP TABLE), which defeats the protection that read-only mode is meant to provide when a database is exposed to an AI agent.
Root Cause
The issue stems from a mismatch between how DBHub's SQL parser handles single-line comments and how MySQL and MariaDB parse them.
In src/utils/sql-parser.ts, scanSingleLineComment treats -- as the start of a comment regardless of what character follows it. MySQL and MariaDB only begin a -- comment when the two dashes are followed by whitespace, a control character, or the end of the line. Otherwise, the dashes are parsed as two minus signs and the remainder of the line is processed as ordinary SQL.
The read-only check in src/tools/execute-sql.ts splits the input and validates each statement with isReadOnlySQL, but the connector then executes the original, unmodified string. The MySQL and MariaDB connectors configure their connection pool with multipleStatements: true (src/connectors/mysql/index.ts:54 and src/connectors/mariadb/index.ts:53) and execute the entire string in a single call.
Because of this, the following payload:
SELECT 1--1;DROP TABLE victim
is treated by DBHub as a single SELECT statement because everything after -- is seen as a comment, allowing the read-only check to pass. In contrast, MySQL and MariaDB parse it as SELECT 1 - -1 followed by DROP TABLE victim and execute both statements.
Proof of Concept
- 1) DBHub's own parser: Running
splitSQLStatementsandisReadOnlySQLfrom this repository against the payload yields a single statement andreadOnly = true, allowing the query in read-only mode. The same code rejectsSELECT 1; DROP TABLE victim, confirming that--1causes the bypass. - 2) Execution: Connecting to MariaDB 11.4 with
mysql2andmultipleStatements: true(the setting used by the connector) and sending the payload returns 2 for the first statement, confirming--was not treated as a comment, and subsequently drops the table. The table is present before the call and removed afterwards.
Impact
Read-only mode is intended to allow an assistant to read from a database without altering it. With this bypass, any party capable of influencing the SQL executed by the assistant—most realistically through prompt injection in content read by the assistant—can execute write operations and destructive DDL statements against MySQL and MariaDB. PostgreSQL is not affected by this path because it treats -- as a comment regardless and executes each split statement individually.
Affected Code (commit e99c3aa9, package version 0.22.3)
src/utils/sql-parser.ts—scanSingleLineCommentdoes not require whitespace after--src/tools/execute-sql.ts— validates split statements but executes the original stringsrc/connectors/mysql/index.tsandsrc/connectors/mariadb/index.ts— configuremultipleStatements: true
What to do
Upgrade @bytebase/dbhub to version 0.22.6 or later.
Suggested fixes include:
- Stop executing the original string: execute only validated statements.
- Disable
multipleStatementson MySQL and MariaDB connections unless required. - Implement dialect-aware comment scanning so that for MySQL and MariaDB,
--only initiates a comment when followed by whitespace, a control character, or the end of a line.
Affected software
Click a technology to see all vulnerabilities affecting it.
| Platform | Package | Vulnerable versions | Fixed in |
|---|---|---|---|
| npm package | @bytebase/dbhub | < 0.22.6 | 0.22.6 |
References
- CVSS vector
CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:P/VC:N/VI:H/VA:H/SC:N/SI:N/SA:N- Weakness (CWE)
CWE-436, CWE-863- Platform
- npm
- Package
@bytebase/dbhub- Disclosed
- 02.11.2026
- Updated
- 04.11.2026 10:00
Sources and licenses · Edited or translated by DockRay; source rights and applicable licenses are retained.
OSV / GitHub Advisory Database - GHSA-j656-3hf2-fvjc - CC BY 4.0
Vulnerability history: @bytebase/dbhub
All published vulnerabilities of this package (npm package), newest first. Shows whether this is a one-off slip or a package that needs watching.
- Total entries
- 3
- First → latest
- 09.2026 11.2026
- Without a fix
- 0
- Exploited in attacks
- 0
Severity breakdown
- Critical 1
- High 1
- Medium 1
Disclosures per year
- 2026: 3
-
DBHub: MySQL and MariaDB comment interpretation bypasses read-only SQL validation this entry
Know which vulnerabilities affect your application
With the DockRay integration and software inventory enabled, DockRay checks reported component versions against known vulnerabilities and notifies you about confirmed matches. Coverage depends on the supported technology and available advisory data.