How to Configure OpenHands SQL Server Guardrails

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up openhands sql server guardrails by creating a restricted database user. Then you assign fixed roles to limit what the agent can run. Many engineering teams start by giving their coding agent a standard developer account. That broad role often lets the agent change rows or drop tables by mistake. A safer setup scopes the database identity before the agent runs a single query. How openhands sql server guardrails work with native roles SQL Server separates server logins from individua

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 guardrails by creating a restricted database user. Then you assign fixed roles to limit what the agent can run. Many engineering teams start by giving their coding agent a standard developer account. That broad role often lets the agent change rows or drop tables by mistake. A safer setup scopes the database identity before the agent runs a single query.

How openhands sql server guardrails work with native roles

SQL Server separates server logins from individual database users. A database user is the identity of a login inside one specific database. When an agent needs many databases on an instance, teams use a master login. When the agent needs one or a few databases, a contained user works well. A contained database user has a password and skips the master login step. An admin must first turn on contained databases on the server and database. In total, SQL Server supports thirteen different types of database users.

Once you create the user, you attach fixed database roles to limit actions. Every database role, including the default public role, includes basic connection rights. You cannot change the built-in permissions assigned to fixed database roles. If the agent only needs to inspect schemas and rows, assign the read role. Members of that read role can read all data from user tables and views. If you want to block writes for sure, add the deny write role. That role stops the user from adding, changing, or deleting any table data.

Never give an automated coding agent the database owner role. The owner role can run all maintenance tasks and even drop the whole database. Even the standard write role is risky for an unmonitored agent session. Members of the write role can add, delete, or change data in all tables.

What native database roles solve and what they miss

Native roles are great for setting a hard floor on database access. They decide which user can log in and which tables that user can touch. By pairing a contained user with a read role, you block destructive writes. The database engine will reject any attempt by the agent to alter table data.

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

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Still, static roles do not inspect what individual queries do in flight. A read role lets the agent read every single user table and view. If a table holds emails, phone numbers, card numbers, or national IDs, queries return them. The database sends those raw rows straight back to the agent workspace. You can add a deny read role, which blocks all user tables and views. Yet that role blocks everything at the database level rather than filtering single columns.

Static roles also lack a step to pause risky statements for human review. Sometimes an agent needs to run a single data fix during a task. Granting the write role opens up every user table to changes all at once. Revoking the role right after the task takes manual work from an admin. Teams need runtime controls that check statements and rewrite sensitive fields in results.

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

Use a contained user if the agent only needs one or a few databases. It keeps the user inside that database without needing a login in master. Remember that an admin must turn on contained databases on the server first.

Can I edit a fixed database role to hide specific columns?

No, SQL Server does not let you change permissions inside fixed database roles. The read role grants read access to all user tables and views at once. To filter out emails or card numbers in results, you need column permissions or masking.

How do I stop an agent from changing data while allowing reads?

Place the agent database user into the fixed read role for table queries. You can also add the deny write role to block all data changes. Avoid the owner role since it allows the user to drop the entire database.

The query runs. The emails stay hidden.