How to Configure OpenHands SQL Server Approval

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up openhands sql server approval by pairing scoped database roles with human review. This setup stops AI agents from running unsafe database changes without a check. Many teams start by giving the agent a shared login to test tasks fast. Broad permissions let a single bad prompt delete rows or drop tables in seconds. You need strict boundaries before an agent touches real data. How native openhands sql server approval and roles work SQL Server manages access through server logins and

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 approval by pairing scoped database roles with human review. This setup stops AI agents from running unsafe database changes without a check. Many teams start by giving the agent a shared login to test tasks fast. Broad permissions let a single bad prompt delete rows or drop tables in seconds. You need strict boundaries before an agent touches real data.

How native openhands sql server approval and roles work

SQL Server manages access through server logins and database users. A database user is the identity of a login inside one database. For access to many databases on an instance, a login in master is common. For one or a few databases, you can use a contained database user. An admin must first turn on contained databases on the server and database. SQL Server supports thirteen types of database users for different needs.

After you create the user, you assign a fixed database role. Every database role, including the public role, includes basic permission to connect. You cannot change the permissions built into fixed database roles. If the agent only needs to inspect records, use the datareader role. Members of this role can read all data from all user tables and views. You can also use a deny role to block all table reads or writes.

Sometimes an agent must fix data or build features. The datawriter role lets the user add, delete, or change data in user tables. Teams often assign the database owner role to avoid permission errors during tests. That owner role can run all maintenance tasks and even drop the database. Giving an autonomous agent owner rights puts every table at risk.

What native roles solve and what they miss

Native roles are great for setting a hard ceiling on database logins. A read role stops an agent from changing rows across the database. A deny write role blocks accidental updates before they run. These controls decide who logs in and which broad actions they can take.

Still, static roles do not inspect individual queries in flight. A read role still lets an agent pull every table at once. That query output can include emails, phone numbers, card numbers, or national IDs. Also, a write role cannot tell a safe update from a bulk delete. If the agent has write rights, every valid statement runs right away.

Approval Chains & Escalation + Kubernetes API Server Access: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Why agent workflows need statement-level checks

An AI coding agent works by running a loop of commands and queries. You can pause the agent before it runs a shell tool. Yet a shell check does not parse the actual SQL statement inside a script. A team member might approve a script without seeing a hidden drop statement. True openhands sql server approval needs checks at the query level.

Instead of giving the agent permanent write roles, teams should gate risky statements. Read queries can run right away with data masking applied to sensitive fields. Masking rewrites matched fields like card numbers or emails in the query results. When the agent tries to change data, the query waits for a human check. A reviewer reads the exact statement and approves or blocks it in real time.

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

Can SQL Server fixed roles require approval for a single query?

No, SQL Server fixed roles only grant or deny access at the role level. Once a user has write rights, the database runs every valid change right away.

Which SQL Server role is safest for an OpenHands agent?

The datareader role combined with the deny datawriter role is the safest native choice. This setup lets the agent read user tables while blocking all data changes.

How do you protect sensitive fields when an agent reads tables?

A read role still exposes all columns in user tables and views by default. You should apply dynamic masking to rewrite emails, phone numbers, and card numbers in results.

The query runs. The emails stay hidden.