Medium · 6.1 Node.js & npm GHSA-j656-3hf2-fvjc
DBHub Read-Only Mode Bypass Lets MySQL and MariaDB Connectors Run Writes and DDL (GHSA-j656-3hf2-fvjc)
A flaw in DBHub's SQL parser lets specially crafted queries bypass read-only mode on MySQL and MariaDB connections, allowing write and destructive DDL statements such as DROP TABLE to execute even when read-only protection is enabled.
By PatchBriefing ·
Produced automatically from official sources with the help of AI. How we work →
AI summary
A vulnerability has been disclosed in DBHub, a tool that connects AI assistants to databases, affecting how its read-only protection handles MySQL and MariaDB connections. Because of a difference between how DBHub's internal SQL parser interprets comments and how MySQL and MariaDB actually parse them, an attacker-controlled query can slip write or destructive DDL statements past the read-only check and have them executed.
What happened
DBHub's read-only mode is designed to let an AI assistant query a database without being able to modify it. A flaw in the underlying SQL parser allows this protection to be bypassed specifically on MySQL and MariaDB connections. A crafted statement using a double-dash sequence followed by characters other than whitespace can be treated by DBHub as a harmless single-line comment, while MySQL and MariaDB interpret the same sequence differently and go on to execute an additional statement that follows it, including write operations and destructive commands such as DROP TABLE.
Technical cause
The root cause is a mismatch between DBHub's comment-scanning logic in its SQL parser and the comment syntax rules of MySQL and MariaDB. DBHub's parser treats any occurrence of two dashes ("--") as the start of a single-line comment, regardless of what follows. MySQL and MariaDB only start a "--" comment when the dashes are followed by whitespace, a control character, or the end of the line; otherwise the dashes are parsed as two minus signs, and anything after them on the line is treated as ordinary SQL. DBHub's read-only check splits and validates statements using its own parser, but the connector then executes the original, unmodified input string. Because the MySQL and MariaDB connectors open their connection pools with the option to run multiple statements in a single call, a payload that DBHub sees as one safe SELECT statement is executed by the database as two statements, the second of which can perform writes or destructive schema changes. PostgreSQL connections are not affected by this specific issue, because PostgreSQL always treats "--" as a comment and each split statement is executed individually.
Why it matters
Read-only mode is a control operators rely on to let an AI assistant read from a database without risk of modification. This bypass defeats that protection for MySQL and MariaDB connections. Anyone able to influence the SQL content an assistant sends, for example through content the assistant processes that contains a crafted instruction, could potentially cause the assistant to run write operations or destructive statements such as table drops against a database that was believed to be protected in read-only mode.
Affected versions
The issue affects the @bytebase/dbhub npm package in versions prior to 0.22.6, starting from version 0. The behavior was confirmed in testing against the codebase at package version 0.22.3. PostgreSQL connectors are not affected by this issue.
Fixes and mitigation
The issue is fixed in @bytebase/dbhub version 0.22.6. The fact package describes a suggested remediation approach consisting of executing only the statements that were actually validated by the read-only check (rather than the original unmodified input string), disabling the option that allows multiple statements per call on MySQL and MariaDB connections unless genuinely required, and making the comment scanner dialect-aware so that "--" only starts a comment for MySQL and MariaDB when followed by whitespace, a control character, or end of line.
Recommended action
Users of @bytebase/dbhub connecting to MySQL or MariaDB databases in read-only mode should upgrade to version 0.22.6 or later. Until upgraded, operators should treat read-only mode on MySQL and MariaDB connections as unreliable for preventing writes or destructive statements, and should consider additional protections such as database-level read-only users or permissions.
PatchBriefing score
6.1 / 10 · Medium
Official CVSS: 6.1
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
Why this score
The PatchBriefing score equals the official CVSS score; when this article covers several vulnerabilities, the highest one. Signals such as known exploitation and EPSS are listed separately and do not change the score.
Affected versions
- @bytebase/dbhub < 0.22.6
- vulnerable
- ≥ 0.22.6
- patched
Reported fixes
The issue is fixed in @bytebase/dbhub version 0.22.6. The fact package describes a suggested remediation approach consisting of executing only the statements that were actually validated by the read-only check (rather than the original unmodified input string), disabling the option that allows multiple statements per call on MySQL and MariaDB connections unless genuinely required, and making the comment scanner dialect-aware so that "--" only starts a comment for MySQL and MariaDB when followed by whitespace, a control character, or end of line.
How this was built
1 source records were collected, matched and used to prepare the report above.
-
GitHub Advisory Database database
Revision history
- Published
- Generated