Introducing The Sweep: OX’s New Live Security Research Series
Register Now
Breaking: The 2026 Vulnpocalypse Hits PHP: Four Critical RCEs, but How Dangerous Are They?
Read the Report
Are you exposed? Connect your apps in minutes.
Scan your apps free

pgleash

Latest version: v0.1.1

Overview

Last scanned
30 Nov 2026
Published
30 Nov 2026
MCP server Transport: stdio Publisher: mufasil
1 Stars
0 Forks
1 Versions
TypeScript Repo language

Scan summary

pgleash was last scanned on 30 Nov 2026 at version 0.1.1. Risk score 0 of 100. No malicious behavior was detected.

  • Releases: First and only release on 30 Nov 2026.
  • Findings: No rules fired in version 0.1.1.
  • MCP server: Runs over stdio.

Versions

1 version published
Versions and the rules that fired in each
VersionPublishedStatus
0.1.1 LATEST 30 Nov 2026 No rules fired

No rules fired in 0.1.1

Findings

Findings for v0.1.1. The score is a capped sum of the weights of the rules that fired — not CVSS, not exploitability, and not a probability. It is not comparable across packages with different scan coverage.

The score describes 0.1.1; other versions have their own rules, not their own score.

README

The publisher’s own README, as collected from the registry.

pgleash

CI

A Postgres proxy that keeps AI agents on a leash.

Point your coding agent at pgleash instead of at your database. pgleash parses every statement with Postgres's own parser and stops the dangerous ones before they reach the server. Reads go through. DROP, TRUNCATE, a DELETE with no WHERE, writes hidden inside a CTE or an EXPLAIN ANALYZE, and the stacked COMMIT; trick do not.

$ npx pgleash check "SELECT 1; COMMIT; DROP TABLE users"
blocked [multi-statement]: send one statement at a time (this query has 3)

Why

Giving an agent database access usually means one of two things: the real connection string, or an MCP server with a "read-only" switch inside it. Both have failed in public.

  • In July 2025 an AI agent on Replit deleted a production database during a code freeze.
  • Anthropic's reference Postgres MCP server wrapped each query in BEGIN TRANSACTION READ ONLY. Datadog Security Labs showed that a query could end that transaction itself and then run any SQL. The server has been archived, and the npm package still had about 21,000 weekly downloads when they wrote it up.
  • AWS's Postgres MCP server needed a fix for an incomplete list of blocked SQL (CVE-2025-59333).

pgleash enforces the rules on the wire, outside the agent. The agent connects with a pgleash token and never sees the real credentials.

Quick start

export PGLEASH_UPSTREAM='postgres://readonly_user:secret@db.internal:5432/app?sslmode=require'
npx pgleash
pgleash 0.1.0 (read-only, max 1000 rows, 10s statement timeout)
upstream:  db.internal:5432/app as readonly_user (sslmode=require)
listening: 127.0.0.1:6433

Give your agent this connection string (not the upstream one):
  postgres://agent:Yq3v...@127.0.0.1:6433/app

pgleash speaks the Postgres wire protocol, so psql, node-postgres, psycopg and ORMs connect to it like any other database. (The test suite uses node-postgres.) When a query is blocked, the agent gets a normal Postgres error with the reason and a hint:

app=> DELETE FROM orders;
ERROR:  pgleash blocked this query: DELETE is not allowed in read-only mode
HINT:  pgleash only lets this connection run the statements its mode allows. Ask a person to run this one.
As an MCP server

For Claude Code:

claude mcp add pgleash -e PGLEASH_UPSTREAM='postgres://...' -- npx -y pgleash mcp

For Cursor and other MCP clients:

{
  "mcpServers": {
    "pgleash": {
      "command": "npx",
      "args": ["-y", "pgleash", "mcp", "--deny-column", "email"],
      "env": { "PGLEASH_UPSTREAM": "postgres://..." }
    }
  }
}

MCP mode gives the agent three tools: query, list_tables and describe_table. Every call goes through the same proxy and the same rules.

What it does

Read-only by default. Only reads, EXPLAIN, SHOW, cursors and transaction control get through. The session is also pinned with default_transaction_read_only = on, and the agent can't undo that: SET, RESET ALL, DISCARD ALL, BEGIN READ WRITE and set_config() are blocked. So a write the parser can't see, such as one inside a user-defined function, still fails in the database.

Guarded writes when you want them. --mode guarded-write allows INSERT, plus UPDATE and DELETE with a WHERE clause that names a column. WHERE true and WHERE 1 = 1 don't count. DDL, TRUNCATE, COPY, DO, CALL, GRANT and MERGE stay blocked.

Off-limits tables and columns. --deny-table api_tokens blocks every reference to the table. --deny-column email blocks queries that name the column, pass a whole row to a function (row_to_json(u)), or SELECT * from a table that has it. pgleash looks those tables up in the live schema and refreshes the list every minute. As a second layer, any result column with a denied name comes back as NULL.

Dangerous functions blocked. These include pg_terminate_backend, pg_read_file, lo_import, dblink, pg_sleep, advisory locks, query_to_xml (which runs SQL passed in as a string), replication slot functions and setval. Add your own with --deny-function, and end a name with * to block a whole prefix.

Limits. Each result stops at 1,000 rows by default, and the agent gets a notice saying how many rows the query really returned. There is a 10 second statement timeout and a 60 second idle-in-transaction timeout.

