How to Configure OpenHands SQL Server Permissions

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up openhands sql server permissions by making a dedicated database user. Then you place that user into a restricted database role. Engineering teams often give coding agents broad owner rights to get started fast. That choice lets an automated agent change or delete tables by mistake. A safer setup limits the agent to only the tables it needs. How openhands sql server permissions work SQL Server splits login accounts from database users to control who gets in. A database user is the i

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 openhands sql server permissions by making a dedicated database user. Then you place that user into a restricted database role. Engineering teams often give coding agents broad owner rights to get started fast. That choice lets an automated agent change or delete tables by mistake. A safer setup limits the agent to only the tables it needs.

How openhands sql server permissions work

SQL Server splits login accounts from database users to control who gets in. A database user is the identity of a login inside one database. SQL Server supports 13 types of database users for different needs. When an agent needs many databases, teams make a login in master. When OpenHands needs just one database, a contained database user works well. A contained user has a password and does not need a master login. An admin must first turn on contained databases on the server and database.

Once the user exists, you assign it to a fixed database role. Every database role, including the public role, includes the right to connect. You cannot change the rights built into these fixed database roles. If OpenHands only inspects schemas or runs reports, use the datareader role. Members of that role can read all data from user tables and views. If the agent must change rows, the datawriter role lets it edit tables. It can add, delete, or change data across all user tables.

How to lock down agent roles in practice

Start by deciding which databases the OpenHands workspace needs to reach. Create a dedicated user for the agent instead of sharing a team login. Shared logins make it hard to see which person or tool ran a query. Add the agent user to the datareader role for safe read tasks.

Never put an automated coding agent into the database owner role. Members of the owner role can run all setup and maintenance tasks. They can even drop the entire database in SQL Server. If you want to block writes for sure, use the deny datawriter role. That role stops the user from adding, changing, or deleting any table data. You can also use the deny datareader role to block all table reads. It even hides metadata about user tables and views from that user.

Kubernetes API Server Access + AI Agent Permissions: 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 SQL Server roles do a great job of checking who logs in. They set a hard boundary around which tables a user can read or write. This stops an agent with read rights from dropping a table by mistake.

Still, fixed roles apply to all user tables inside that database at once. A reader role lets OpenHands read every column in every user table by default. That includes sensitive fields like emails, phone numbers, card numbers, and national IDs. Native roles also do not check what each query does in flight. Once the agent logs in, the database runs every valid command right away. Teams cannot pause a risky delete command for human approval before it runs. They also have to rotate the static database password stored in the agent settings.

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 OpenHands use a master login or a contained database user?

Use a contained user if OpenHands only needs one or a few databases. Use a login in master if the agent needs many databases on the server.

Why is the database owner role unsafe for an AI coding agent?

The database owner role allows all maintenance tasks and can drop the whole database. A single bad prompt or bug could wipe out your production data.

Can I edit the rights inside a SQL Server fixed database role?

No, SQL Server does not let you change the rights of fixed roles. You can combine allow and deny roles or set up custom roles instead.

The query runs. The emails stay hidden.