CVE-2026-61788: @bytebase/dbhub @bytebase/dbhub's Read-only Mode Does Not Vulnerability

HIGH
Advisory Identifier: GHSA-mwwr-p57h-56pf
CVSS 7.4
CWE-863 CWE-184 CWE-636
Published
Advisory Summary

CVE-2026-61788 is a HIGH (CVSS 7.4) @bytebase/dbhub's read-only mode does not vulnerability (CWE-863: Incorrect Authorization) affecting @bytebase/dbhub libraries in the npm ecosystem. The issue involves @bytebase/dbhub's read-only mode does not prevent database writes. Remediation is available by upgrading affected packages to version 0.22.6.

CVE-2026-61788 at a Glance

CVE Identifier CVE-2026-61788
GHSA Identifier GHSA-mwwr-p57h-56pf
Severity HIGH
CVSS v3.1 Base Score 7.4
CWE Classification CWE-863: Incorrect Authorization
Affected Product @bytebase/dbhub
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 7.4

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:N).

Attack Vector Network (AV:N)
Attack Complexity High (AC:H)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity High (I:H)
Availability None (A:N)

How to Fix CVE-2026-61788

To remediate this vulnerability, upgrade all affected @bytebase/dbhub dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

@bytebase/dbhub fixed: 0.22.6
npm install @bytebase/dbhub@0.22.6
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

npm ls @bytebase/dbhub

How to Check if You Are Affected

To determine whether your Node.js application is affected by CVE-2026-61788, inspect your project dependencies using npm:

npm ls @bytebase/dbhub

Analyze the terminal output to locate any version of @bytebase/dbhub in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.22.6), your application is affected.

