How to Configure OpenHands Snowflake Permissions

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up openhands snowflake permissions by creating a custom database role with read rights. You then assign that role to a dedicated service user for the coding agent. Many teams start by giving the agent a broad developer role to move fast. Broad roles let an autonomous agent drop tables or read private customer records by mistake. How openhands snowflake permissions work in practice OpenHands runs as an autonomous coding agent inside a local or cloud container. It writes scripts, runs s

Your coding agents run with your access.

Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.

You set up openhands snowflake permissions by creating a custom database role with read rights. You then assign that role to a dedicated service user for the coding agent. Many teams start by giving the agent a broad developer role to move fast. Broad roles let an autonomous agent drop tables or read private customer records by mistake.

How openhands snowflake permissions work in practice

OpenHands runs as an autonomous coding agent inside a local or cloud container. It writes scripts, runs shell commands, and queries databases to finish tasks for your team. When the agent needs warehouse data, it reads login keys from its local workspace. Those keys link the agent session to a specific user and role inside Snowflake.

Snowflake uses role-based permissions to control what that session can read or change. You create a custom role and grant it usage rights on one warehouse. Next, you grant usage on the specific database and schema the agent needs. Finally, you grant select rights on the tables or views required for the task.

If the agent must build new tables, you give it write rights on a sandbox schema. You keep production schemas read-only so the agent cannot alter live business data. You also set up key-pair login or a short-lived token for the service user. This stops static passwords from sitting in plain text inside the agent workspace.

What native roles solve and what they miss

Native roles are great at drawing hard borders around schemas, tables, and compute warehouses. They stop an agent from touching databases that belong to other teams in your company. Resource monitors on the warehouse also cap how much compute credit the agent can burn. This baseline setup handles basic login checks and broad table rules well.

Still, table grants only check who logs in at the start of a session. They do not inspect what individual queries do while the agent runs. If a table holds emails, phone numbers, or card numbers, select rights return them all. The agent pulls those raw fields into its prompt history and container logs.

Snowflake Access Control + AI Agent Permissions: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Write grants on a staging schema also allow destructive queries inside that space. A confused agent loop can truncate a shared staging table or run a massive join. Static keys inside the agent container present another risk for engineering teams. Because the agent runs arbitrary shell code, a bad prompt can read and leak local keys.

How to tighten agent sessions and query rules

To close these gaps, teams separate login secrets from the container where the agent runs. The agent should never hold raw database keys in its local file system or memory. Instead, requests should pass through a check that validates every single query in flight. This lets you block drop or truncate statements even inside a writable sandbox schema.

You can also apply dynamic data masking to sensitive columns before results reach the agent. Masking rewrites matched fields like emails, phone numbers, and national IDs in query results. The agent gets the schema shape it needs to write code without pulling raw PII. You also gain a full log of every query tied to the user who started the agent.

Govern statements and responses across databases and APIs

Good config and scoped roles are needed setup. They do not check single queries in flight or mask sensitive fields in returned rows. Across Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, and internal HTTP endpoints, hoop.dev runs beside each supported service as an open-source proxy, a sidecar for your database or API.

First, hoop.dev guardrails block banned queries before they run. Then hoop.dev data masking rewrites matched sensitive values in responses in memory. The audit trail records every statement and verdict per resource. Furthermore, hoop.dev holds SOC 2 Type II and is open source on GitHub.

Frequently asked questions

Should OpenHands use a human engineer role for Snowflake tasks?

No, you should always create a separate service user and custom role for the agent. Sharing a human role makes it hard to audit which queries the agent ran by itself. Dedicated roles also let you restrict the agent to a smaller compute warehouse.

How do I stop the agent from running expensive warehouse queries?

Assign the agent role to a dedicated small warehouse with an aggressive statement timeout value. Attach a resource monitor to that warehouse so it suspends compute if credit usage spikes. This keeps a bad query loop from driving up your monthly cloud bill.

How can the agent test schema changes safely?

Give the agent role write permissions only on an isolated dev or scratch schema. You can clone production table structures without copying sensitive rows into that scratch space. Require a human engineer to review and approve any migration script before it runs in production.

The query runs. The emails stay hidden.