How to Configure Codex ClickHouse Sandbox

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up a codex clickhouse sandbox by creating a restricted database user. Then you limit that user to specific tables, columns, and allowed hosts. Many teams start by giving an AI coding tool a shared admin account. That shortcut lets the AI agent read sensitive tables or drop production data. A dedicated sandbox user keeps automated query generation inside safe, predictable bounds. You still need a clear plan to manage permissions as schemas grow. How to build a native codex clickhouse sa

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 a codex clickhouse sandbox by creating a restricted database user. Then you limit that user to specific tables, columns, and allowed hosts. Many teams start by giving an AI coding tool a shared admin account. That shortcut lets the AI agent read sensitive tables or drop production data. A dedicated sandbox user keeps automated query generation inside safe, predictable bounds. You still need a clear plan to manage permissions as schemas grow.

How to build a native codex clickhouse sandbox

ClickHouse manages users, roles, row policies, settings profiles, and quotas as SQL access entities. To enable SQL access control, you first set a storage directory on the server. You also need at least one admin account with user management permissions turned on. Once enabled, an admin can create a dedicated user for the AI coding tool. A user in ClickHouse can only grant privileges that they already hold themselves.

When you create the sandbox user, you define how that account logs in. You can also restrict which network hosts the user is allowed to reach from. Next, you assign a default role that holds only read permissions on safe tables. ClickHouse lets you grant read access down to specific columns on a table. If you grant access to two columns, the user can query only those two. A query asking for all columns with a star will fail right away. The database returns no data unless the table contains only those granted columns. You can also grant permissions across multiple tables that share a common name prefix.

What native database roles solve and what they miss

Native ClickHouse roles and column grants stop an AI agent from modifying tables. They also block the agent from reading restricted columns that you leave out. Host limits make sure the sandbox account only logs in from approved developer machines. Quota entities and settings profiles help you cap how much memory a query uses. These built-in tools give you a strong baseline for basic database isolation.

Still, static database roles only check who logs in at the start. They do not inspect what individual queries do while they run in flight. If an allowed column holds emails or card numbers, the AI reads them. Column grants also break when an AI agent runs broad schema discovery queries. Any query that selects all columns fails if one column is off limits. Teams often loosen permissions just to stop the AI tool from throwing errors. Soon the sandbox role has full table access across the whole database again. Also, local developer tools need a static password stored on the machine. Rotating that password across every engineer laptop and agent runner takes constant manual work.

ClickHouse Access Management + AI Sandbox Environments: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Managing schema changes and sensitive fields

Analytics tables change often as product teams ship new features and event types. Keeping column-level grants updated by hand for every new table takes significant time. If someone adds a phone number column, the sandbox role might read it. You need a way to rewrite matched fields like emails or national IDs. Masking those fields in query results lets queries run without exposing raw values. It also helps when every single query from an AI agent has a log. Clear logs show which developer triggered the agent and what query ran.

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, inline in ClickHouse's native TCP protocol. On every query an AI agent or engineer runs against production, hoop.dev decides to pass, mask, block, or hold it for human review.

Multi-statement queries and table mutations are split and checked by hoop.dev guardrails, which refuse banned actions with a native ClickHouse error or hold risky ones for approval. On returned rows, hoop.dev data masking rewrites String and FixedString columns in memory, and the audit trail logs each query and verdict. See the MIT-licensed source on GitHub.

Frequently asked questions

Why do select-star queries fail in a ClickHouse column sandbox?

ClickHouse blocks select-star queries when a user only has access to specific columns. The query only works if the user has grants for every column present by default.

How do I let an admin create sandbox users with SQL?

You must configure the server access control storage directory and enable access management. Only a user with the create user privilege can add new accounts.

Can a ClickHouse sandbox user grant permissions to another agent?

No, a user can only grant privileges that they already hold themselves. Do not give the sandbox account user management rights or admin privileges.

The query runs. The emails stay hidden.