How to Configure OpenHands Snowflake Least Privilege

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up openhands snowflake least privilege by making a narrow database role. Then you give that role to the AI agent with read-only table permissions. Many engineering teams start by sharing a human admin role with their agent. This fast shortcut gives the bot power to change tables or read private rows. A bad prompt or agent loop can then drop tables or leak data. How openhands snowflake least privilege works in practice OpenHands runs as an autonomous coding agent inside its own workspa

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 least privilege by making a narrow database role. Then you give that role to the AI agent with read-only table permissions. Many engineering teams start by sharing a human admin role with their agent. This fast shortcut gives the bot power to change tables or read private rows. A bad prompt or agent loop can then drop tables or leak data.

How openhands snowflake least privilege works in practice

OpenHands runs as an autonomous coding agent inside its own workspace container. It writes scripts, runs shell tasks, and queries data warehouses to finish jobs. When the agent queries Snowflake, it logs in using a set of credentials. Your warehouse checks the assigned role on those credentials before running any query.

To build a safe setup, you create a dedicated user for the agent. Next, you create a custom role in Snowflake just for this bot user. Do not attach built-in admin or developer roles to the agent user. Instead, grant usage rights on one small warehouse and one specific database.

After that, grant select permissions only on the schemas and tables needed today. If the agent only builds reports, it never needs write or delete rights. You also set a tight query timeout on the dedicated warehouse for safety. This rule stops a bad agent query from burning credits for hours. Finally, you pass the scoped key pair into the OpenHands runtime workspace.

What native roles solve and what they miss

Native roles in Snowflake do a great job of blocking broad schema changes. A read-only role stops OpenHands from dropping tables or changing warehouse sizes. It also keeps the bot out of billing tables and other team databases. This step cuts down the blast radius of a broken agent script.

Still, database roles only check who logs in at the start of a session. They do not inspect what each query does while it runs in flight. If a table holds customer emails, a select grant returns every single email. The agent reads those raw emails, phone numbers, or card numbers into memory. That private data then goes straight into the external model context window.

Least Privilege Principle + Snowflake Access Control: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Static roles also stay active twenty-four hours a day without human checks. If an agent task goes wrong at night, nobody approves the risky query. Native column masking helps, but you must maintain rules across every single warehouse. Teams with Postgres, MySQL, and cloud warehouses end up managing split security rules. Static keys sitting inside the agent workspace can also leak through build logs.

Steps to harden agent database sessions

Start by auditing every table the agent can read with its current role. Remove select grants from any table that stores national IDs or card numbers. Give the agent synthetic test views whenever it writes new data pipelines. Only allow real production reads when the task truly needs live metrics.

Next, rotate the agent keys on a strict schedule to limit exposure risk. Set resource monitors on the agent warehouse so runaway loops stop right away. Check query history logs each week to see what SQL the bot generates. Look for full table scans or failed permission checks in those warehouse logs. These simple habits keep your data safe while the agent writes code.

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

Why should OpenHands use a separate database role?

A separate role keeps the AI agent from using human admin permissions. It limits the bot to specific tables and makes warehouse audit logs clear.

Can Snowflake roles stop an agent from reading sensitive columns?

Standard table grants allow reads on all columns inside an approved table by default. You must build separate views or masking rules to rewrite emails or card numbers.

How do you stop OpenHands from running expensive warehouse queries?

Assign the agent role to a small warehouse with a short query timeout. Add a daily credit limit so runaway agent loops shut down fast.

The query runs. The emails stay hidden.