Note: The npm ls @bytebase/dbhub command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-863: Incorrect Authorization, where the product performs an authorization check when an actor attempts to access a resource or perform an action, but it does not correctly perform the check. In @bytebase/dbhub, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Summary Setting `readonly = true` on the `execute_sql` tool does not make the connection read-only. The connectors are written to set PostgreSQL `default_transaction_read_only=on` (and open SQLite in `readOnly` mode), but that code is gated on a config value that is never populated, so it never runs. The only thing left enforcing read-only is a classifier that inspects the first keyword of each statement. Any `SELECT` that writes or has side effects through a function call passes it. With an ordinary role this allows sequence tampering; with a privileged role it allows writing arbitrary files on the server (`lo_export`), reading arbitrary host files (`pg_read_file`), and remote code execution (`dblink` + `COPY ... TO PROGRAM`). The HTTP transport is unauthenticated and binds to `0.0.0.0` by default, so this is reachable by any network caller of `/mcp`. ### Details Two problems combine. **1. The database-level read-only control is dead code.** `PostgresConnector.connect()` only enables it when `config.readonly` is truthy (`src/connectors/postgres/index.ts:175-177`): ```ts // SDK-level readonly enforcement: Set default_transaction_read_only for the entire connection if (config?.readonly) { poolConfig.options = (poolConfig.options || '') + ' -c default_transaction_read_only=on'; } ``` SQLite is gated the same way (`src/connectors/sqlite/index.ts:192`). `ConnectorConfig.readonly` is assigned in exactly one place, and only from `source.readonly` (`src/connectors/manager.ts:236-238`): ```ts // Pass readonly flag for SDK-level enforcement (PostgreSQL, SQLite) if (source.readonly !== undefined) { config.readonly = source.readonly; } ``` `source.readonly` can never have a value: - `SourceConfig` has no `readonly` field (`src/types/config.ts:49-62`). `readonly` exists only on the per-tool `ExecuteSqlToolConfig` / `CustomToolConfig`. - The TOML loader rejects `readonly` at source level (`src/config/toml-loader.ts:476-481`: "readonly must be configured per-tool, not per-source"). - The `--readonly` CLI flag was removed and now hard-exits (`src/config/env.ts:30`). So the `if (source.readonly !== undefined)` check is always false, `config.readonly` stays unset, and DB-level read-only is never applied in any configuration the loader accepts. The per-tool `readonly` only ever reaches the classifier; `executeSQL()` ignores `options.readonly` and runs multi-statement batches in a plain `BEGIN` rather than `BEGIN READ ONLY` (`src/connectors/postgres/index.ts:598-666`). (The docs already describe the classifier as "a safety net... not a security boundary." This report is about the DB-level control above, which the code clearly means to apply — see the "SDK-level readonly enforcement" comments — but silently fails to wire up.) **2. The classifier only checks the leading keyword.** `areAllStatementsReadOnly()` (`src/tools/execute-sql.ts:24-27`) splits on `;` and runs `isReadOnlySQL()` (`src/utils/allowed-keywords.ts`) on each statement. `isReadOnlySQL` matches the first word against an allow-list, scans for mutating keywords only inside `WITH`, blocks `SELECT ... INTO`, and special-cases `EXPLAIN ANALYZE`. It never looks at the functions a statement calls. These all classify as read-only: - `SELECT setval('seq', n)` / `nextval('seq')` — sequence write. Needs UPDATE (setval) or USAGE/UPDATE (nextval) on the sequence, which read roles normally hold. - `SELECT lo_export(lo, '/path')` — writes a file on the server. Needs superuser or `pg_write_server_files`. - `SELECT pg_read_file('/etc/passwd')` — reads any file the server user can read. Needs superuser or `pg_read_server_files`. - `SELECT dblink_exec('dbname=...', 'UPDATE ...')` — opens a fresh connection (not read-only) and runs writes/DDL. Needs the `dblink` extension. - `SELECT dblink_exec('dbname=...', $$COPY (SELECT 1) TO PROGRAM 'id'$$)` — command execution. Needs superuser or `pg_execute_server_program`, plus `dblink`. The read-only test suite covers none of these. ### PoC Point DBHub at a PostgreSQL source with read-only set on the tool: ```toml [[sources]] id = "default" dsn = "postgres://app:app@localhost:5432/app" [[tools]] name = "execute_sql" source = "default" readonly = true ``` Start it and call `execute_sql`: ``` npx @bytebase/dbhub@latest --transport http --port 8080 ``` With any role, a write that should be blocked goes through — the sequence value changes and the call returns success: ```sql SELECT setval('users_id_seq', 1); ``` With a privileged role, the rest are also accepted and executed: ```sql SELECT lo_export(lo_from_bytea(0, decode('48656c6c6f0a','hex')), '/tmp/dbhub_poc'); -- writes /tmp/dbhub_poc SELECT pg_read_file('/etc/passwd'); -- reads a host file SELECT dblink_exec('dbname=app', 'UPDATE users SET admin=true'); -- write via a new connection SELECT dblink_exec('dbname=app', $$COPY (SELECT 1) TO PROGRAM 'id > /tmp/pwned'$$); -- runs a shell command ``` The decision can be reproduced without a database by running the project's own `isReadOnlySQL` + `splitSQLStatements` (with `areAllStatementsReadOnly` copied from `src/tools/execute-sql.ts`) over the strings above: direct INSERT/UPDATE/DROP, data-modifying CTEs, `SELECT ... INTO`, and `EXPLAIN ANALYZE INSERT` are all rejected, while every function-based statement above returns read-only = true. ### Impact Affects all released versions up to and including 0.22.2, on both stdio and HTTP transports, for PostgreSQL and SQLite. `readonly = true` does not stop writes. Anyone who can reach the `execute_sql` input can modify data under read-only mode — a network caller of the unauthenticated `/mcp` endpoint, a malicious MCP client, or untrusted content reaching an agent wired to DBHub through prompt injection. When the configured database role is privileged (common, since DBHub is often pointed at an existing admin DSN), the same access yields arbitrary file write on the server, arbitrary host-file read, and remote code execution on the database host. --- ### Maintainer note (consolidation) Tracking this as the canonical advisory for "read-only mode does not prevent database writes." The following reports describe the same root cause (read-only enforced only by the keyword classifier; the connection-level backstop was never wired) and are closed as duplicates: - **GHSA-7rgf-cwgq-c2qc** — same unwired driver-level backstop, plus the SQLite write-effecting `PRAGMA` gap. - **GHSA-m689-287g-5xpc** — SQLite assignment-form `PRAGMA` write bypass (a subset of the above). Preserving the SQLite-specific remediation from those reports: in `isReadOnlySQL`, the assignment form `PRAGMA x = ...` must be classified as a write (only the query/introspection form is read-only), and SQLite read-only executions are additionally guarded at the engine via `PRAGMA query_only=ON`. GHSA-j656-3hf2-fvjc (MySQL/MariaDB `--` comment parsing + `multipleStatements`) is a distinct root cause and is tracked separately. Fix: https://github.com/bytebase/dbhub/pull/342 — adds engine-level read-only enforcement per tool (Postgres `BEGIN READ ONLY`, SQLite `query_only`, MySQL/MariaDB `START TRANSACTION READ ONLY`) plus the classifier hardening above.

CVE-2026-61788 Affected @bytebase/dbhub Versions

1 component(s)
Fixed Versions:
0.22.6
Product / Package Ecosystem Affected Versions Fixed Version
@bytebase/dbhub
npm
< 0.22.6
0.22.6

References

Frequently Asked Questions

