How to Configure OpenHands Supabase Sandbox
You set up an openhands supabase sandbox by creating a custom database user with scoped permissions. Then you pass those specific role details to the isolated agent container. Many teams start by giving their coding agent the default admin password to move fast. Broad permissions let an automated agent drop tables or read raw customer rows by mistake. How an openhands supabase sandbox works with database roles OpenHands runs tasks inside an isolated container where the agent writes code and r
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 an openhands supabase sandbox by creating a custom database user with scoped permissions. Then you pass those specific role details to the isolated agent container. Many teams start by giving their coding agent the default admin password to move fast. Broad permissions let an automated agent drop tables or read raw customer rows by mistake.
How an openhands supabase sandbox works with database roles
OpenHands runs tasks inside an isolated container where the agent writes code and runs commands. When the agent needs database state, it connects to your Supabase Postgres instance over the network. Every Supabase project includes a default postgres role that holds admin privileges. Supabase does not grant true superuser access because superusers can run destructive database operations. Even so, the default postgres role has extra privileges for most admin tasks. The password you pick at project creation unlocks this default admin role.
Supabase states you should never share this main password with an external service or tool. Instead, you should create a dedicated Postgres user for the coding agent to use. Supabase also provides built-in roles like anon, authenticated, and service_role for API traffic. For direct database work, a custom role lets you grant read or write rights per table. You load these scoped credentials into the agent workspace so it can test queries safely.
What native roles solve and where gaps remain
Creating a separate Postgres role for your agent stops total project takeovers. If the agent hallucinates a bad command, it cannot alter roles or touch other schemas. You can restrict the role to specific tables needed for the current coding ticket. This setup controls which user logs in and which tables that user can reach.
Still, static database roles only check identity when the session starts and when tables open. Once the agent logs in, Postgres allows any query that fits the role grant. A role with write rights on a test table can still delete every row inside it by default. A role with read rights on user tables returns raw emails, phone numbers, and card numbers. Native role grants do not inspect individual SQL statements in flight before they run. They also do not require human approval when an agent tries to run a risky change.
AI Sandbox Environments + End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Steps to scope agent database permissions
Start by listing the exact tables and views your coding agent needs for its task. Log in to your project dashboard, where queries run under the default postgres admin role. Create a new database role with a unique password just for the OpenHands container. Grant that role permission to read or change only the target tables in your schema. Revoke default public schema permissions if the agent should not create new objects there.
Next, pass the new role credentials into the OpenHands workspace settings as secret values. Test the setup by asking the agent to list tables and run a safe select query. Check your database logs after the run to see what statements the agent sent. When the coding task finishes, rotate the password or drop the temporary role right away. This habit keeps old credentials from sitting around in container logs or local files.
Run guardrails and masking on the Postgres connection
Role grants and firewall rules are needed setup. Setup alone cannot check single SQL statements or mask sensitive rows in a response. By design, hoop.dev is an open-source proxy that sits beside Postgres, RDS, or Aurora as a sidecar for your Postgres. Clients and agent tools keep their credentials and point their connection string at the listener.
On each query, hoop.dev guardrails refuse disallowed drops, deletes, or table reads before they run. Next, hoop.dev data masking rewrites sensitive fields in returned rows that match your rules. Furthermore, hoop.dev holds SOC 2 Type II and logs every statement and verdict per resource. Check out the project on GitHub.
Frequently asked questions
Should I give OpenHands the default postgres password in Supabase?
No, you should keep the default postgres password private because it carries admin privileges. Create a separate database user with limited table grants for the agent instead.
Does the Supabase postgres role have full superuser access?
No, Supabase withholds true superuser access to block destructive system commands on the host. Instead, the default postgres role gets admin rights and specific extra privileges.
How can I protect sensitive data when an agent queries my sandbox?
You can remove sensitive columns from the role grant or use dummy data in testing. You can also use data masking to rewrite emails, phone numbers, and card numbers in results.
Related guides
In this post