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

By Vadim Nareyko, founder, Arviser. Published 2026-11-28 · Updated 2026-11-28 · Last reviewed 2026-11-28

## 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 (https://securitylabs.datadoghq.com/articles/mcp-vulnerability-case-study-SQL-injection-in-the-postgresql-mcp-server.md)
- Record published: 2026-11-27 · CVE-2026-138032 (WhoDB), the latest record in the table (https://github.com/advisories/GHSA-rv9x-jh6w-58xh)
- 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](https://www.cve.org/CVERecord?id=CVE-2025-59333)
- CVE: [CVE-2025-58337](https://www.cve.org/CVERecord?id=CVE-2025-58337)
- CVE: [CVE-2025-67509](https://www.cve.org/CVERecord?id=CVE-2025-67509)
- CVE: [CVE-2026-35402](https://www.cve.org/CVERecord?id=CVE-2026-35402)
- CVE: [CVE-2026-126196](https://www.cve.org/CVERecord?id=CVE-2026-126196)
- CVE: [CVE-2026-85620](https://www.cve.org/CVERecord?id=CVE-2026-85620)
- CVE: [CVE-2026-85787](https://www.cve.org/CVERecord?id=CVE-2026-85787)
- CVE: [CVE-2026-61788](https://www.cve.org/CVERecord?id=CVE-2026-61788)
- CVE: [CVE-2026-108604](https://www.cve.org/CVERecord?id=CVE-2026-108604)
- CVE: [CVE-2026-126197](https://www.cve.org/CVERecord?id=CVE-2026-126197)
- CVE: [CVE-2026-130008](https://www.cve.org/CVERecord?id=CVE-2026-130008)
- CVE: [CVE-2026-63129](https://www.cve.org/CVERecord?id=CVE-2026-63129)
- CVE: [CVE-2026-138032](https://www.cve.org/CVERecord?id=CVE-2026-138032)
- GitHub advisory: [GHSA-65hm-pwj5-73pw](https://github.com/advisories/GHSA-65hm-pwj5-73pw)
- GitHub advisory: [GHSA-m35w-xx8c-6xc7](https://github.com/advisories/GHSA-m35w-xx8c-6xc7)
- GitHub advisory: [GHSA-j8g6-5gqc-mq36](https://github.com/advisories/GHSA-j8g6-5gqc-mq36)
- GitHub advisory: [GHSA-x3cv-r3g3-fpg9](https://github.com/advisories/GHSA-x3cv-r3g3-fpg9)
- GitHub advisory: [GHSA-j7mp-839j-jrm7](https://github.com/pgEdge/pgedge-postgres-mcp/security/advisories/GHSA-j7mp-839j-jrm7)
- GitHub advisory: [GHSA-cm87-gp55-7cgj](https://github.com/advisories/GHSA-cm87-gp55-7cgj)
- GitHub advisory: [GHSA-f4f4-39r8-8gj4](https://github.com/advisories/GHSA-f4f4-39r8-8gj4)
- GitHub advisory: [GHSA-mwwr-p57h-56pf](https://github.com/advisories/GHSA-mwwr-p57h-56pf)
- GitHub advisory: [GHSA-jj9h-m6r9-g37h](https://github.com/advisories/GHSA-jj9h-m6r9-g37h)
- GitHub advisory: [GHSA-j656-3hf2-fvjc](https://github.com/advisories/GHSA-j656-3hf2-fvjc)
- GitHub advisory: [GHSA-q433-mp6c-8v4f](https://github.com/advisories/GHSA-q433-mp6c-8v4f)
- GitHub advisory: [GHSA-2m9m-6cr5-9x25](https://github.com/advisories/GHSA-2m9m-6cr5-9x25)
- GitHub advisory: [GHSA-rv9x-jh6w-58xh](https://github.com/advisories/GHSA-rv9x-jh6w-58xh)
- CWE: [CWE-863](https://cwe.mitre.org/data/definitions/863.html)
- CWE: [CWE-89](https://cwe.mitre.org/data/definitions/89.html)
- CWE: [CWE-284](https://cwe.mitre.org/data/definitions/284.html)
- CWE: [CWE-184](https://cwe.mitre.org/data/definitions/184.html)
- CWE: [CWE-436](https://cwe.mitre.org/data/definitions/436.html)
- CWE: [CWE-636](https://cwe.mitre.org/data/definitions/636.html)
- CWE: [CWE-693](https://cwe.mitre.org/data/definitions/693.html)
- CWE: [CWE-94](https://cwe.mitre.org/data/definitions/94.html)
- 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](https://github.com/advisories/GHSA-q433-mp6c-8v4f) (sqlite-mcp), [GHSA-2m9m-6cr5-9x25](https://github.com/advisories/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](https://github.com/nareyko/arviser-labs/tree/eff5333621201b67e2b4fed0f039e2902704b9bf/tested-threats/db-mcp-read-only), [summary](https://github.com/nareyko/arviser-labs/blob/eff5333621201b67e2b4fed0f039e2902704b9bf/tested-threats/db-mcp-read-only/results/2026-11-28/v3-run-1/summary.md))
- Check: [`check-db-login.sh <connection-string>`](https://github.com/nareyko/arviser-labs/blob/eff5333621201b67e2b4fed0f039e2902704b9bf/tested-threats/db-mcp-read-only/check-db-login.sh): asks the database which write rights the login holds; writes nothing

**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](https://github.com/advisories/GHSA-j656-3hf2-fvjc)), a dollar-quoted block that a tool argument could close ([CVE-2026-126197](https://nvd.nist.gov/vuln/detail/CVE-2026-126197)), a guard that matched only two literal setting names ([GHSA-j7mp-839j-jrm7](https://github.com/pgEdge/pgedge-postgres-mcp/security/advisories/GHSA-j7mp-839j-jrm7)), and a database-level read-only setting the server meant to apply but never did ([CVE-2026-61788](https://github.com/advisories/GHSA-mwwr-p57h-56pf)).

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](https://github.com/advisories/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](https://www.cisa.gov/known-exploited-vulnerabilities-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](https://securitylabs.datadoghq.com/articles/mcp-vulnerability-case-study-SQL-injection-in-the-postgresql-mcp-server.md), 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](https://github.com/advisories/GHSA-65hm-pwj5-73pw) | `<= 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](https://github.com/advisories/GHSA-m35w-xx8c-6xc7) | `< 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](https://github.com/advisories/GHSA-j8g6-5gqc-mq36) | `<= 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](https://github.com/advisories/GHSA-x3cv-r3g3-fpg9) | `< 0.6.0`; 0.6.0 | `read_only` mode bypassed through `CALL` procedures |
| 2026-09-03 | pgEdge Postgres MCP Server | [GHSA-j7mp-839j-jrm7](https://github.com/pgEdge/pgedge-postgres-mcp/security/advisories/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](https://github.com/advisories/GHSA-cm87-gp55-7cgj) | `<= 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](https://github.com/advisories/GHSA-f4f4-39r8-8gj4) | `< 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](https://github.com/advisories/GHSA-mwwr-p57h-56pf) | `< 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](https://github.com/advisories/GHSA-jj9h-m6r9-g37h) | 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](https://github.com/TabularisDB/tabularis/security/advisories/GHSA-xrx3-j98v-67x9)) |
| 2026-11-02 | `@bytebase/dbhub` (npm) | [GHSA-j656-3hf2-fvjc](https://github.com/advisories/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](https://nvd.nist.gov/vuln/detail/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](https://github.com/advisories/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](https://github.com/advisories/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](https://github.com/advisories/GHSA-rv9x-jh6w-58xh) | 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](https://github.com/clidey/whodb/security/advisories/GHSA-pvf2-6h4x-r24j), [GHSA-6mr5-wx6p-65fg](https://github.com/clidey/whodb/security/advisories/GHSA-6mr5-wx6p-65fg)) name 0.134.0, and the [0.134.0 release notes](https://github.com/clidey/whodb/releases/tag/0.134.0) 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](https://github.com/advisories/GHSA-hvw4-mh2q-3vph).

## 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](https://github.com/bytebase/dbhub/pull/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](https://github.com/advisories/GHSA-q433-mp6c-8v4f)). 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](https://github.com/advisories/GHSA-x3cv-r3g3-fpg9)). pgEdge lists as affected deployments that rely on `read_only` "and connects with a role holding write privileges" ([GHSA-j7mp-839j-jrm7](https://github.com/pgEdge/pgedge-postgres-mcp/security/advisories/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](https://securitylabs.datadoghq.com/articles/mcp-vulnerability-case-study-SQL-injection-in-the-postgresql-mcp-server.md)). WhoDB says its issue "does not bypass database authorization", and that ordinary accounts without file privileges were denied ([GHSA-6mr5-wx6p-65fg](https://github.com/clidey/whodb/security/advisories/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](https://www.postgresql.org/docs/18/runtime-config-client.html)), 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](https://www.postgresql.org/docs/18/ddl-priv.html)). 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.

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

It needs `sh` and `psql` ([script](https://github.com/nareyko/arviser-labs/blob/eff5333621201b67e2b4fed0f039e2902704b9bf/tested-threats/db-mcp-read-only/check-db-login.sh)). Run it only against a database you own or are allowed to test. It reports WRITE-CAPABLE for any of:

- superuser, or `SUPERUSER`, `CREATEROLE` or `CREATEDB` on the login or a role it can switch to;
- membership in `pg_write_server_files`, `pg_execute_server_program` or `pg_write_all_data`;
- `CREATE` on the database or on a schema;
- ownership of a table, view, sequence or schema;
- `INSERT` or `UPDATE` on a table or any of its columns, `DELETE` or `TRUNCATE`, on a table, view or foreign table;
- `UPDATE` or `USAGE` on a sequence (`nextval` and `setval`).

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/`](https://github.com/nareyko/arviser-labs/tree/eff5333621201b67e2b4fed0f039e2902704b9bf/tested-threats/db-mcp-read-only/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:

- W1, `SELECT setval(...)`: a `SELECT` that moves a sequence.
- W2, `SELECT 1 AS m INTO marker_s2`: a `SELECT` that creates a table.
- W3, a plain `INSERT`.
- W4, a plain `UPDATE` of one column of one row.

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](https://github.com/nareyko/arviser-labs/blob/eff5333621201b67e2b4fed0f039e2902704b9bf/tested-threats/db-mcp-read-only/results/2026-11-28/v3-run-1/summary.md)). 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.**

- `agent_sel`: rights alone refused all four statements in both modes, with 42501. No read-only setting was involved.
- `agent_flag`: the read-only setting refused all four (25006) until the session turned it off; then all four wrote. The setting is a default the session controls.
- `agent_ro`: as connected, the setting refused W2, W3 and W4 first (25006), so those three results say nothing about rights; W1 was refused by rights (42501), because PostgreSQL checked the sequence right first. With the setting off, rights refused all four (42501).
- `agent_col`: a right on one column is a write right. It wrote W4 and nothing else.
- `agent_owner` and `postgres` wrote in every cell: the marker check sees a write when there is one.

**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](https://www.postgresql.org/docs/18/ddl-priv.html)). 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](https://github.com/nareyko/arviser-labs/blob/eff5333621201b67e2b4fed0f039e2902704b9bf/tested-threats/db-mcp-read-only/expected/EXPECTED-v2.md), [EXPECTED-v3.md](https://github.com/nareyko/arviser-labs/blob/eff5333621201b67e2b4fed0f039e2902704b9bf/tested-threats/db-mcp-read-only/expected/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.

- **A login without write rights.** Create a role with `CONNECT`, schema `USAGE` and `SELECT` on the tables the agent needs. Do not make it an owner, and do not grant it membership in roles that own data. Check it with the script in section 4.

- **Revoke the defaults that table rights miss.** We tested these two in the lab:

  ```sql
  REVOKE TEMPORARY ON DATABASE app FROM PUBLIC;
  REVOKE EXECUTE ON FUNCTION lo_from_bytea(oid, bytea), lo_create(oid), lo_creat(integer) FROM PUBLIC;
  ```

  Revoking from `PUBLIC` affects every login without a direct grant, so check that your applications do not rely on them. Not tested by us, and worth doing: list the `SECURITY DEFINER` functions the agent's login can execute and revoke `EXECUTE` where it does not need them; use `ALTER DEFAULT PRIVILEGES ... REVOKE EXECUTE ON FUNCTIONS FROM PUBLIC` for functions created later ([docs](https://www.postgresql.org/docs/18/ddl-priv.html)). Do not grant `pg_read_server_files`, `pg_write_server_files` or `pg_execute_server_program`; the docs warn they "could be used to gain superuser-level access" ([predefined roles](https://www.postgresql.org/docs/18/predefined-roles.html)). On MySQL, do not grant `FILE`.

- **Upgrade the tool where a fix exists.** sqlite-mcp 0.1.2, mssql-mcp-core 0.6.0 (with reader and writer 0.5.0, server 0.6.0), DBHub 0.22.6, WhoDB 0.134.0, pgEdge 1.1.0, awslabs `postgres-mcp-server` 1.1.7, Neuron 2.8.12, `mcp-neo4j-cypher` 0.6.0, Doris MCP Server 0.6.0 (0.6.1 for its two later SQL injection records). For the archived reference server, the executeautomation server, Postgres MCP Pro and Tabularis, the records give no fixed version as of 2026-11-28: the login's rights are the fix you control.

- **Keep the tool's read-only mode on, as one layer.** DBHub's own documentation calls its classifier "a safety net... not a security boundary" ([quoted in CVE-2026-61788](https://github.com/advisories/GHSA-mwwr-p57h-56pf)).

- **Keep the server off the open network.** sqlite-mcp "has no built-in authentication and, by default, listens on `:8080` on all interfaces" ([advisory](https://github.com/advisories/GHSA-q433-mp6c-8v4f)); DBHub's HTTP transport was unauthenticated and bound `0.0.0.0` ([CVE-2026-61788](https://github.com/advisories/GHSA-mwwr-p57h-56pf)). Use loopback, a private interface or an authenticating proxy.

- **Point the agent at a copy.** A read replica or a separate database means a write that gets through lands on a copy. Our suggestion, not from a record.

## 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?

## Related pages

- [LiteLLM /public/mcp_hub (GHSA-28j3-9x3h-556f): tested on six versions, and a check for your instance](/library/tests/litellm-public-mcp-hub-ghsa-28j3)

## Sources

- Datadog Security Labs, "MCP vulnerability case study: SQL injection in the PostgreSQL MCP server", Santiago Mola, 2025-08-21: https://securitylabs.datadoghq.com/articles/mcp-vulnerability-case-study-SQL-injection-in-the-postgresql-mcp-server.md (accessed 2026-11-28)
- CVE-2025-59333 (GHSA-65hm-pwj5-73pw), @executeautomation/database-server: https://github.com/advisories/GHSA-65hm-pwj5-73pw (accessed 2026-11-28)
- CVE-2025-58337 (GHSA-m35w-xx8c-6xc7), Apache Doris MCP Server: https://github.com/advisories/GHSA-m35w-xx8c-6xc7 (accessed 2026-11-28)
- CVE-2025-67509 (GHSA-j8g6-5gqc-mq36), Neuron: https://github.com/advisories/GHSA-j8g6-5gqc-mq36 (accessed 2026-11-28)
- CVE-2026-35402 (GHSA-x3cv-r3g3-fpg9), mcp-neo4j-cypher: https://github.com/advisories/GHSA-x3cv-r3g3-fpg9 (accessed 2026-11-28)
- GHSA-j7mp-839j-jrm7 (CVE-2026-126196), pgEdge Postgres MCP Server, repository advisory: https://github.com/pgEdge/pgedge-postgres-mcp/security/advisories/GHSA-j7mp-839j-jrm7 (accessed 2026-11-28)
- CVE-2026-85620 (GHSA-cm87-gp55-7cgj), Postgres MCP Pro: https://github.com/advisories/GHSA-cm87-gp55-7cgj (accessed 2026-11-28)
- CVE-2026-85787 (GHSA-f4f4-39r8-8gj4), awslabs postgres-mcp-server: https://github.com/advisories/GHSA-f4f4-39r8-8gj4 (accessed 2026-11-28)
- CVE-2026-61788 (GHSA-mwwr-p57h-56pf), @bytebase/dbhub: https://github.com/advisories/GHSA-mwwr-p57h-56pf (accessed 2026-11-28)
- GHSA-j656-3hf2-fvjc, @bytebase/dbhub: https://github.com/advisories/GHSA-j656-3hf2-fvjc (accessed 2026-11-28)
- DBHub pull request #342, the fix for 0.22.6: https://github.com/bytebase/dbhub/pull/342 (accessed 2026-11-28)
- CVE-2026-108604 (GHSA-jj9h-m6r9-g37h), Tabularis: https://github.com/advisories/GHSA-jj9h-m6r9-g37h (accessed 2026-11-28)
- GHSA-xrx3-j98v-67x9, Tabularis describe_table, repository advisory: https://github.com/TabularisDB/tabularis/security/advisories/GHSA-xrx3-j98v-67x9 (accessed 2026-11-28)
- CVE-2026-126197, pgEdge Postgres MCP Server (NVD): https://nvd.nist.gov/vuln/detail/CVE-2026-126197 (accessed 2026-11-28)
- GHSA-q433-mp6c-8v4f (CVE-2026-130008), sqlite-mcp: https://github.com/advisories/GHSA-q433-mp6c-8v4f (accessed 2026-11-28)
- GHSA-2m9m-6cr5-9x25 (CVE-2026-63129), mssql-mcp-core: https://github.com/advisories/GHSA-2m9m-6cr5-9x25 (accessed 2026-11-28)
- CVE-2026-138032 (GHSA-rv9x-jh6w-58xh), WhoDB: https://github.com/advisories/GHSA-rv9x-jh6w-58xh (accessed 2026-11-28)
- GHSA-pvf2-6h4x-r24j, WhoDB, repository advisory: https://github.com/clidey/whodb/security/advisories/GHSA-pvf2-6h4x-r24j (accessed 2026-11-28)
- GHSA-6mr5-wx6p-65fg, WhoDB, repository advisory: https://github.com/clidey/whodb/security/advisories/GHSA-6mr5-wx6p-65fg (accessed 2026-11-28)
- WhoDB 0.134.0 release notes: https://github.com/clidey/whodb/releases/tag/0.134.0 (accessed 2026-11-28)
- GHSA-hvw4-mh2q-3vph (ZDI-26-1067), Bytebase DBHub, a neighbouring class: https://github.com/advisories/GHSA-hvw4-mh2q-3vph (accessed 2026-11-28)
- CISA, Known Exploited Vulnerabilities catalog (catalog version 2026.11.27): https://www.cisa.gov/known-exploited-vulnerabilities-catalog (accessed 2026-11-28)
- PostgreSQL 18 documentation, privileges (section 5.8): https://www.postgresql.org/docs/18/ddl-priv.html (accessed 2026-11-28)
- PostgreSQL 18 documentation, client connection defaults: https://www.postgresql.org/docs/18/runtime-config-client.html (accessed 2026-11-28)
- PostgreSQL 18 documentation, predefined roles: https://www.postgresql.org/docs/18/predefined-roles.html (accessed 2026-11-28)
- Our lab, arviser-labs at commit eff5333, tested-threats/db-mcp-read-only: https://github.com/nareyko/arviser-labs/tree/eff5333621201b67e2b4fed0f039e2902704b9bf/tested-threats/db-mcp-read-only (accessed 2026-11-28)
- Our lab, version 3 run of 2026-11-28: summary, raw files and hashes: https://github.com/nareyko/arviser-labs/tree/eff5333621201b67e2b4fed0f039e2902704b9bf/tested-threats/db-mcp-read-only/results/2026-11-28/v3-run-1 (accessed 2026-11-28)

## Corrections

No corrections.

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](https://creativecommons.org/licenses/by/4.0/). Code in [our lab](https://github.com/nareyko/arviser-labs/tree/eff5333621201b67e2b4fed0f039e2902704b9bf/tested-threats/db-mcp-read-only): [MIT](https://opensource.org/license/mit). Quoted third-party material keeps its own terms.
