A stakeholder asks why your Claude-powered analytics agent can't also update records or fix data issues directly in the warehouse while it's at it. What's the safe default here?
Click or press Enter to reveal the answerThe safe default is read-only, full stop — the database role or warehouse credential the agent's queries execute under should have no write, DDL, or DML permissions at all, so even a bad, hallucinated, or prompt-injected query physically cannot modify or delete production data. Any write capability should be a completely separate, explicitly reviewed pathway, not something bolted onto a general Q&A agent.
Why “just don’t let it write anything harmful” isn’t a real control
Telling an agent, via prompt instructions, “only run SELECT queries” is not a security boundary — it’s a request the model might not follow, especially under an unusual phrasing, a bug in the prompt, or a prompt-injection attempt embedded in data the agent reads. The actual control has to live below the model, at the database or warehouse layer, where it can’t be talked around.
What the safe default looks like in practice
Grant the credential the agent’s queries run under a role that is, at the infrastructure level, incapable of writing:
-- Illustrative — exact syntax varies by warehouse
CREATE ROLE analytics_agent_readonly;
GRANT SELECT ON SCHEMA analytics_views TO analytics_agent_readonly;
-- No GRANT INSERT / UPDATE / DELETE / CREATE / DROP, ever, for this role.
If that role literally does not have INSERT, UPDATE, DELETE, CREATE, or DROP privileges, then no generated SQL — no matter how the model was tricked or confused into producing it — can modify anything. This is the same principle as the read-only-role guidance in the MCP server design and auth cards: least privilege isn’t a nice-to-have, it’s the thing that limits the blast radius when (not if) something goes wrong upstream of the database.
Allow-listing on top of read-only
Read-only is necessary but often not sufficient on its own — you generally also want to constrain what can be read, via allow-listed views or schemas rather than every table in the warehouse (see the companion card on exposing parameterized tools instead of raw SQL). A read-only role that can still SELECT * from every table, including ones with sensitive columns nobody meant to expose through a chat interface, is safer than a writable one but still broader than it needs to be.
Why write capability deserves its own separate, reviewed pathway
If there’s a genuine business need for an AI-assisted workflow to fix data (e.g., correcting a known bad record), that’s a fundamentally different risk profile than answering questions, and it deserves its own explicit design: a narrow, purpose-built tool (not a general SQL-writing capability), almost certainly gated behind human approval for every execution (see the companion card on human-in-the-loop approval), and probably its own audit trail separate from the read-only Q&A path. Bolting “oh, and it can also write sometimes” onto a general-purpose analytics agent conflates two very different risk levels into one system, which makes both harder to reason about and secure.