How to Configure Dify Supabase Sandbox
You set up a dify supabase sandbox by making a dedicated Postgres user for your AI workflows. Next, you restrict that user to read-only access on non-sensitive tables. Many teams skip this step when they test AI apps. They often paste the default admin password into their workflow tool. This habit gives an AI agent full control over the database. One bad query can wipe out test tables or leak sensitive user records. A safe test setup starts with strict database roles and clear limits. How a d
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 dify supabase sandbox by making a dedicated Postgres user for your AI workflows. Next, you restrict that user to read-only access on non-sensitive tables.
Many teams skip this step when they test AI apps. They often paste the default admin password into their workflow tool. This habit gives an AI agent full control over the database. One bad query can wipe out test tables or leak sensitive user records. A safe test setup starts with strict database roles and clear limits.
How a dify supabase sandbox works with database roles
Every new Supabase project comes with a default postgres role. This role has admin rights across the whole project. Supabase does not grant true superuser rights because those allow destructive actions. Still, the default postgres role holds broad power over your data and schemas. The password you pick at project creation belongs to this admin role.
Supabase warns teams not to share this admin password with outside tools. Instead, you should make a fresh database user for each external service. When you run SQL in the project dashboard, it runs as the default postgres role. The system even tags those queries with a dashboard source comment.
For your AI workflow tool, you should create a custom role with limited rights. This role only needs permission to read specific tables in your test schema. You also get built-in roles like anon for public requests in each project. Still, a dedicated role works best for direct database queries from an AI app. You create this user and grant table permissions through standard SQL commands. Then you place those new credentials into your workflow tool settings.
What native database roles solve and what they miss
A custom database role solves the first big problem in AI testing. It stops the AI workflow from dropping tables or changing schema rules. It also blocks the app from reading tables that you did not grant to that role. Your admin credentials stay safe inside your team vault.
Still, static database roles only check who logs in at the start. They do not inspect what individual queries do once the session starts. If a table holds test records with real emails or phone numbers, the role reads them. The database sends every column in that allowed table back to the AI model. Native role checks cannot rewrite emails, phone numbers, or card numbers in flight.
AI Sandbox Environments + End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Static credentials also create work for your engineering team over time. Someone must store, rotate, and revoke the password stored inside the AI tool. If a builder shares a workflow template, the shared database role handles all runs. You cannot tell which team member ran a specific query from the database logs alone. Every query from the AI app looks identical inside the database activity log. You need query-level controls to mask sensitive fields and track who ran each test.
Best practices for safe AI database testing
Keep your test database separate from your production project at all times. Even in a test project, never load real customer card numbers or national IDs. Use fake data whenever you build new AI prompts and agent tools.
Review your role grants often to make sure test users stay locked down. Revoke access right away when a team finishes testing an AI workflow. Check your database logs each week to spot slow or broad queries from your AI tools. Combine scoped database roles with field masking when test tables hold real user emails.
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 use the default postgres role for my AI sandbox?
No, the default postgres role has admin rights across your project. Supabase recommends creating a separate user for every external service you use.
Can database roles hide emails and phone numbers from AI prompts?
Standard table roles allow or block access to whole tables or columns. They do not rewrite matched emails or phone numbers inside query results.
How do queries from the Supabase dashboard differ from external app queries?
Queries run in the Supabase dashboard execute as the default postgres admin role. They also include a comment showing the dashboard as the source.
Related guides
In this post