Audit log. --audit pgleash.jsonl writes one line per query, allowed or blocked, with the rule that blocked it.

{"ts":"2026-11-29T10:02:11.412Z","session":3,"user":"agent","app":"psql","kind":"query","sql":"DROP TABLE users","allowed":false,"rule":"statement-type","reason":"DROP is not allowed in read-only mode"}

Configuration

Flags, environment variables or a pgleash.json in the working directory:

{
  "upstream": "postgres://readonly_user:secret@db.internal:5432/app?sslmode=verify-full&sslrootcert=/etc/ssl/rds-global-bundle.pem",
  "mode": "read-only",
  "maxRows": 500,
  "statementTimeout": "5s",
  "denyTables": ["api_tokens", "billing.cards"],
  "denyColumns": ["email", "phone", "password_hash"],
  "denyFunctions": ["app_purge_*"],
  "audit": "pgleash.jsonl"
}
Flag Default
--upstream <url> $PGLEASH_UPSTREAM, then $DATABASE_URL The real database. sslmode and sslrootcert work as in libpq.
--host, --port 127.0.0.1, 6433 Where pgleash listens.
--token <token> $PGLEASH_TOKEN, or random The password the agent uses.
--mode read-only Or guarded-write.
--max-rows <n> 1000 0 turns the cap off.
--statement-timeout <t> 10s
--deny-table, --deny-column, --deny-function Repeat for more than one.
--allow-setting <name> Lets the agent SET another setting.
--allow-multi-statement off Each statement is still checked.
--audit <file> JSON lines.

pgleash check runs the same policy without a database, so you can try rules or use it in CI and agent hooks. It exits 1 when a query is blocked, and --json prints the decision.

How it works

agent ──(token)──▶ pgleash ──(real credentials, TLS)──▶ Postgres
                     │
                     ├─ parse with libpg-query (Postgres's own parser)
                     ├─ check statement types, functions, tables, columns
                     └─ cap rows, null denied columns, write the audit log

pgleash speaks the Postgres wire protocol on both sides and checks the simple and the extended (prepared statement) protocol. A blocked statement isn't simply dropped. pgleash swaps it for a query that fails on the server, then replaces that error with its own. So the error comes back in the order the client expects, and an open transaction is aborted just as Postgres would abort it. Anything the parser can't parse is blocked.

Limits

pgleash is a guardrail, not a sandbox. Use it together with these:

  • A least-privilege role for the upstream. For read-only work, something like:

    CREATE ROLE agent_ro LOGIN PASSWORD '...';
    GRANT CONNECT ON DATABASE app TO agent_ro;
    GRANT USAGE ON SCHEMA public TO agent_ro;
    GRANT SELECT ON orders, products TO agent_ro;
    GRANT SELECT (id, name, created_at) ON users TO agent_ro; -- leaves out email and phone

    Grant column lists rather than revoking columns: a column REVOKE has no effect while the role holds SELECT on the whole table.

  • Keep the real connection string away from the agent. If it's in a .env file the agent can read, the agent can skip pgleash. On AWS, let only the pgleash host reach the database through its security group.

pgleash also has gaps you should know about:

  • Tables and columns are matched by name. A view over a denied table, or a view that renames a denied column, isn't caught. Deny the view too, or use column privileges.
  • In guarded-write mode, a user-defined function can write whatever its owner can. Block such functions with --deny-function.
  • The agent's side of the connection is plain TCP, meant for loopback. pgleash won't listen on another address without a token.
  • Not supported yet: COPY, fast-path function calls, replication connections, and TLS between the agent and pgleash.

Development

npm install
npm test        # starts an embedded Postgres; or set PGLEASH_TEST_URL to a superuser URL
npm run build

The tests run a real Postgres with TLS, connect through pgleash with node-postgres, and check each guardrail end to end. They also cover the CLI and MCP mode.

Security

If a query gets past the rules, please open an issue. For anything that exposes credentials or another session, see SECURITY.md for private reporting.

License

MIT

OX Radar and Response Center

Find threats in your stack.

OX Radar can check high-priority threats, like critical package CVEs, against your context.

Each incident is marked Detected or Not Detected with a remediation plan and proof all tracked in the Response Center.

Where it’s listed

The probe returned only these fields for this server — auth requirement, protocol and tool list weren’t observed, so they’re not shown (never guessed).

  • MCP Registry io.github.mufasil/pgleash

References

The publisher’s own links, as the registry reports them. These are not sources for the assessment on this page.

Powered by Read the latest findings

Scan your whole stack

Group 1261154050 1
Group 1261154050
 

From OX Research Newsroom

CVE

Java4Shell (CVE-2026-114938): Easy to Crash, Hard to Exploit — Less Than 0.12% of JVMs Estimated at Risk of RCE

Cry2Wolf: How to Tell a Real Bug from a Nothingburger
AI & VibeSec

Cry2Wolf: Not Every Branded Bug Deserves a Fire Drill

The 2026 Vulnpocalypse Hits PHP: Four Critical RCEs, but How Dangerous Are They?
Vulnerability Insights

The 2026 Vulnpocalypse Hits PHP: Four Critical RCEs, but How Dangerous Are They?

Frame 2085668439 (1)
Group 1261154229