Arviser

A database tool's read-only mode that still lets writes through

Facts

Failure class
KB-P-0002 · AI applications, SaaS team security
Made public
2025-08-21 · Datadog Security Labs write-up on the read-only bypass in the reference PostgreSQL MCP server, the earliest entry in the table · source
Record published
2026-11-27 · CVE-2026-138032 (WhoDB), the latest record in the table · source
Our test run
2026-11-28 · Our lab run: PostgreSQL 18.6, six logins, four plain write statements, 3 runs per cell
CVE
CVE-2025-59333, CVE-2025-58337, CVE-2025-67509, CVE-2026-35402, CVE-2026-126196, CVE-2026-85620, CVE-2026-85787, CVE-2026-61788, CVE-2026-108604, CVE-2026-126197, CVE-2026-130008, CVE-2026-63129, CVE-2026-138032
GitHub advisory
GHSA-65hm-pwj5-73pw, GHSA-m35w-xx8c-6xc7, GHSA-j8g6-5gqc-mq36, GHSA-x3cv-r3g3-fpg9, GHSA-j7mp-839j-jrm7, GHSA-cm87-gp55-7cgj, GHSA-f4f4-39r8-8gj4, GHSA-mwwr-p57h-56pf, GHSA-jj9h-m6r9-g37h, GHSA-j656-3hf2-fvjc, GHSA-q433-mp6c-8v4f, GHSA-2m9m-6cr5-9x25, GHSA-rv9x-jh6w-58xh
CWE
CWE-863, CWE-89, CWE-284, CWE-184, CWE-436, CWE-636, CWE-693, CWE-94
Class
A database tool for AI agents advertises a read-only or restricted mode; a caller who controls the SQL writes anyway, or reads what it should not, because the check works on SQL text, not in the database
Entries
15, published from 2025-08 to 2026-11: 14 advisories and one researcher write-up, across SQLite, PostgreSQL, MySQL and MariaDB, MSSQL, Neo4j and Doris
Starting records
GHSA-q433-mp6c-8v4f (sqlite-mcp), GHSA-2m9m-6cr5-9x25 (mssql-mcp-core)
The control that holds
The database login's rights, plus revoking two PostgreSQL defaults (section 6)
Tested by us
2026-11-28, PostgreSQL 18.6, six logins, plain statements only (lab, summary)
Check
check-db-login.sh <connection-string>: asks the database which write rights the login holds; writes nothing
Next review
2027-05-28

Short answer: Database tools for AI agents (MCP servers) offer a "read-only" mode, and in record after record a caller who controls the SQL wrote anyway, or read what it should not. The mode was usually a check on the SQL text, such as "starts with SELECT". A SELECT can change state, and several of these servers passed the whole string to a driver that runs every statement in it. The control that holds is the database login's own rights. To check your setup, ask the database which write rights your server's login holds.

1. What goes wrong

A read-only database tool takes SQL from the caller and should run it only if it reads. In most of these records the check worked on the text of the query: it had to start with SELECT, or it must not contain a word from a block list. Two things defeat that.

A SELECT can change state. SELECT setval(...) moves a sequence. SELECT ... INTO t creates a table. On PostgreSQL, SELECT lo_export(...) writes a file on the database host, for a login allowed to call it. A function called from a SELECT does whatever the function does.

Some servers passed the whole string to a driver that runs every statement in it. Among the records with a fixed version, these name the drivers: modernc.org/sqlite in sqlite-mcp, node-mssql's batch API in mssql-mcp-core, mysql2 with multipleStatements: true in DBHub, and the pgx simple query protocol in pgEdge's server. In those servers a string that started with SELECT and carried a second statement passed the check, and the driver ran both.

The records add other paths to the same end: a comment marker that DBHub's parser and MySQL read differently (GHSA-j656-3hf2-fvjc), a dollar-quoted block that a tool argument could close (CVE-2026-126197), a guard that matched only two literal setting names (GHSA-j7mp-839j-jrm7), and a database-level read-only setting the server meant to apply but never did (CVE-2026-61788).

Who sends the SQL matters. These tools exist so an AI agent can query a database, and an agent can be steered by text it reads. The mssql-mcp-core advisory names "an LLM agent steered via indirect prompt injection" as one caller (GHSA-2m9m-6cr5-9x25). Read-only mode is meant to hold when the agent is not fully trusted.

2. The records, 2025 to 2026

Dates are each record's own publication date. Four entries have no fixed version in the record as of 2026-11-28. None of these records is in the CISA KEV catalog as of 2026-11-28 (catalog version 2026.11.27, read that day).

