How to Configure Semantic Kernel SQL Server Sandbox

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up a semantic kernel sql server sandbox by making a scoped database user. Then you bind that user to a read-only database role for your agent plugins. Many teams start by giving their AI app a shared admin login to test queries fast. That broad login lets an agent change tables or drop the whole database by mistake. How a semantic kernel sql server sandbox works with native roles SQL Server separates server logins from database users to control who gets in. A database user is the iden

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 semantic kernel sql server sandbox by making a scoped database user. Then you bind that user to a read-only database role for your agent plugins. Many teams start by giving their AI app a shared admin login to test queries fast. That broad login lets an agent change tables or drop the whole database by mistake.

How a semantic kernel sql server sandbox works with native roles

SQL Server separates server logins from database users to control who gets in. A database user is the identity a login uses inside one specific database. When someone needs to reach many databases on one server, teams make a login in master. For one or a few databases, you can make a contained database user with a password. This contained user stays inside that single database and does not need a login in master. A server admin must turn on contained databases on the server and database first. Microsoft supports thirteen types of database users for different sign-in needs.

Once you create the user for your Semantic Kernel plugin, you assign fixed database roles. You cannot change the built-in permissions that come with fixed database roles. Every role, including the default public role, lets the user connect to the database. Adding the agent user to the data reader role lets it read all user tables. This role also lets the plugin read all views inside that sandbox database. You can also add the deny data writer role to block any table changes. That role stops the user from adding, changing, or deleting rows in any table. You should never give an agent the database owner role in your setup. Members of the owner role can run all maintenance tasks and drop the database.

What native roles solve and what they leave open

Fixed database roles do a good job of sorting out who can log in. They also stop a read-only Semantic Kernel plugin from running write or delete queries. If the model writes an update query, the database engine blocks it right away. This setup protects your tables from bad writes during agent testing and daily runs.

Still, database roles only check who logs in and which broad actions they can take. They do not look at individual queries while those queries run in flight. A user in the data reader role can read every row in every user table by default. If a sandbox table holds real customer data, the agent can read all of it. Native roles cannot rewrite matched fields like emails, phone numbers, or card numbers in results. They also cannot pause a risky query to ask a human for approval first. Finally, static passwords stored in app settings can leak into logs or source control.

Kubernetes API Server Access + AI Sandbox Environments: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Scoping tables and views for agent plugins

Because the fixed data reader role opens every user table, teams often want tighter rules. You can skip the broad data reader role and grant read rights on single views. First, you build views that only include the safe columns your agent needs to see. Then you grant select permissions on just those views to your database user. If a table holds secret data, you can also use the deny data reader role. That role blocks the user from reading data or metadata from user tables and views. Combining custom views with deny rules keeps your AI plugins inside a smaller box.

Add runtime guardrails beside SQL Server

Role grants and network rules are needed setup for SQL Server. Still, an allowed user or agent tool can send a bad delete or read raw customer fields over a valid session. In practice, hoop.dev runs beside the database as a sidecar for your SQL Server and checks TDS traffic without changing how clients log in.

With hoop.dev SQL Server controls, rules refuse banned statements before they run and can hold risky queries for human review. Matched sensitive values in supported result columns are masked before they reach the client. Furthermore, hoop.dev holds SOC 2 Type II and generates evidence for HIPAA, PCI DSS, SOX, and GDPR audits. See the source on GitHub.

Frequently asked questions

Should I use a contained database user for a Semantic Kernel plugin?

Yes, a contained user works well when your agent only needs one sandbox database. It keeps the user and password inside that database without needing a login in master.

Can the fixed data reader role hide sensitive columns from my AI agent?

No, members of the fixed data reader role can read all user tables and views. To hide columns with native tools, skip that role and grant access to specific views.

What happens if I put the agent user in the database owner role?

The database owner role gives the agent full control over settings and maintenance tasks. A bad prompt or model error could change tables or drop the entire SQL Server database.

The query runs. The emails stay hidden.