How to Configure JetBrains AI SQL Server Least Privilege

Published
Length
3 min read

Luis Felipe Dias

All posts

To set up jetbrains ai sql server least privilege, create a dedicated database user. Then assign that user only the read permissions needed for AI prompts. Many teams start by linking their IDE to a database with a shared admin account. That broad role lets the AI assistant run risky commands on live tables. If a prompt creates a bad update statement, a broad role will run it right away. Scoping down database permissions is the first step to safe AI coding. How to set up jetbrains ai sql serve

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.

To set up jetbrains ai sql server least privilege, create a dedicated database user. Then assign that user only the read permissions needed for AI prompts. Many teams start by linking their IDE to a database with a shared admin account. That broad role lets the AI assistant run risky commands on live tables. If a prompt creates a bad update statement, a broad role will run it right away. Scoping down database permissions is the first step to safe AI coding.

How to set up jetbrains ai sql server least privilege

SQL Server splits login accounts from database users to control who can do what. A database user is the identity of a login inside one specific database. When someone needs to reach many databases on an instance, teams create a login in master. Then they map a SQL user to that login.

If the IDE only needs one or a few databases, you have another option. You can create a contained database user with its own password. This user is not tied to a login in the master database. An admin must first turn on contained databases on the server and the target database. SQL Server supports thirteen types of database users in total.

Once you create the user, you must assign a role with limited rights. SQL Server includes fixed database roles for common permission setups. You cannot change the permissions assigned to these fixed database roles. Every role, including the public role, includes basic connect rights.

Avoid the owner role for any IDE or AI workflow. Members of the owner role can do all setup and maintenance tasks. They can even drop the entire database in SQL Server. You should also avoid the data writer role for basic query generation. Members of the data writer role can add, delete, or change data in all user tables.

Instead, add the IDE database user to the data reader role. Members of the data reader role can read all data from all user tables and views. You can pair this with the deny data writer role for extra safety. Members of the deny data writer role cannot add, modify, or delete any table data. If you must block all reads in a database, use the deny data reader role. That role stops users from reading data or metadata from user tables and views.

Least Privilege Principle + Kubernetes API Server Access: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

What native roles solve and what they leave open

Native database roles solve the problem of who can log in and change tables. By using the data reader and deny data writer roles, you block destructive writes. The AI tool can read schema metadata and sample rows to help write SQL queries. At the same time, the database engine blocks any attempt to drop tables or delete rows.

Still, fixed roles still leave a large gap during live sessions. A role decides who logs in, not what individual statements do in flight. Remember that the data reader role grants read access to all user tables and views. It does not filter out specific columns that hold private customer records.

When a developer runs a select query in the IDE, the database returns raw rows. Those results often contain emails, phone numbers, card numbers, or national IDs. If those query results feed into an AI prompt, sensitive values leave your database boundary. Native SQL Server roles also do not require peer approval for broad table scans. To control each query and rewrite sensitive fields in results, you need runtime controls.

Govern SQL Server queries and responses in flight

Table grants decide which SQL Server objects a caller may touch. They do not check query intent or rewrite sensitive values in results across every client and agent. By design, hoop.dev is an open-source proxy that sits next to SQL Server as a sidecar for your SQL Server. It inspects TDS batches and parameterized queries in real time.

With hoop.dev guardrails and hoop.dev data masking, banned statements are refused with your message. Matched sensitive fields in supported result columns are masked in memory, and each decision is logged per listener. Check out the code on GitHub.

Frequently asked questions

What is the difference between a SQL login and a contained database user?

A standard SQL user maps to a server login stored in the master database. This works well when a user needs access to many databases on one server. A contained database user has its own password inside one specific database. An admin must enable contained databases on the server and database first.

Does the data reader role hide sensitive columns from JetBrains AI?

No, the fixed data reader role allows reading all data from all user tables and views. You cannot change the permissions assigned to fixed database roles in SQL Server. To rewrite fields like emails or card numbers in results, you need column-level masking.

How do you block a SQL Server user from changing table data?

First, remove the user from the owner and data writer roles. Next, add the user as a member of the deny data writer role. Members of that role cannot add, modify, or delete data in any user table.

The query runs. The emails stay hidden.