How to Configure OpenHands ClickHouse Permissions
You set up openhands clickhouse permissions by making a dedicated database user and role. Then you grant read rules only on the exact tables and columns the agent needs. Many teams give AI coding agents broad admin keys just to get things working fast. That shortcut creates a major risk for your production data. A single bad prompt or agent loop can drop tables or read private user records. Scoping down what the agent can do at the database level stops most accidents early. How openhands click
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 clickhouse permissions by making a dedicated database user and role. Then you grant read rules only on the exact tables and columns the agent needs. Many teams give AI coding agents broad admin keys just to get things working fast. That shortcut creates a major risk for your production data. A single bad prompt or agent loop can drop tables or read private user records. Scoping down what the agent can do at the database level stops most accidents early.
How openhands clickhouse permissions work in practice
ClickHouse treats users, roles, row policies, settings profiles, and quotas as access items. You can manage all of these items with standard SQL commands. Before you start, your server needs a storage folder for these access rules. At least one admin account must also have permission to manage access and named collections. Keep in mind that a user can only grant rights that they already hold themselves.
Once SQL access control is on, you create a dedicated account for OpenHands. Creating this account takes the right user creation privilege. During setup, you pick how the agent logs in and which hosts it can use. You can also assign default roles and custom settings profiles to that new agent user. Teams usually put all table grants inside a role and attach it to the agent. This keeps your setup clean when you run more than one agent container.
To keep data safe, you should grant read rights on specific columns only. When you limit a user to a few columns, queries on other columns will fail. A full wildcard query on that table will also fail and return no data. It only works if the user has rights to every single column in the table. In newer database builds, you can also grant rights across tables that share a prefix.
What native database roles solve and what they miss
Native database roles and column grants are great for blocking unauthorized table reads. They make sure an OpenHands container can only log in from an allowed host IP. They also let you attach quotas and settings profiles to cap heavy agent queries. If an agent tries to change a locked table, the database blocks it right away.
ClickHouse Access Management + AI Agent Permissions: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Still, static roles only check who logs in and which objects they touch. They cannot inspect the actual queries or data flowing back to the agent in flight. If an allowed column holds emails, phone numbers, or card numbers, the agent gets them. Those raw values then get sent straight to the external model provider in the prompt. Static database rules also require you to put a long-lived password inside the agent container. Finally, native roles do not pause a valid but risky command for human review.
Managing credentials and data risks for AI agents
Running an autonomous coding agent means giving software direct reach into your backend systems. When you hand a static database key to an agent, that key lives on disk. If the agent workspace leaks, an attacker gets the exact same reach as the agent. Even with tight column rules, valid tables often mix safe metrics with private text fields. Teams need a way to rewrite sensitive fields like national IDs in query results. They also need a clear audit trail that links every query back to a task.
Check ClickHouse queries and result columns on the wire
ClickHouse users and row policies decide who connects. They do not check each statement on the wire or redact sensitive string columns in query results. With hoop.dev, you run an open-source proxy, a sidecar for your ClickHouse. It reads ClickHouse's native TCP protocol before queries run while ClickHouse stays in charge of login and grants.
Multi-statement queries and table mutations are split and checked by hoop.dev guardrails. Banned actions are refused with a native ClickHouse error. On returned rows, hoop.dev data masking rewrites String and FixedString columns that match your rules. The audit trail logs each query, table, and verdict. See the MIT-licensed source on GitHub.
Frequently asked questions
Why did my agent wildcard query fail after setting column permissions?
ClickHouse blocks wildcard select queries when a user only has rights to specific columns. The query will return no data unless the user has grants for every column. Update the agent instructions so it asks for the allowed column names directly.
Can OpenHands create its own database roles if needed?
A database user can only grant privileges that they already hold themselves. It also needs the specific privilege to create users or roles. You should never give these management rights to an automated coding agent.
How do I stop an agent from connecting from an unknown server?
When you create the database user, you can lock down the allowed client hosts. This rule checks the network address of the OpenHands container before letting it log in. Connections from any other IP address or hostname will get rejected right away.
Related guides
In this post