How to Configure OpenHands Supabase Data Masking

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up openhands supabase data masking by making a custom database role and masking rules. These rules rewrite sensitive fields like emails and phone numbers before query results return. Teams use AI coding agents to write code, run tests, and fix database bugs. To work well, the agent needs to read your schema and run test queries. Many teams take a shortcut and hand the agent the default project password. That password links to the default admin role in your project. When an AI agent hold

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 supabase data masking by making a custom database role and masking rules. These rules rewrite sensitive fields like emails and phone numbers before query results return.

Teams use AI coding agents to write code, run tests, and fix database bugs. To work well, the agent needs to read your schema and run test queries. Many teams take a shortcut and hand the agent the default project password. That password links to the default admin role in your project. When an AI agent holds admin rights, a bad query can pull live user data. It can also drop tables or send raw card numbers into external model logs.

How openhands supabase data masking works in Postgres

Every project comes with a default postgres role that holds admin privileges. The platform does not grant full superuser status because that allows destructive database tasks. Instead, the default postgres role gets extra permissions to handle daily admin work. The password you create at project setup belongs to this admin role. Docs warns that you should never give this password to an external service. Instead, you should make a fresh database user for each tool you connect.

Each new project also includes built-in roles such as anon, authenticated, service_role, and authenticator. These built-in roles support client apps and API traffic, not autonomous coding agents. To set up openhands supabase data masking, you first create a dedicated role for the agent. Next, you revoke read permissions on tables that hold sensitive records. You can then build separate database views that replace emails or national IDs with placeholders. You grant your agent role permission to read only those views. When the agent runs a query, the database returns only the altered view rows.

Why static database roles and views fall short

Static database roles and custom views solve the basic login problem. They make sure the AI agent logs in with its own identity. They also block the agent from reading raw tables that you remembered to lock down.

Still, static setup only decides who can log in at the start. It does not inspect what individual queries do while a session runs. Coding agents often build new tables and run migrations while fixing bugs. When a developer adds a new column for phone numbers, views fall out of sync. If the agent queries that new table, raw data flows back into the agent context. Static views also require heavy upkeep across dozens of tables. If you restrict the agent role too much, it cannot inspect schemas or test queries. Teams then grant broad admin permissions again just to get their work done.

Data Masking (Static) + End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

How to protect sensitive fields during agent runs

A safer approach separates schema tasks from raw data reads during live sessions. You start by giving the agent a dedicated database user with narrow table rights. You never share the default postgres admin password with the agent runtime. Queries run in the project dashboard already execute as the postgres role with a dashboard comment. Keeping your agent on a separate user makes database logs much easier to read.

Beyond basic roles, teams need real-time checks on the results of every query. When an agent runs a select statement, masking rules should rewrite matched fields in results. This step alters emails, phone numbers, card numbers, and national IDs before the agent processes them. The agent still sees accurate data types and row counts to debug code. Yet the raw values do not enter the agent prompt history.

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 I give an AI coding agent the default postgres password?

No, the default postgres password grants admin rights across the database. You should make a separate database user with limited permissions for the agent.

What types of data can masking rewrite in query results?

Masking rules rewrite matched fields like emails, phone numbers, card numbers, and national IDs. The database returns realistic placeholders so the agent can still test code logic.

Do built-in roles like anon mask sensitive columns automatically?

No, built-in roles like anon and authenticated only control basic row and table permissions. You must set up separate masking rules or views to rewrite sensitive fields in results.

The query runs. The emails stay hidden.