How to Configure Windsurf Postgres Least Privilege

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up windsurf postgres least privilege by creating a restricted database role. You then point the editor agent to that role instead of an admin account. Many teams start by giving their AI coding assistant a shared developer login. That broad login lets the agent read every table or alter data by mistake. A tight role limits what the agent can touch from the very first query. How windsurf postgres least privilege works in practice Cognition renamed Windsurf to Devin Desktop in June 2026

Least Privilege Principle + End-to-End Encryption: the complete guide

Architecture patterns, implementation strategies, and security best practices. Delivered to your inbox.

Free white paper. No spam. Unsubscribe anytime.

You set up windsurf postgres least privilege by creating a restricted database role. You then point the editor agent to that role instead of an admin account. Many teams start by giving their AI coding assistant a shared developer login. That broad login lets the agent read every table or alter data by mistake. A tight role limits what the agent can touch from the very first query.

How windsurf postgres least privilege works in practice

Cognition renamed Windsurf to Devin Desktop in June 2026. The product keeps the same editor features and agent workflow. Its Cascade agent can run terminal commands with user permission. The dedicated terminal loads the user shell setup on macOS and Linux. That means shell aliases and local variables are open to the agent. The agent can also reach external tools through local Model Context Protocol servers.

When the agent queries Postgres, it uses the database role you give it. To lock this down, admins create a dedicated group role for AI tools. You then create a login user for the agent and add it to that group. Next, you check the built-in PUBLIC role in your database. By default, Postgres gives PUBLIC the right to log in and make temp tables. It also lets PUBLIC run functions and procedures. The database owner can take back these default rights to tighten security.

You should also check the public schema rules. In Postgres 15 and newer, regular users cannot create new objects there by default. On older upgraded databases, an admin must take back that create right from PUBLIC. After you lock down defaults, you grant read rights only where needed. Postgres lets you grant read access on a whole table or specific columns. Column grants help you keep password hashes or billing fields off limits.

How to scope table and column access for the agent

Start by listing the exact tables the coding agent needs for its task. Most coding tasks only need schema details and a few sample rows. Grant read access on those specific tables to your agent group role. If a table holds sensitive columns, grant read access only on safe columns. Remember that read permission in Postgres also allows bulk data export from those columns. Keep the role away from tables it does not need to inspect.

You also need to plan for new tables that your team builds later. When an engineer runs a migration, the new table gets default owner rules. Make sure your migration scripts do not grant broad rights to PUBLIC by accident. Keep the agent database login details in a dedicated project file. Do not put an admin database URL in your main shell profile. Since the agent terminal loads your shell profile, it can read those variables.

Least Privilege Principle + End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

What native database roles solve and what keeps the session active

Native Postgres roles do a great job of limiting object access at login. They stop the agent from dropping tables or reading forbidden schemas. They also block the agent from writing to tables when it only has read rights. This setup forms a strong base for database safety.

Still, database roles only check who logs in and which objects they touch. They cannot inspect what individual queries do in flight during an active session. A read role can still pull every row from an allowed customer table by default. If a safe table holds emails, phone numbers, or card numbers, the query returns them. Data masking is needed to rewrite matched fields like national IDs in results. Native roles also do not require human approval before a risky command runs.

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, inline in the Postgres wire protocol. On every query an AI agent or engineer runs against production, hoop.dev decides to pass, mask, block, or hold it for human review. 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 refuse bad deletes or drops with a real Postgres error, or hold risky queries for approval. On the way back, hoop.dev data masking rewrites sensitive values in returned rows in memory, and every 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

Does Devin Desktop handle database access the same way as Windsurf?

Yes, Devin Desktop is the new name for Windsurf since June 2026. It uses the same editor setup, terminal execution, and local tool rules.

Can I limit the coding agent to specific columns in a Postgres table?

Yes, Postgres lets you grant read rights on specific columns of a table or view. The agent role will fail if it queries any other column on that table.

Why can a new read-only role still run functions in Postgres?

Postgres grants function execution and database login rights to the PUBLIC role by default. Every new role inherits PUBLIC rights until the object owner revokes them.

Save the open-source gateway.

hoop is MIT-licensed infrastructure for controlling how AI agents reach production data. Star hoophq/hoop so you can inspect it, deploy it, or share it when your team starts governing agent access.