How to Configure Semantic Kernel ClickHouse Least Privilege

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up semantic kernel clickhouse least privilege by making a scoped SQL role. Next, you bind that role to the database user for your AI agent. Teams often start by giving agents a default admin account to test fast. That broad setup lets an agent read private tables or drop production data. Limiting the database user right away stops bad prompts from ruining your tables. How semantic kernel clickhouse least privilege works in SQL ClickHouse manages users, roles, row policies, settings pr

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 semantic kernel clickhouse least privilege by making a scoped SQL role. Next, you bind that role to the database user for your AI agent. Teams often start by giving agents a default admin account to test fast. That broad setup lets an agent read private tables or drop production data. Limiting the database user right away stops bad prompts from ruining your tables.

How semantic kernel clickhouse least privilege works in SQL

ClickHouse manages users, roles, row policies, settings profiles, and quotas as access items. You create and change these items with SQL statements. First, you must turn on SQL-driven access control in your server setup. This step needs a storage folder and one user with access management turned on. Once active, an admin can create a new user account for the agent. Note that a user can only grant the privileges that they have themselves.

Creating a user requires the right to create users on the server. During this step, you set how the agent logs in. You also pick the exact network hosts the agent can connect from. You then assign default roles and specific user settings to that account. For Semantic Kernel, you should build a role that only allows read queries.

You can grant read rights on specific columns rather than whole tables. When you do this, the agent can only query those exact columns. If the agent tries to read another column, the database blocks the query. A wildcard query that selects all columns also fails and returns no data. It only works if the table holds just the allowed columns. Since version 24.10, a trailing asterisk grants rights by table name prefix. This helps when your agent needs to read a group of related tables.

Where native database roles fall short for AI agents

Native roles and column grants solve the first part of agent security. They decide who can log in and which columns they can read. They also block write tasks and limit which hosts can open a session. This stops an agent from changing data or reading banned tables.

Least Privilege Principle + ClickHouse Access Management: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Still, static database grants do not check what queries do in flight. An agent with column read rights can still pull millions of rows at once. If an allowed text column holds emails or phone numbers, the query returns them. Static grants cannot rewrite matched fields in results to hide card numbers. Also, every Semantic Kernel plugin using that account shares the same database identity. When a bad query runs, the database log only shows the shared service account. You cannot see which user prompt or agent task ran the query.

Managing agent credentials and query policies

To keep credentials safe, teams must avoid putting passwords in agent code. Semantic Kernel plugins need a secure way to run queries without storing secrets. Teams also need a way to inspect every query before the database runs it. Checking queries in flight lets you block risky patterns that static roles allow. Adding field masking also rewrites emails and national IDs in query results.

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 do wildcard queries fail when using ClickHouse column grants?

ClickHouse blocks wildcard queries when a user only has rights on certain columns. The query returns no data unless the table holds only those granted columns. You must tell your Semantic Kernel prompt to name each allowed column.

How do you turn on SQL-driven access control in ClickHouse?

You must set a storage folder for access items in the server setup. You also need at least one user with access management turned on. After that, you can create users, roles, and quotas with SQL.

Can a ClickHouse role hide phone numbers inside an allowed text column?

No, standard column grants only allow or block access to the whole column. If a user can read a column, they get all text inside it. Rewriting phone numbers or card numbers in results requires masking during the query.

The query runs. The emails stay hidden.