# We gave an AI agent a readonly Postgres login. It wasn’t as readonly as we thought — retained record

> Retained reddit record from reddit:AI_Agents.

Canonical: https://highsignal.app/data/records/adcbc109e0d33bfc

[← sources](https://highsignal.app/data)


source: [reddit](https://highsignal.app/data/reddit) (reddit:AI_Agents)  published 2026-09-30 23:02 ingested 2026-10-01 02:37

[original source ↗](https://www.reddit.com/r/AI_Agents/comments/1wujjkx/we_gave_an_ai_agent_a_readonly_postgres_login_it/)

## retained text



```
A while ago we had a Postgres login that was provisioned as read only for an AI agent we were working with.

At some point the agent tried to do something destructive with it. I honestly don’t remember the exact query anymore, this was a while back, but it made us actually inspect the login to see what it could do.

That was when I went down the rabbit hole of Postgres role inheritance. Just because you didn’t directly give a login UPDATE/DELETE etc doesn’t necessarily mean it can’t do those things. It can inherit privileges from other roles, own tables, have access through other grants etc.

We ended up putting together a small check internally to basically show us know what a given postgres login can actually do 

I recently went back to that idea and built a small open source version of it called agent-db-scan.

You give it a Postgres connection string and it checks the effective privileges, inherited roles, tables it owns, whether it can write/delete/truncate, RLS, statement timeout, sensitive columns it can read, things like that.

Nothing too fancy, I just thought it might be useful for anyone giving Postgres credentials to agents or even just wanting to sanity check a supposedly restricted DB user before using it somewhere.

It’s open source, so feel free to use it or improve it


```



document fetched 2026-10-01 00:19 · canonical https://reddit.com/r/AI_Agents/comments/1wujjkx/we_gave_an_ai_agent_a_readonly_postgres_login_it