Published Product (ecosystem) Record Affected; fixed What the record says
2025-08-21 reference @modelcontextprotocol/server-postgres (npm, archived) Datadog write-up, no CVE 0.6.2; no fixed version in the record as of 2026-11-28 (deprecated 2025-07-10; the write-up names a fixed fork) Read-only restriction can be bypassed. Partial mitigation: a Postgres user with restricted privileges, or move off the package
2025-09-16 @executeautomation/database-server (npm) CVE-2025-59333 <= 1.1.0; no fixed version in the record as of 2026-11-28 "Read-only" mode not enforced. Mitigation: a login without write rights
2025-11-05 Apache Doris MCP Server (pip) CVE-2025-58337 < 0.6.0; 0.6.0 "An attacker with a valid read-only account can bypass Doris MCP Server’s read-only mode due to improper access control"
2025-12-09 Neuron MySQLSelectTool (composer) CVE-2025-67509 <= 2.8.11; 2.8.12 First-keyword and block-list check missed INTO OUTFILE and INTO DUMPFILE; files written with the FILE privilege
2026-04-17 mcp-neo4j-cypher (pip) CVE-2026-35402 < 0.6.0; 0.6.0 read_only mode bypassed through CALL procedures
2026-09-03 pgEdge Postgres MCP Server GHSA-j7mp-839j-jrm7 (CVE-2026-126196) <= 1.0.0; 1.1.0 The guard matched only two literal setting names; reads were detected by prefix; statements went over a protocol that accepts several per message
2026-09-04 Postgres MCP Pro postgres-mcp (pip) CVE-2026-85620 <= 0.3.0; no fixed version in the record as of 2026-11-28 Restricted mode can be bypassed to read files on the server. Our mitigation: a login without file-reading rights
2026-09-04 awslabs postgres-mcp-server (pip) CVE-2026-85787 < 1.1.7; 1.1.7 "An incomplete list of disallowed inputs" allowed changes "beyond the read-only scope"
2026-09-24 @bytebase/dbhub (npm) CVE-2026-61788 < 0.22.6; 0.22.6 The database-level read-only setting was dead code; only a first-keyword classifier remained
2026-10-10 Tabularis (desktop app) CVE-2026-108604 through 0.27.0; no fixed version in the record as of 2026-11-28 MCP read-only mode can be bypassed. Our mitigation: a login without write rights. A related describe_table record names 0.28.0 as fixed (GHSA-xrx3-j98v-67x9)
2026-11-02 @bytebase/dbhub (npm) GHSA-j656-3hf2-fvjc, no CVE < 0.22.6; 0.22.6 On MySQL and MariaDB, DBHub's parser treated -- as a comment where the database did not, so a second statement went unchecked
2026-11-12 pgEdge Postgres MCP Server CVE-2026-126197 < 1.1.0; 1.1.0 A pl-do tool argument could close the fixed dollar-quote block and add statements, "bypassing read_only"
2026-11-18 sqlite-mcp (go) GHSA-q433-mp6c-8v4f (CVE-2026-130008) < 0.1.2; 0.1.2 SELECT-prefix check plus chained statements; ATTACH DATABASE opened files read-write despite mode=ro
2026-11-18 mssql-mcp-core (npm) GHSA-2m9m-6cr5-9x25 (CVE-2026-63129) core <= 0.5.0; 0.6.0 Identifiers and whereClause interpolated into T-SQL; one injectable tool is "reachable even under READONLY=true"
2026-11-27 WhoDB (go) CVE-2026-138032 records disagree: CVE 0.88.0 to < 0.132.0; repository advisories <= 0.131.0, fixed 0.134.0 Keyword classifier omitted INTO, OUTFILE, DUMPFILE; file-writing SELECT ran under --read-only

On WhoDB: the CVE record says the fix is in 0.132.0. The repository advisories (GHSA-pvf2-6h4x-r24j, GHSA-6mr5-wx6p-65fg) name 0.134.0, and the 0.134.0 release notes list both fixes. Use 0.134.0 or later.

We opened these records on 2026-11-28. A neighbouring class, where the tool skips authorization rather than read-only, has records of its own, for example Bytebase DBHub, ZDI-26-1067.

3. Why the flag does not hold, and what does

Short answer, our view: a read-only check inside the tool decides from the SQL text, and SQL has more ways to change state than a list can name. The database checks rights on every statement it runs, whatever the text looked like.

Fixes moved the check into the database. DBHub PR #342, the fix for 0.22.6, wraps each read-only tool call in a read-only transaction (BEGIN READ ONLY on PostgreSQL, START TRANSACTION READ ONLY on MySQL and MariaDB) and sets PRAGMA query_only on SQLite. sqlite-mcp 0.1.2 sets query_only and disables ATTACH (advisory). The same DBHub PR states the limits of that layer: on MySQL and MariaDB, DDL "performs an implicit commit that ends the read-only transaction", and the PostgreSQL vectors that need a privileged role "are not closeable by a read-only transaction"; the PR leaves them to least privilege.

