How to Configure OpenHands Supabase Least Privilege
To set up openhands supabase least privilege, create a dedicated Postgres role for the agent. Grant that role only the exact table and row permissions needed for its task. Teams often skip this step and hand the default admin password to their coding agents. That shortcut lets an automated agent drop tables, change schemas, or read sensitive customer data. A broad role turns a minor agent mistake into a major data incident. How openhands supabase least privilege works in Postgres Every Supaba
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.
To set up openhands supabase least privilege, create a dedicated Postgres role for the agent. Grant that role only the exact table and row permissions needed for its task. Teams often skip this step and hand the default admin password to their coding agents. That shortcut lets an automated agent drop tables, change schemas, or read sensitive customer data. A broad role turns a minor agent mistake into a major data incident.
How openhands supabase least privilege works in Postgres
Every Supabase project starts with a default postgres role that holds admin privileges. Supabase does not grant full superuser status because that allows destructive database actions. Even so, the default postgres role holds broad power across your project. You set its password when you first create the project. Supabase docs states you should not share this password with third-party tools. Instead, you should make a fresh database user for each external service.
OpenHands runs as an autonomous coding agent that writes code and runs commands. When it builds features or fixes bugs, it often needs database access. Setting up openhands supabase least privilege means creating a dedicated Postgres role for the agent. You start with a blank role that has no rights by default. Next, you grant read or write permissions only on specific schemas and tables. You can also turn on Row Level Security to limit which rows the agent sees. Supabase also includes built-in roles like anon and authenticated for app traffic. For a coding agent that connects to Postgres, a custom database role works best.
Why native roles are only the first step for agent safety
Native Postgres roles do a great job of controlling who can log in. They also define which tables a user can read or modify at rest. Still, static database permissions cannot judge the intent of an active query in flight. Once OpenHands logs in with a valid role, Postgres trusts every allowed command it sends. If the role has permission to update a table, the agent can update every row by default.
Static roles also create a problem when an agent reads production tables for debugging. If a table holds customer emails, phone numbers, or card numbers, a read grant exposes them. Dynamic data masking solves this by rewriting matched fields in query results on the fly. Native role grants also stay active until an admin revokes them by hand. An agent might need write rights for ten minutes to test a migration. Leaving those write permissions open all week adds risk if the agent misbehaves later.
Least Privilege Principle + End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Steps to scope database permissions for AI coding agents
Start by auditing what OpenHands needs to do during a coding session. Most agents only need to read schema definitions and query a few test tables. Create a new user in your Supabase database with a strong, unique password. Do not let this user inherit rights from the default postgres admin role. Grant usage only on the specific schema your app uses for its data.
Next, grant select permissions only on the tables the agent must inspect. Avoid granting delete or drop rights to an autonomous agent in shared databases. If the agent must test schema changes, point it at a local or staging project. Review your active roles often and remove any permissions the agent no longer needs.
Add query and result controls beside Postgres
Grants and pools govern who logs into PostgreSQL. Yet every query in an open session still runs with that role's full scope. In practice, hoop.dev runs beside your database as a sidecar for your Postgres. It reads plain and prepared queries on the wire with no change to your users or drivers.
When a tool or agent sends SQL, hoop.dev Postgres controls check each statement against your deny rules. An AI Analyzer you configure can also score intent or hold a risky query for human review. Matched sensitive columns in result rows are masked in memory before they reach the caller. Each query and decision is logged per listener, which generates evidence for SOC 2, HIPAA, and GDPR audits. View the binary on GitHub.
Frequently asked questions
Should OpenHands use the default Supabase postgres password?
No, you should keep the default postgres role password private at all times. That role holds admin privileges, so create a separate user with limited rights for OpenHands.
Can Postgres roles hide emails or phone numbers from an AI agent?
Standard table grants allow or block access to whole tables or specific columns. To rewrite sensitive fields like emails or card numbers in results, you need data masking.
How do built-in Supabase roles differ from a custom OpenHands role?
Supabase provides built-in roles like anon for public requests through its API. A custom Postgres role is built for direct database tasks with tailored table rules.
Related guides
In this post