| tiêu đề | bytebase dbhub 1.2.3 Incorrect Access Control |
|---|
| Mô tả | Product: DBHub (bytebase/dbhub, database MCP gateway; official Docker image)
Affected versions: 1.2.3 (current release at report time; unfixed).
SUMMARY:
DBHub enforces read-only mode with two layers: a keyword classifier (escapeHatchFunctionKeywords, src/utils/allowed-keywords.ts) and a database-level BEGIN READ ONLY transaction (src/connectors/postgres/index.ts). For SQL Server, DBHub defends both layers against pass-through functions (OPENQUERY/OPENROWSET/OPENDATASOURCE, sqlServerPassThroughKeywords) whose work executes on a remote source and is therefore invisible to both layers. The PostgreSQL dblink family (dblink_exec, dblink, dblink_send_query) is exactly this class — remote execution from a plain SELECT, not contained by a read-only transaction — but is absent from escapeHatchFunctionKeywords.postgres. A tool argument (LLM-produced and steerable via prompt injection) such as
SELECT dblink_exec('host=internal-db port=5432 dbname=app user=app password=...',
'UPDATE accounts SET balance = 0 WHERE id = 1')
passes the classifier (leading keyword select, no matching escape-hatch function) and executes inside BEGIN READ ONLY without error, because the write happens on the remote libpq connection. The remote statement's status/rows are returned into the model context. The same holds for pg_advisory_lock/pg_advisory_xact_lock (session-level locks taken inside a read-only transaction persist on the pooled connection past COMMIT — the session-side-effect class DBHub already blocks for MySQL via get_lock/release_lock/release_all_locks).
IMPACT:
An attacker who can influence tool arguments (e.g. via prompt injection into an agent session, or a malicious MCP client) can make DBHub execute arbitrary SQL — UPDATE/DELETE/DDL/CREATE ROLE — on any PostgreSQL server reachable and authenticatable from the DBHub host (trust auth, .pgpass, or attacker-supplied credentials in the dblink parameter), while the operator believes the execute_sql tool is read-only (readOnlyHint=true). Remote data is returned into the model context (exfiltration channel), and dblink_connect to attacker-chosen hosts turns the MCP host into an internal-network probe (SSRF). pg_advisory_lock additionally enables cross-session denial of service that the query-timeout guardrail cannot cover, since the lock outlives the query.
This is exactly the boundary the existing guard was built to draw: the same file already rejects the SQL Server members of this class, and DBHub's own engine-layer comment claims the backstop "rejects any write, even one the keyword classifier failed to catch (e.g. SELECT setval())" — dblink defeats precisely that claim because the write is remote. DBHub's GHSA history treats read-only-mode gaps as security issues (GHSA-mwwr-p57h-56pf / CVE-2026-61788 scored 7.4; GHSA-j656-3hf2-fvjc / CVE-2026-61789).
Proof of impact (loopback lab, DBHub 1.2.3 official Docker image, [[tools]] readonly=true):
CTRL-1 tools/list: execute_sql readOnlyHint=true -> confirmed
CTRL-2 execute_sql "UPDATE local_secret ..." -> READONLY_VIOLATION (classifier fires)
CTRL-4 execute_sql "SELECT setval('probe_seq',1,false)" -> "cannot execute setval() in a read-only
transaction" (engine layer fires)
ATTACK execute_sql "SELECT dblink_exec('host=1do-dbhub-remote ...',
'UPDATE vault SET secret=''DBHUB-PWN-MARKER''')" -> success, "UPDATE 1"
physical verification (direct psql on the victim server, bypassing DBHub):
vault row = 1|DBHUB-PWN-MARKER (persistent write on another database)
ATTACK execute_sql "SELECT * FROM dblink(..., 'SELECT secret FROM vault')..."
-> victim data returned into model context
ATTACK execute_sql "SELECT pg_advisory_lock(4242)" -> success; a second session's
pg_advisory_lock(4242) cancels at statement_timeout=3s; pg_locks shows the pooled
connection (pid) holding the advisory lock
Preconditions (stated honestly): the local database has the dblink extension installed (contrib module, ships in the official PostgreSQL image, common in data platforms); the target server is reachable and authenticatable from the DBHub host. Deployments using stdio on a single-user machine are lower impact; DBHub's documented HTTP deployment (with the built-in workbench) is the primary exposure.
AFFECTED VERSION:
- 1.2.3 (current release, git tag v1.2.3 == 4ac6e89e; audited via official Docker image bytebase/dbhub:1.2.3)
CVSS:
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:N = 8.1 (self-assessed; happy to align with your CNA scoring — for reference, your CVE-2026-61788 for the same guard family scored 7.4)
SUGGESTED FIX:
Add the remote-execution class (and related session-side-effect class) to escapeHatchFunctionKeywords.postgres, mirroring sqlServerPassThroughKeywords:
postgres: ["pg_read_file", "pg_read_binary_file", "pg_ls_dir",
"dblink", "dblink_exec", "dblink_send_query",
"pg_advisory_lock", "pg_advisory_xact_lock",
"pg_stat_file"],
(If preferred, a deny-pattern in the postgres connector's read-only path as defense-in-depth works too.) Long term, structural statement parsing is the durable answer to list-vs-language drift — the same drift this file has been closing reactively per dialect (#349, #377, GHSA-61789).
CVSS v3.1: 8.1 (CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:N; self-assessed).
CWE: CWE-184 (Incomplete List of Disallowed Inputs)
DISCLOSURE: Reported privately to the maintainers via GitHub PVR on 2026-09-07 (GHSA-69r3-848g-rpx6, acknowledged the same day, state triage, no CVE requested through GitHub). Not publicly disclosed. Lab reproduction: 8/8 live tests on the official 1.2.3 Docker image, including physical verification of a persistent write on a second PostgreSQL server.
DEDUP: NVD/GitHub/OSV searched: DBHub advisory history for this guard family is GHSA-mwwr-p57h-56pf (CVE-2026-61788, 7.4) and GHSA-j656-3hf2-fvjc (CVE-2026-61789). Neither covers dblink or session-level advisory locks.
FIX: Add dblink, dblink_exec, dblink_send_query and pg_advisory_lock/pg_advisory_xact_lock to escapeHatchFunctionKeywords.postgres, mirroring sqlServerPassThroughKeywords; a deny-pattern in the postgres read-only path is an acceptable defense-in-depth supplement. |
|---|
| Người dùng | NeoWSY (UID 82976) |
|---|
| Đệ trình | 22/10/2026 13:27 (cách đây 29 ngày) |
|---|
| Kiểm duyệt | 20/11/2026 19:19 (29 days later) |
|---|
| Trạng thái | được chấp nhận |
|---|
| Mục VulDB | 441546 [Bytebase DBHub đến 2.0.0 Read Only Mode allowed-keywords.ts escapeHatchFunctionKeywords tool nâng cao đặc quyền] |
|---|
| điểm | 17 |
|---|