
A "read-only" Postgres connection let 3 of 5 agent queries write. One dropped a table. Same 5 queries as a role with only pg_read_all_data: 0 of 5. CVE-2026-126196, published Nov 12: pgEdge's Postgres MCP server read_only mode was bypassed with ordinary transaction SQL when the role could write. Fixed in 1.1.0. pgEdge's own workaround: give the role no write privileges. 1) Create the agent role: CREATE ROLE agent_ro LOGIN PASSWORD 'change-me'; GRANT CONNECT ON DATABASE app TO agent_ro; GRANT pg_read_all_data TO agent_ro; Built in since PostgreSQL 14. SELECT on every table, view and sequence. No write rights. 2) Cap runaway queries: ALTER ROLE agent_ro SET statement_timeout = '5s'; pg_sleep(7) got cancelled at 5.0 s. The role can set it back to 0. Convenience, not a guard. 3) Give the agent a connection string for agent_ro. Never the app's own DATABASE_URL. 4) Prove it as agent_ro: BEGIN READ WRITE; DELETE FROM users; COMMIT; It must fail with: permission denied for table users pg_read_all_data reads every table. If a table holds secrets, GRANT SELECT on named tables instead. It does not bypass row-level security. What most people miss: BEGIN READ ONLY and default_transaction_read_only are session settings. The agent's own SQL can switch them off. A single "COMMIT;" ends the read-only transaction. Privileges are checked on every statement. Tested on PostgreSQL 17.11: table owner behind a READ ONLY wrapper, 3 of 5 writes landed, including DROP TABLE orders. Write grants plus default_transaction_read_only = on: 2 of 5. pg_read_all_data only: 0 of 5. Reads still worked. Read-only is a privilege, not a setting.
Post summary
The post details a proof-of-concept for CVE-2026-126196, showing how a read-only pgEdge Postgres MCP role could be bypassed with transaction SQL, and notes the fix in 1.1.0 and a workaround.
