How to Configure Haystack SQL Server Sandbox
You set up a haystack sql server sandbox by making a read-only database user. Then you link your AI pipeline to that limited account. Teams often test AI pipelines with broad admin accounts to move fast. Broad roles let bad queries change tables or drop the whole database. How a haystack sql server sandbox works with native roles SQL Server uses logins and database users to manage who gets in. A database user is the identity a login uses inside one database. For many databases on one server,
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 haystack sql server sandbox by making a read-only database user. Then you link your AI pipeline to that limited account. Teams often test AI pipelines with broad admin accounts to move fast. Broad roles let bad queries change tables or drop the whole database.
How a haystack sql server sandbox works with native roles
SQL Server uses logins and database users to manage who gets in. A database user is the identity a login uses inside one database. For many databases on one server, teams make a login in master. For just one 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. SQL Server offers thirteen types of database users for different needs.
Once the user exists, you assign a fixed database role to it. Every database role, including the public role, has permission to connect. You cannot change the permissions built into fixed database roles. To keep the sandbox safe, teams add the user to the datareader role. Members of this role can read all data from user tables and views. You can also add the deny datawriter role to block all changes. Members of that role cannot add, change, or delete any table data. Avoid the owner role for any AI pipeline or test account. The owner role can change settings and even drop the database.
What native database roles solve and what they miss
Native database roles control who can log in to the database. They also set broad rules on whether an account can read or write. Assigning a read-only role stops an AI agent from deleting your rows. This step blocks destructive commands before they can change any stored records.
Still, native database roles do not inspect individual queries in flight. A user in the datareader role can read every user table and view. If a sandbox holds real customer copies, the AI reads all of it. Fixed roles cannot rewrite query results to hide emails or phone numbers. They also cannot mask card numbers or national IDs inside returned rows. You need extra controls if you want to filter specific columns or rows. Teams must either build custom views or clean the test data first.
Kubernetes API Server Access + AI Sandbox Environments: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Steps to prepare your test data and pipeline
Start by picking an isolated database instance for your AI pipeline tests. Do not run experimental agent queries against your live production tables. Next, create a dedicated database user just for the Haystack pipeline. Assign the read-only role and block write actions using the deny role. If a table holds secret data, use the deny datareader role on it. Members of that role cannot read user tables, views, or their metadata.
Next, check the data sitting inside your test tables before running queries. Replace real emails, phone numbers, and card numbers with fake test values. Finally, give the read-only user details to your Haystack database component. Run a few test prompts to check that read queries work well. Run a test write query to verify that the database blocks changes.
Check SQL Server batches and results on the wire
SQL Server logins and roles decide who connects. They do not check what each TDS batch does or mask sensitive values in returned rows. With hoop.dev, you run an open-source proxy, a sidecar for your SQL Server. It reads plain batches and parameterized queries on the TDS wire while passing Windows login through untouched.
Before a batch hits the server, hoop.dev guardrails check the statement against your rules. Disallowed actions get a native TDS error with your message. On the way back, hoop.dev data masking rewrites sensitive values in supported result columns that match your rules. Every query and decision is logged. Explore the MIT-licensed project on GitHub.
Frequently asked questions
Can I change the permissions inside a SQL Server fixed role?
No, SQL Server does not let you change permissions on fixed roles. You must combine roles or create a custom role for special rules.
Should I use a master login or a contained user for a sandbox?
A contained user is great when the pipeline needs only one database. It stays inside that database and does not need a master login.
How do I stop a read-only user from writing data by mistake?
Add the user to the deny datawriter role inside your sandbox database. This role blocks the account from adding, changing, or deleting any rows.
Related guides
In this post