The write runs with the login's rights. The records that give mitigation advice point at those rights. The Neo4j advisory: "The only way to guarantee the server actions is to limit the permissions of the db credentials available to the server" (CVE-2026-35402). pgEdge lists as affected deployments that rely on read_only "and connects with a role holding write privileges" (GHSA-j7mp-839j-jrm7). Datadog recommends "a Postgres user with restricted privileges", while noting it does not fix shared session state in a connection pool (write-up). WhoDB says its issue "does not bypass database authorization", and that ordinary accounts without file privileges were denied (GHSA-6mr5-wx6p-65fg).

A setting is a default; a right is a boundary. PostgreSQL's default_transaction_read_only "controls the default read-only status of each new transaction" (docs), and a session can set it off. A session cannot grant itself a right. Our lab shows both (section 5).

Rights on tables are not the whole story. By default PostgreSQL grants PUBLIC the right to create temporary tables in a database and to execute functions (docs, section 5.8). In our lab a login with SELECT on one table and nothing else could still create a temporary table and a large object, until we revoked those defaults (section 5). A function that writes, and in particular a SECURITY DEFINER function, runs with its own rights for anyone allowed to execute it. "Read-only by rights" therefore needs those defaults reviewed too.

4. Tell whether your setup is exposed

Find the login. Read the connection string where the MCP server reads it: its environment, .env, the compose file, the command line. env in your own shell says nothing about the service.

Ask the database what that login may do. The script connects as that login and asks PostgreSQL which write rights it holds, directly or through any role it can switch to with SET ROLE. It writes nothing.

PGPASSWORD=... sh check-db-login.sh "postgresql://agent_user@db.internal:5432/app"

It needs sh and psql (script). Run it only against a database you own or are allowed to test. It reports WRITE-CAPABLE for any of:

It also warns about pg_read_server_files and notes when the login can create temporary tables.

Exit Verdict What it means
0 READ-ONLY BY RIGHTS None of the rights above was found. Not a proof that nothing can change: see the list below
1 WRITE-CAPABLE At least one write right was found, and the script lists it. The tool's read-only flag is the only thing in the way
2 NOT TESTED No connection, a query failed, or an answer could not be read. Never read it as safe

The script fails closed: in our lab it gave exit 2 when a stub psql returned an error, a superuser value other than on or off, a count that was not a number, or an incomplete answer, 3 of 3 runs each.

For MySQL or MariaDB, run SHOW GRANTS as the login and look for anything beyond SELECT, in particular FILE, which the Neuron and WhoDB records need for their file writes.

Exit 0 does not rule out: EXECUTE on functions (granted to PUBLIC by default), including SECURITY DEFINER functions and functions that write; the TRIGGER and MAINTAIN privileges on tables; creating large objects; creating temporary tables (reported as a note, not a write); extension functions such as dblink; other databases on the same server; reads the login is allowed, including reads of data the agent should not see; and anything above the database, such as the tool's authentication and who can reach its port.

5. What we ran

Short answer: 180 database runs and 21 stub runs on 2026-11-28, all matching the results we wrote down before the first run. A login with SELECT rights only refused every write by rights, and a login with an UPDATE right on one column could write that column, which the reader's test reports. A login with write rights and a read-only setting refused writes only until its session turned the setting off. The SELECT-only login could still create a temporary table and a large object until we revoked two PostgreSQL defaults.

Run on 2026-11-28 by Claude Opus 5.5, an AI model, with Docker 29.10.0 on one Linux host and the image postgres:18 (18.6) by digest. A separate AI agent checked the lab record. Raw files: results/2026-11-28/v3-run-1/. No vulnerable product, no bypass, no COMMIT or chained statements: each statement is one plain statement in a new session.

Six logins: agent_owner (owns the data and can create tables), agent_flag (the same rights, plus a role-level default_transaction_read_only = on), agent_ro (SELECT on one table, plus the same setting), agent_sel (SELECT on one table, no setting), agent_col (SELECT on one table plus UPDATE on one of its columns, no setting), and postgres (superuser, positive control).

Four statements:

Each ran in two modes: as connected, and with the setting off, where the session first runs SET default_transaction_read_only = off.

Tested by us, 2026-11-28 (3 runs per cell; every cell gave the same result in all 3; summary). The code after HELD is the SQLSTATE: 42501 refused by rights, 25006 refused by the read-only setting.

