How to Configure OpenHands CockroachDB Permissions
You set up openhands cockroachdb permissions by creating a custom database role with strict table grants. Then you give that role to the AI agent workspace so it can run queries. Teams often start by giving the agent a default admin account to save time. This broad setup creates big risks during automated coding tasks. If the agent makes a mistake, it can drop tables or alter live user rows. A good setup limits what the agent can read and write from the start. How to set up openhands cockroac
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 cockroachdb permissions by creating a custom database role with strict table grants. Then you give that role to the AI agent workspace so it can run queries.
Teams often start by giving the agent a default admin account to save time. This broad setup creates big risks during automated coding tasks. If the agent makes a mistake, it can drop tables or alter live user rows. A good setup limits what the agent can read and write from the start.
How to set up openhands cockroachdb permissions
First, you need to plan what the agent must do in your database. Most coding agents only need to read schema details and test data in a staging space. You start by logging into your database cluster as an admin. Next, you create a dedicated role just for the OpenHands agent.
Do not reuse a role that belongs to a human developer or another app. Once the role exists, you grant privileges on specific databases, schemas, or tables. For safe code exploration, you only grant read privileges on non-sensitive tables. If the agent needs to test migrations, you grant write privileges on a scratch schema.
You also block the role from changing cluster settings or creating new database users. After you set the grants, you create a login credential for that role. You pass these login details into the agent runtime workspace as environment variables. The agent then uses this limited role whenever it opens a database session.
What native database roles solve and what they miss
Native database roles are great for basic access control at login time. They confirm who the user is and which tables that user can touch. If the agent tries to read a forbidden table, the database blocks the query. This stops the agent from touching entire databases outside its assigned scope.
Still, static grants cannot inspect what a query does while it runs in flight. Once a role has read access to a table, it can pull every row by default. It can also read every column, including emails, phone numbers, card numbers, and national IDs. Data masking can help here because it rewrites matched fields in results before returning them.
AI Agent Permissions + End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Write grants have a similar gap during live sessions. If a role can update one row in a table, it can update all rows by default. A bad loop or a missing filter in an agent script can wipe out test data. Also, native database logs only show the shared agent role name. They do not link each query back to the human who started the agent task.
Scoping agent tasks for safer database work
To reduce risk, teams break agent database work into smaller, safer steps. You can create separate database roles for read tasks and schema change tasks. When a developer asks the agent to debug a query, they load the read-only role. This keeps the database safe even if the agent writes a bad command.
When the agent needs to alter a table, it writes the migration script first. A human engineer checks the script before anyone runs it against the cluster. You should also set query timeouts on the agent database role. Timeouts stop slow queries from locking up CPU and memory across your cluster nodes.
Check database and API queries on the wire
Identity tools, roles, and network rules decide who opens a session. Setup alone cannot check what each query does or mask sensitive values in a response once a session starts. When workflows touch Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, or internal HTTP APIs, hoop.dev runs beside those services as an open-source proxy, a sidecar for your Postgres or API. It inspects requests coming in and results going back on the wire.
Your login details and client tools stay as they are while hoop.dev guardrails refuse bad deletes or drops before they run. On responses, hoop.dev data masking rewrites matched sensitive values in memory. Furthermore, hoop.dev holds SOC 2 Type II, is MIT licensed, and writes every query and decision to an audit trail that generates evidence for HIPAA, GDPR, and PCI DSS. See the source on GitHub.
Frequently asked questions
Should OpenHands use an admin role in development databases?
No, an admin role lets the agent change cluster settings and delete shared schemas. Always create a dedicated role with grants limited to one test schema.
How do I stop the agent from reading sensitive user columns?
Native table grants apply to the whole table, though views can hide specific columns. You can also use masking rules that rewrite emails and phone numbers in query results.
Can I limit how many rows an OpenHands session pulls at once?
Standard database roles do not cap row counts on a single select query. You must use views with limits or enforce statement rules at the session level.
Related guides
In this post