How to Configure Copilot Studio Supabase Least Privilege

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up copilot studio supabase least privilege by making a custom database role. Then you restrict that role to the exact tables and rows your bot needs. Many teams skip this step when they build their first AI agent. They paste the default admin password or a broad key into the agent setup. This gives the bot full read and write power over every table. A bad prompt or agent mistake can then change or leak production rows. How copilot studio supabase least privilege works Every Supabase p

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 copilot studio supabase least privilege by making a custom database role. Then you restrict that role to the exact tables and rows your bot needs. Many teams skip this step when they build their first AI agent. They paste the default admin password or a broad key into the agent setup. This gives the bot full read and write power over every table. A bad prompt or agent mistake can then change or leak production rows.

How copilot studio supabase least privilege works

Every Supabase project starts with a default postgres role that holds admin rights. The vendor docs say not to give this password to outside services. Instead, the docs tell you to make a new user for each service. This is the core rule for copilot studio supabase least privilege.

When your bot connects to the database, it logs in with one role. If you use the default admin role, the bot can read or drop tables. To fix this, you create a dedicated role just for your bot. You give this role read-only rights on a few specific tables. If the bot does not need to edit data, it gets no write rights.

Supabase also includes built-in roles for API requests, such as anon and authenticated. You can pair these roles with row rules on your Postgres tables. Row rules check who is asking before the database sends back any rows. You can also limit which columns the bot role is allowed to read. This keeps secret columns out of the bot's reach during normal queries.

Why you should avoid the default admin role

The default postgres role in Supabase is an admin, though not a full superuser. Supabase blocks superuser access to stop destructive actions on the host system. Still, the default postgres role has extra rights for most admin work. Queries run in the web dashboard use this admin role by default.

If an AI agent uses this admin role, it bypasses standard table checks. The agent can read every schema, view internal tables, and change live records. Creating a custom role with narrow table grants stops whole-database exposure. It forces the database to reject queries that touch off-limit tables.

Least Privilege Principle + Copilot Security Implications: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

What native roles solve and what they leave open

Native Postgres roles and row rules decide who can log in and read tables. They do a great job of blocking access to entire tables or rows. If a bot asks for a forbidden table, Postgres stops the query right away. This is a strong first step for any database team.

Still, static database roles cannot check what an individual query does in flight. Once a role has read access to a customer table, it sees every allowed column. If that table holds emails, phone numbers, or card numbers, the query returns them. A static role cannot rewrite matched fields in results before the bot reads them.

Database roles also rely on long-lived passwords or keys stored in your agent setup. If someone copies that key, they get the same access as the bot. Also, standard role checks do not ask a human to approve risky queries in real time. Teams need a way to inspect queries and mask sensitive fields on the fly.

Check every Postgres query on the wire

Database roles and network rules decide who can open a session. They do not read what each SQL statement does after login. With hoop.dev, you run an open-source proxy, a sidecar for your Postgres. It runs beside your database and reads the Postgres wire protocol. Your apps and agents keep their login details and change only the host and port in the connection string their tool uses.

Before a query runs, hoop.dev guardrails check the statement by its effect, table, or pattern. They refuse bad deletes or drops with a real Postgres error. On the way back, hoop.dev data masking rewrites sensitive values in returned rows based on your rules. Every query and verdict goes to the audit trail. Furthermore, hoop.dev holds SOC 2 Type II, is MIT licensed, and generates evidence for HIPAA, GDPR, and PCI DSS. See the code on GitHub.

Frequently asked questions

Should I give my AI agent the default Supabase postgres password?

No, the default postgres password has admin rights across your whole project. You should create a separate database user with narrow rights for each outside service.

Can a read-only database role stop an AI bot from reading sensitive fields?

A read-only role only stops the bot from changing or deleting data. If the role can read a column, it still gets all raw emails or card numbers in that column.

How do I limit which tables my Copilot Studio bot can query?

Create a dedicated Postgres role for the bot and revoke all default public permissions. Then grant select rights only on the specific tables and columns the bot needs.

The query runs. The emails stay hidden.