Login W1 setval, as connected W1, setting off W2 SELECT INTO, as connected W2, setting off W3 INSERT, as connected W3, setting off W4 UPDATE, as connected W4, setting off
agent_owner WROTE WROTE WROTE WROTE WROTE WROTE WROTE WROTE
agent_flag HELD 25006 WROTE HELD 25006 WROTE HELD 25006 WROTE HELD 25006 WROTE
agent_ro HELD 42501 HELD 42501 HELD 25006 HELD 42501 HELD 25006 HELD 42501 HELD 25006 HELD 42501
agent_sel HELD 42501 HELD 42501 HELD 42501 HELD 42501 HELD 42501 HELD 42501 HELD 42501 HELD 42501
agent_col HELD 42501 HELD 42501 HELD 42501 HELD 42501 HELD 42501 HELD 42501 WROTE WROTE
postgres WROTE WROTE WROTE WROTE WROTE WROTE WROTE WROTE

WROTE means the host saw our marker after the session (a moved sequence, a new table, a new row or a changed row in our own throwaway database). HELD means no marker, while the same login's control read worked.

What each row shows.

Defaults that table rights do not cover (agent_sel, as connected):

Statement Default database After revoking TEMPORARY and the large-object functions from PUBLIC
CREATE TEMP TABLE, insert a row, read it back WROTE HELD 42501
SELECT lo_from_bytea(0, ...), a new large object WROTE HELD 42501

Both match the PostgreSQL defaults: TEMPORARY on databases and EXECUTE on functions are granted to PUBLIC (docs, section 5.8). Neither changes the data the agent reads, but both are writes a "read-only" login can make.

Reader's test on the same logins, 3 of 3 runs each: WRITE-CAPABLE (exit 1) for agent_owner, agent_flag, agent_col and postgres; READ-ONLY BY RIGHTS (exit 0) for agent_ro and agent_sel, with the temporary-table note, and for agent_sel on the hardened database without it; NOT TESTED (exit 2) for a wrong password. agent_flag came out WRITE-CAPABLE although its read-only setting was on, because the script reports rights, not settings. Against a stub psql, it gave exit 2 for each malformed or failed answer and exit 1 for a superuser or a reachable role with a role attribute.

How the runs changed. Version 1 of this lab, run earlier on 2026-11-28, also used two statements that end a read-only transaction with COMMIT before writing.

The independent check ruled them out, because that shape matches the bypass of the archived reference server, which has no fixed version. We wrote new expectations and removed those statements and the raw output of the version 1 runs from the lab folder.

Version 1 also had three smoke runs: the first failed on folder permissions; the second showed that agent_owner lacked CREATE and that the reader's test, which then tried a write, mislabelled write-capable logins, so the test was changed to ask the database instead of writing.

In version 2 the smoke run matched every expectation; after it, the reader's test was changed to count distinct objects (it had counted one schema once per reachable role). No verdict depends on that change.

The re-check then found that version 2 of the reader's test missed INSERT and UPDATE rights granted on single columns. Version 3 checks them, adds agent_col and W4, and reran the whole lab; its smoke run matched every expectation, with no change after it. Each version's expectations were written and hashed before its first container started (EXPECTED-v2.md, EXPECTED-v3.md). The version 2 runs stay in the lab folder (v2-smoke-1, v2-run-1).

Limits of the runs. We ran no MCP product (sqlite-mcp, mssql-mcp-core, DBHub, WhoDB or any other) and reproduced no bypass. PostgreSQL 18 only, on one host. MySQL's FILE privilege, file-reading functions, SECURITY DEFINER functions and reads were not tested.

6. The control that holds, and the ones that do not hold alone

Short answer: give the agent a login with SELECT on what it needs and nothing else, revoke the two PostgreSQL defaults, then upgrade the tool and keep it off the open network.

7. Questions for your team

  1. Which login does each MCP server or agent tool connect with, and what does check-db-login.sh print for it?
  2. Is any agent login an owner, a superuser, or a member of a role that owns data, because it was the login at hand?
  3. Have we revoked TEMPORARY and the large-object functions from PUBLIC, and which SECURITY DEFINER functions can the agent's login execute?
  4. On MySQL, does the agent's login hold FILE?
  5. Which of our database tools has an open advisory for the installed version, and which has no fixed version at all?

Sources

Primary records first. Record identifiers link from the facts box.

Records and release notes

Vendor documentation and statements

Researchers

Our lab

Corrections

No corrections.

Report an error to contact@arviser.com.

How this page was made: Claude Opus 5.5, an AI model, read the records and the product source, ran the lab and wrote this page. A separate AI agent checked the claims against the sources and the lab record; the page and the lab were revised after each of two checks, and a third check led to corrected table labels. Vadim Nareyko set the scope and the publishing rules. This page was not reviewed by Vadim Nareyko. On 28 November 2026 Vadim Nareyko decided that new pages are published after the linters and an independent check, without that review.

Text and data on this page: CC BY 4.0. Code in our lab: MIT. Quoted third-party material keeps its own terms.

Request a security review