How to Configure OpenHands ClickHouse Data Masking
You set up openhands clickhouse data masking by limiting columns or rewriting query results. This approach stops AI coding agents from pulling raw emails or phone numbers. Teams often start by giving an AI agent a broad database account. That account can read every table and column in the cluster. When the agent runs a test query, sensitive fields flow into the prompt context. A wide role puts card numbers and national IDs at risk during routine tasks. How native openhands clickhouse data mas
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 data masking by limiting columns or rewriting query results. This approach stops AI coding agents from pulling raw emails or phone numbers.
Teams often start by giving an AI agent a broad database account. That account can read every table and column in the cluster. When the agent runs a test query, sensitive fields flow into the prompt context. A wide role puts card numbers and national IDs at risk during routine tasks.
How native openhands clickhouse data masking works
ClickHouse handles users, roles, row rules, settings profiles, and quotas as SQL access items. To turn on SQL access control, admins set up a storage folder on the server. At least one admin account needs the right to manage access and named collections. An admin can only give out rights that their own account already holds.
With SQL access control active, an admin creates a dedicated user for OpenHands. Creating a user requires the specific privilege to make new users in the database. That creation step sets how the user logs in and which hosts can connect. It also assigns default roles and user settings right away.
Next, the team locks down what the agent can read at the column level. Admins can grant read rights on safe columns while skipping columns with card numbers. The agent can then run queries that ask for those safe columns by name. If a query asks for a restricted column, the database blocks the request.
A query that selects all columns with a star also fails and returns nothing. It only works if the table holds just the allowed columns. Since version 24.10, a trailing star lets admins grant rights by table name prefix. Teams also build custom SQL views that replace emails with masked text strings. They then grant the agent read rights on the view instead of the base table.
Data Masking (Static) + ClickHouse Access Management: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Where native column grants and views fall short
Native database roles and column grants work well to control who logs in. They block an agent from reading restricted tables or banned columns from the start. Still, static grants create friction when an AI agent explores a schema to debug code.
Agents often run broad queries to inspect table shapes during a task. When a select-all query fails on a restricted column, the agent hits a wall. The team must then rewrite the agent prompt or build new views by hand. Every schema change means an admin must update views across every table prefix.
Static roles also do not inspect what individual statements do in flight. Once a role has read access to a column, every row comes back raw by default. Native grants decide who enters the database, not how results get scrubbed at runtime. Plus, storing database keys inside the agent runtime leaves credentials exposed in local files.
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
Can ClickHouse restrict an OpenHands user to specific columns?
Yes, admins can grant read rights on specific columns to the agent user. The user can query those named columns, while restricted columns stay blocked.
Why do select-all queries from OpenHands fail with column grants?
ClickHouse refuses a select-all query unless the user has rights on every table column. The query returns no data at all when restricted columns exist in that table.
What kinds of sensitive fields can query masking rewrite?
Masking rules rewrite matched fields like emails, phone numbers, card numbers, and national IDs. The query still runs, and the agent receives scrubbed values in the result set.
Related guides
In this post