How to Configure Goose SQL Server Sandbox
You set up a goose sql server sandbox by making a read-only database user. Then you connect the AI agent to an isolated test database. Engineering teams often connect local AI agents straight to shared test databases. They reuse broad admin accounts to get the agent running fast. When permissions are too broad, a bad query can wipe out test tables. It can also pull sensitive customer rows into the agent logs. How to set up a goose sql server sandbox with native roles To lock down the agent, s
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 a goose sql server sandbox by making a read-only database user. Then you connect the AI agent to an isolated test database. Engineering teams often connect local AI agents straight to shared test databases. They reuse broad admin accounts to get the agent running fast. When permissions are too broad, a bad query can wipe out test tables. It can also pull sensitive customer rows into the agent logs.
How to set up a goose sql server sandbox with native roles
To lock down the agent, start with how SQL Server handles user accounts. A database user is the identity of a login inside a database. SQL Server supports thirteen types of database users for different access needs. If the agent needs many databases, teams create a login in master. Then they map a SQL user to that login.
For a single sandbox database, a contained database user works well. This user has a password and does not need a login in master. An admin must first turn on contained databases on the server and database. This keeps the agent inside that one sandbox database.
Next, you assign the user to fixed database roles to control actions. You cannot change the permissions built into these fixed roles. Every role, including the public role, comes with basic connect rights. To let the agent inspect data, add the user to db_datareader. Members of db_datareader can read all data from all user tables and views.
If the agent must test writes, you can add it to db_datawriter. Members of db_datawriter can add, delete, or change data in all user tables. For a safe sandbox, pair db_datareader with the db_denydatawriter role. Members of db_denydatawriter cannot add, change, or delete any table data. Never put the agent in the db_owner role. Members of db_owner can run all maintenance tasks and even drop the database.
Why native roles leave gaps for AI agents
Native SQL Server roles solve the first step of sandbox security. They control who logs in and which broad actions that account can take. Putting an agent in db_datareader and db_denydatawriter stops accidental table drops and bad writes. It keeps your test database intact while the AI agent explores the schema.
Still, fixed roles do not check individual SQL statements in flight. A user in db_datareader can read every single user table and view. If your sandbox holds copied production data, the agent can read all of it. It can pull emails, phone numbers, card numbers, and national IDs in one query.
Kubernetes API Server Access + AI Sandbox Environments: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
You can block all reads with db_denydatareader, which hides all user tables and views. Yet that breaks the agent because it cannot read anything at all. Native roles are all-or-nothing across user tables unless you manage table grants by hand. They also store static database passwords on the machine running the Goose agent. Teams still need a way to inspect queries and mask sensitive fields in results.
Managing statement checks and sensitive fields in a sandbox
Before letting an agent query a sandbox, teams should review their data exposure. Test databases often start as snapshots of live systems. Even when an agent only has read rights, every row it fetches leaves the database. The agent reads those rows into its local memory and sends them to the model.
To keep the sandbox safe, teams need controls that work at the query level. Instead of relying only on table-wide read roles, check each statement before it runs. Block high-risk commands and limit how many rows a single query can return. When results come back, masking rules should rewrite matched fields like emails and card numbers. This lets the agent debug schemas and test queries while keeping private fields masked.
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
What SQL Server role is safest for a Goose sandbox?
Assign the agent user to db_datareader and db_denydatawriter. This lets the agent read all user tables and views while blocking data changes.
Should I use a standard login or a contained user for the sandbox?
Use a contained database user if the agent only needs one sandbox database. This keeps the user password inside that database without needing a login in master.
Does db_datareader stop an AI agent from reading sensitive columns?
No, members of db_datareader can read all data across every user table and view. You need query-level masking to rewrite emails, phone numbers, or card numbers in results.
Related guides
In this post