How to Configure Devin SQL Server Least Privilege

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up devin sql server least privilege by creating a restricted database user. Then you assign that user to a read-only role or specific table permissions. Many teams start by giving their AI software agent broad database owner rights. This shortcut speeds up early testing for the team. Still, broad permissions let an autonomous agent change data or drop tables by mistake. A strict setup limits what the agent can read and change during a task. How to set up devin sql server least privileg

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 devin sql server least privilege by creating a restricted database user. Then you assign that user to a read-only role or specific table permissions. Many teams start by giving their AI software agent broad database owner rights. This shortcut speeds up early testing for the team. Still, broad permissions let an autonomous agent change data or drop tables by mistake. A strict setup limits what the agent can read and change during a task.

How to set up devin sql server least privilege natively

A strong setup starts with how the agent logs in to the database. In SQL Server, a database user is the identity of a login. When an agent needs many databases, teams create a login in the master database. When the agent needs one database, a contained database user is a good option. A contained user has a password and does not tie to a master login. An admin must enable contained databases on the server and database first.

After you create the user, you must assign its permissions. SQL Server offers thirteen types of database users and several fixed database roles. The permissions attached to fixed database roles cannot be changed by admins. Every role, including the public role, holds the basic permission to connect. You add a user to a fixed role through an alter role statement. Note that Azure Synapse uses a different system stored procedure to add role members.

Never put an autonomous coding agent in the database owner role. Members of that owner role can run all maintenance tasks and drop the database. Instead, start with the fixed data reader role for safe agent checks. This role lets the agent read all data from all user tables and views. If the agent must block writes, you can add the deny data writer role. That role makes sure the user cannot add, change, or delete any table data.

Why native roles alone leave a runtime gap

Native roles control who can log in and which tables they can read. They do not inspect what individual queries do while a session is active. For example, the fixed data reader role grants read rights to every user table. You cannot change the built-in rules of that fixed role. If a table holds sensitive customer data, the agent can still read it.

You can also add the deny data reader role to block all table reads. Yet that blocks the agent from reading anything at all in the database. Admins can build custom roles for specific tables, which takes extra setup work. Even on an allowed table, a read role returns every column in the result by default. The agent will receive raw emails, phone numbers, card numbers, and national IDs. Masking rewrites matched fields in results so raw values do not reach the workspace.

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

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Evaluating write roles and query control

Sometimes an AI coding agent needs to fix data or test a schema change. Teams might grant the fixed data writer role to let the agent work. Members of this writer role can add, delete, or change data in all tables. A single bad query from the agent could wipe out a full table. Native roles cannot tell a safe single-row update from a full table delete.

Static database credentials also create a real risk for engineering teams. If you store a password in the agent workspace, that secret stays active. The agent can run queries at any hour without a human checking the statement. True safety requires checking each SQL statement before the database runs it. Teams need a way to approve risky writes and mask sensitive columns in flight.

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 login or a contained user for an AI agent?

Use a contained database user if the agent only needs one or two databases. This keeps the user inside the target database instead of the master database. Remember that an admin must turn on contained databases on the server first.

What is the danger of giving an AI agent the db_owner role?

Members of the database owner role can run all setup and maintenance actions. They can even drop the entire database in SQL Server. An AI agent with this role could destroy data if a prompt goes wrong.

Does the db_datareader role hide sensitive columns from the agent?

No, the fixed data reader role lets the user read all user tables. Its built-in permissions cannot be changed to hide specific columns like card numbers. You need column permissions or result masking to rewrite emails and phone numbers.

The query runs. The emails stay hidden.