How to Configure Semantic Kernel SQL Server Data Masking

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up semantic kernel sql server data masking with restricted database roles and rules. These rules rewrite sensitive fields like emails or phone numbers in query results. Teams often connect AI agents to SQL Server using shared logins with broad rights. When an agent runs with broad rights, it can read every table and column. This exposes customer card numbers and national IDs to language models during tool calls. How semantic kernel sql server data masking works with native roles Seman

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 sql server data masking with restricted database roles and rules. These rules rewrite sensitive fields like emails or phone numbers in query results. Teams often connect AI agents to SQL Server using shared logins with broad rights. When an agent runs with broad rights, it can read every table and column. This exposes customer card numbers and national IDs to language models during tool calls.

How semantic kernel sql server data masking works with native roles

Semantic Kernel uses plugins to run SQL queries on behalf of an AI agent. The plugin logs in to SQL Server using a specific database user identity. In SQL Server, a database user maps to a server login for multi-database needs. Teams can also use a contained database user for one or a few databases. An admin must enable contained databases on the server and database first. SQL Server supports thirteen different types of database users for various login needs.

Once you create the user, you assign database roles to limit what it reads. Many teams place the agent user into the fixed reader role. Members of this reader role can read all data from all user tables. They can also read data from all views in that database. You cannot change the permissions assigned to fixed database roles in SQL Server. To block writes, teams avoid the fixed writer role and the owner role. The owner role can perform all maintenance tasks and even drop the database.

Why native roles fall short for AI agent queries

Native roles decide who logs in and which tables they can read. They do not inspect what individual queries do in flight during an agent session. If an agent has the fixed reader role, it reads every user table. Even if you add a deny role, it blocks whole tables or views. You must maintain manual rules on every single sensitive column across every schema.

AI agents generate dynamic queries based on user prompts and plugin descriptions. When a schema changes, someone must remember to update column rules right away. If a developer adds a new table with phone numbers, the reader role exposes it. Native database roles also lack a unified way to mask results across different database types. Teams need a way to rewrite emails and card numbers in query results by default.

Data Masking (Static) + Kubernetes API Server Access: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Planning user permissions for AI plugins

Start by creating a dedicated database user just for your Semantic Kernel app. Do not share human admin accounts or broad service logins with AI plugins. If the agent only needs one database, consider a contained database user with a password. Next, avoid granting the fixed reader role if the database holds private user records. Instead, grant select rights only on the specific views or tables the plugin needs. Pair those limited select rights with result masking that rewrites national IDs and phone numbers. This keeps raw sensitive values out of prompt history and model context windows.

Check SQL Server batches and results on the wire

SQL Server logins and roles decide who connects. They do not check what each TDS batch does or mask sensitive values in returned rows. With hoop.dev, you run an open-source proxy, a sidecar for your SQL Server. It reads plain batches and parameterized queries on the TDS wire while passing Windows login through untouched.

Before a batch hits the server, hoop.dev guardrails check the statement against your rules. Disallowed actions get a native TDS error with your message. On the way back, hoop.dev data masking rewrites sensitive values in supported result columns that match your rules. Every query and decision is logged. Explore the MIT-licensed project on GitHub.

Frequently asked questions

Can I use the fixed reader role for Semantic Kernel agents?

You can, but members of that role can read all user tables and views. It is safer to grant read rights only on specific tables the agent needs.

What fields should we mask in SQL Server results for AI plugins?

Focus on structured identifiers like emails, phone numbers, card numbers, and national IDs. Masking rewrites these matched fields in query results before the plugin reads them.

Should an AI agent use a server login or a contained user?

Use a contained database user when the agent only needs one or a few databases. Use a login in master when the user needs access to many databases.

The query runs. The emails stay hidden.