November 17, 2026 路 #62
The analytics agent with DROP rights
A support agent answers questions by writing SQL against production. It connects as the app's main database user. What is the safest fix?
Next puzzle in UTC
One try. The first answer sticks.
How to fix it
The database is the only reliable enforcement point. A read-only role on a replica cannot change data, whatever the model writes or an injected prompt asks for.
Generated SQL comes from user input and whatever the model read, so treat it like untrusted code. Prompt rules and keyword filters fail in practice: TRUNCATE, a CTE that updates, a function with side effects, or simply a cross join that scans billions of rows. Asking the model to explain itself does not change what runs.
Fix
CREATE ROLE support_agent LOGIN PASSWORD '...';
GRANT USAGE ON SCHEMA reporting TO support_agent;
GRANT SELECT ON ALL TABLES IN SCHEMA reporting TO support_agent;
ALTER ROLE support_agent SET default_transaction_read_only = on;
ALTER ROLE support_agent SET statement_timeout = '5s';
Point it at a read replica, expose views without personal data, and log every query the agent runs.