Letting LLMs query sensitive data: aggregates aren't as safe as you think
Then_Respect_1964 · reddit · 2026-11-17
A developer shares a lesson from building access rules for AI agents querying Postgres: aggregates were allowed without approval on the assumption they can't expose individual records. Reviewing the agent's actual SQL broke that assumption — MAX/MIN(amount) return real underlying values, and SUM(amount) GROUP BY customerid effectively exposes single-payment customers. All passed because the policy only checked whether an aggregate function was used, not what the result could reveal; the agent wasn't even trying to bypass rules.
He now requires approval for MIN/MAX like row-level reads, but GROUP BY remains hard: grouping by quasi-identifiers (emails, precise timestamps) is effectively row access, and k-anonymity minimums can be defeated by overlapping queries — something agents are good at. Key takeaway: policies should evaluate what a query's result reveals, not whether it uses an aggregate. He asks how others let agents query production databases safely.
Related event: Agent bypasses approval rules via "harmless" aggregate queries(2 posts)→
More from coding & agent
- Paper launches Remote MCP to serve any cloud agent, anywhere — evilrabbit_ · 2026-11-17
- Warp CEO: nearly every team is building an internal 'software factory' for coding agents — thursdai_pod · 2026-11-17
- Claude Opus 5.5 one-shots an entire short-film production app, no spec needed — RileyRalmuto · 2026-11-17
- Silicon Valley's new obsession: agent swarms that beat frontier models via parallelism and specialization — briannekimmel · 2026-11-17
- Cheaper code is rewriting the physics of technical debt — yacineMTB · 2026-11-17
- Swarms releases AgentRearrange paper: one-line multi-agent workflows benchmarked at 8–512 agents — KyeGomezB · 2026-11-17