What is CVE-2026-61788?
CVE-2026-61788 is a security vulnerability in @bytebase/dbhub involving @bytebase/dbhub's read-only mode does not prevent database writes under CWE-863: Incorrect Authorization.
Which @bytebase/dbhub versions are affected?
Affected versions include releases prior to 0.22.6 across affected packages: @bytebase/dbhub.
What version fixes CVE-2026-61788?
Upgrading to 0.22.6 (or the latest patched release for your respective branch) resolves the vulnerability.
Is @bytebase/dbhub affected?
Yes, @bytebase/dbhub is affected in releases prior to 0.22.6. Upgrade your dependency to 0.22.6 or later.
What is the CVSS score of CVE-2026-61788?
CVE-2026-61788 has a CVSS v3.1 base score of 7.4 (HIGH) with vector string CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:N.
What CWE is associated with CVE-2026-61788?
CVE-2026-61788 is classified under CWE-863: Incorrect Authorization (The product performs an authorization check when an actor attempts to access a resource or perform an action, but it does not correctly perform the check.).
How can I check npm dependencies for CVE-2026-61788?
Run the dependency tree command: 'npm ls @bytebase/dbhub'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-mwwr-p57h-56pf",
  "modified" : "2026-09-24T19:38:00Z",
  "published" : "2026-09-24T19:37:59Z",
  "aliases" : [ "CVE-2026-61788" ],
  "summary" : "@bytebase/dbhub's read-only mode does not prevent database writes",
  "details" : "### Summary\n \nSetting `readonly = true` on the `execute_sql` tool does not make the connection read-only. The connectors are written to set PostgreSQL `default_transaction_read_only=on` (and open SQLite in `readOnly` mode), but that code is gated on a config value that is never populated, so it never runs. The only thing left enforcing read-only is a classifier that inspects the first keyword of each statement. Any `SELECT` that writes or has side effects through a function call passes it. With an ordinary role this allows sequence tampering; with a privileged role it allows writing arbitrary files on the server (`lo_export`), reading arbitrary host files (`pg_read_file`), and remote code execution (`dblink` + `COPY ... TO PROGRAM`). The HTTP transport is unauthenticated and binds to `0.0.0.0` by default, so this is reachable by any network caller of `/mcp`.\n \n### Details\n \nTwo problems combine.\n \n**1. The database-level read-only control is dead code.**\n \n`PostgresConnector.connect()` only enables it when `config.readonly` is truthy (`src/connectors/postgres/index.ts:175-177`):\n \n```ts\n// SDK-level readonly enforcement: Set default_transaction_read_only for the entire connection\nif (config?.readonly) {\n  poolConfig.options = (poolConfig.options || '') + ' -c default_transaction_read_only=on';\n}\n```\n \nSQLite is gated the same way (`src/connectors/sqlite/index.ts:192`). `ConnectorConfig.readonly` is assigned in exactly one place, and only from `source.readonly` (`src/connectors/manager.ts:236-238`):\n \n```ts\n// Pass readonly flag for SDK-level enforcement (PostgreSQL, SQLite)\nif (source.readonly !== undefined) {\n  config.readonly = source.readonly;\n}\n```\n \n`source.readonly` can never have a value:\n \n- `SourceConfig` has no `readonly` field (`src/types/config.ts:49-62`). `readonly` exists only on the per-tool `ExecuteSqlToolConfig` / `CustomToolConfig`.\n- The TOML loader rejects `readonly` at source level (`src/config/toml-loader.ts:476-481`: \"readonly must be configured per-tool, not per-source\").\n- The `--readonly` CLI flag was removed and now hard-exits (`src/config/env.ts:30`).\n \nSo the `if (source.readonly !== undefined)` check is always false, `config.readonly` stays unset, and DB-level read-only is never applied in any configuration the loader accepts. The per-tool `readonly` only ever reaches the classifier; `executeSQL()` ignores `options.readonly` and runs multi-statement batches in a plain `BEGIN` rather than `BEGIN READ ONLY` (`src/connectors/postgres/index.ts:598-666`).\n \n(The docs already describe the classifier as \"a safety net... not a security boundary.\" This report is about the DB-level control above, which the code clearly means to apply — see the \"SDK-level readonly enforcement\" comments — but silently fails to wire up.)\n \n**2. The classifier only checks the leading keyword.**\n \n`areAllStatementsReadOnly()` (`src/tools/execute-sql.ts:24-27`) splits on `;` and runs `isReadOnlySQL()` (`src/utils/allowed-keywords.ts`) on each statement. `isReadOnlySQL` matches the first word against an allow-list, scans for mutating keywords only inside `WITH`, blocks `SELECT ... INTO`, and special-cases `EXPLAIN ANALYZE`. It never looks at the functions a statement calls. These all classify as read-only:\n \n- `SELECT setval('seq', n)` / `nextval('seq')` — sequence write. Needs UPDATE (setval) or USAGE/UPDATE (nextval) on the sequence, which read roles normally hold.\n- `SELECT lo_export(lo, '/path')` — writes a file on the server. Needs superuser or `pg_write_server_files`.\n- `SELECT pg_read_file('/etc/passwd')` — reads any file the server user can read. Needs superuser or `pg_read_server_files`.\n- `SELECT dblink_exec('dbname=...', 'UPDATE ...')` — opens a fresh connection (not read-only) and runs writes/DDL. Needs the `dblink` extension.\n- `SELECT dblink_exec('dbname=...', $$COPY (SELECT 1) TO PROGRAM 'id'$$)` — command execution. Needs superuser or `pg_execute_server_program`, plus `dblink`.\n \nThe read-only test suite covers none of these.\n \n### PoC\n \nPoint DBHub at a PostgreSQL source with read-only set on the tool:\n \n```toml\n[[sources]]\nid = \"default\"\ndsn = \"postgres://app:app@localhost:5432/app\"\n \n[[tools]]\nname = \"execute_sql\"\nsource = \"default\"\nreadonly = true\n```\n \nStart it and call `execute_sql`:\n \n```\nnpx @bytebase/dbhub@latest --transport http --port 8080\n```\n \nWith any role, a write that should be blocked goes through — the sequence value changes and the call returns success:\n \n```sql\nSELECT setval('users_id_seq', 1);\n```\n \nWith a privileged role, the rest are also accepted and executed:\n \n```sql\nSELECT lo_export(lo_from_bytea(0, decode('48656c6c6f0a','hex')), '/tmp/dbhub_poc');   -- writes /tmp/dbhub_poc\nSELECT pg_read_file('/etc/passwd');                                                  -- reads a host file\nSELECT dblink_exec('dbname=app', 'UPDATE users SET admin=true');                     -- write via a new connection\nSELECT dblink_exec('dbname=app', $$COPY (SELECT 1) TO PROGRAM 'id > /tmp/pwned'$$);  -- runs a shell command\n```\n \nThe decision can be reproduced without a database by running the project's own `isReadOnlySQL` + `splitSQLStatements` (with `areAllStatementsReadOnly` copied from `src/tools/execute-sql.ts`) over the strings above: direct INSERT/UPDATE/DROP, data-modifying CTEs, `SELECT ... INTO`, and `EXPLAIN ANALYZE INSERT` are all rejected, while every function-based statement above returns read-only = true.\n \n### Impact\n \nAffects all released versions up to and including 0.22.2, on both stdio and HTTP transports, for PostgreSQL and SQLite. `readonly = true` does not stop writes. Anyone who can reach the `execute_sql` input can modify data under read-only mode — a network caller of the unauthenticated `/mcp` endpoint, a malicious MCP client, or untrusted content reaching an agent wired to DBHub through prompt injection. When the configured database role is privileged (common, since DBHub is often pointed at an existing admin DSN), the same access yields arbitrary file write on the server, arbitrary host-file read, and remote code execution on the database host.\n \n\n---\n\n### Maintainer note (consolidation)\n\nTracking this as the canonical advisory for \"read-only mode does not prevent database writes.\" The following reports describe the same root cause (read-only enforced only by the keyword classifier; the connection-level backstop was never wired) and are closed as duplicates:\n\n- **GHSA-7rgf-cwgq-c2qc** — same unwired driver-level backstop, plus the SQLite write-effecting `PRAGMA` gap.\n- **GHSA-m689-287g-5xpc** — SQLite assignment-form `PRAGMA` write bypass (a subset of the above).\n\nPreserving the SQLite-specific remediation from those reports: in `isReadOnlySQL`, the assignment form `PRAGMA x = ...` must be classified as a write (only the query/introspection form is read-only), and SQLite read-only executions are additionally guarded at the engine via `PRAGMA query_only=ON`.\n\nGHSA-j656-3hf2-fvjc (MySQL/MariaDB `--` comment parsing + `multipleStatements`) is a distinct root cause and is tracked separately.\n\nFix: https://github.com/bytebase/dbhub/pull/342 — adds engine-level read-only enforcement per tool (Postgres `BEGIN READ ONLY`, SQLite `query_only`, MySQL/MariaDB `START TRANSACTION READ ONLY`) plus the classifier hardening above.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@bytebase/dbhub"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.22.6"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/bytebase/dbhub/security/advisories/GHSA-mwwr-p57h-56pf"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-61788"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/bytebase/dbhub/pull/342"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/bytebase/dbhub/commit/872bb338f7d31f6afe517a076ac3e3edafaaaf08"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/bytebase/dbhub"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/bytebase/dbhub/releases/tag/v0.22.6"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-184", "CWE-636", "CWE-863" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-09-24T19:37:59Z",
    "nvd_published_at" : "2026-09-24T18:17:16Z"
  }
}