Est.
Data AccessLong read

Why Shared Read-Only Postgres Users Fail Least-Privilege Audits and What Internal Database Tools Should Enforce Instead

Shared read-only roles hide who queried what, and auditors want names.

· 9 min read
Cover illustration for “Why Shared Read-Only Postgres Users Fail Least-Privilege Audits and What Internal Database Tools Should Enforce Instead”
Data Access · December 5, 2026 · 9 min read · 2,022 words

You’ve got a shared read-only Postgres user. You’ve got query logging. You’re good, right? Wrong.

Why a shared read-only Postgres role is not a least-privilege control

Read-only is not the same as least-privilege. The problem with a shared read-only user is who can use it. Every person or service that connects as that role is indistinguishable from every other. The database sees one anonymous identity, and your audit logs reflect that.

Least-privilege has two parts: limiting what an identity can do, and limiting who that identity is. A shared read-only role addresses the first and completely fails the second.

The shared role exists because provisioning individual accounts is a hassle. But the shortcut creates an audit problem: you can’t tell which analyst ran which query, which service issued which read, or which engineer touched the data on the day they left the company.

A blanket SELECT on every schema is not minimized access. A query that returns a plan_tier also returns an iban, a date_of_birth, and an ssn in the same row. That’s a data-minimization problem even if nothing is written.

What SOC 2 and PCI-DSS actually require at the credential level

SOC 2 CC6.1 requires logical access controls that limit access to authorized users. CC6.2 requires that new access be registered and provisioned through a formal process. A shared service account fails both: there is no per-user registration, and there’s no per-user revocation.

The PCI-DSS requirements are more specific. Requirement 8 demands a unique ID for each user. Requirement 7 demands access restricted to what the user’s role needs. mydbops’s 2026 PCI-DSS guide says it plainly: shared app_user accounts with blanket SELECT and UPDATE across every table fail PCI-DSS every time. The required outcome is a role matrix in which every account is traceable to a named individual or service.

This is why security reviewers at enterprise prospects push back on “we use a shared readonly role with audit logging” when you’re asked for your SOC 2 evidence. They need per-user attribution.

Diagram: Shared Role vs. Per-User Role: What the Audit Log Actually Shows. Visualizes: Contrast two database access models side by side.

What the Intesa Sanpaolo fine shows about unattributed query access

In March 2026 the Garante fined Intesa Sanpaolo — one of the largest fines the Italian data protection authority had ever issued — for a data breach involving an employee’s unauthorized access to thousands of customer records over two years. The Garante found inadequate technical and organizational controls: the bank failed to detect the accesses.

Query logs existed. Per-user attribution did not. The regulator’s question — who ran these queries — could not be answered. That’s the same failure mode a shared read-only role creates: logs that show a role name but not a person. If your database team can’t answer “who ran this query on this date” during an incident, you have the same problem, read-only or not.

Three ways a shared read-only role leaks more than teams realize

Blanket SELECT isn’t column-level minimized. Granting SELECT on a table grants access to every column in it, including PII columns you never meant to expose. GDPR Article 5(1)(c) data minimization applies to both what is returned and what is written. Teams often apply data minimization to external APIs and assume it doesn’t apply internally. It does. StrataKB’s initial read-only role, for example, granted SELECT on all tables in three schemas — inadvertently exposing the audit log, the users table, and all learning interaction records to any operator. The fix: explicit per-table grants, an explicit REVOKE on all tables across all three schemas, and only the needed tables re-granted. No ALTER DEFAULT PRIVILEGES, so future tables are closed by default.

Row-Level Security doesn’t cover columns. PostgreSQL RLS filters rows. Within a permitted row, every column is accessible. RLS and column-level access control are evaluated independently. To revoke column access you have to revoke SELECT on the table first and then grant it back column by column — column grants do not override a pre-existing table-level SELECT. The royaraqamia security audit found that two public roles held write grants on a substantial number of relations and TRUNCATE on two views — the only thing refusing unauthorized writes was RLS policy. The documented least-privilege baseline had drifted from production, and nothing checked for it.

Connection poolers can erase identity entirely. Transaction-mode poolers like PgBouncer can be configured to map multiple application users onto a single backend credential. To Postgres, every connection looks like the same user. In that setup, RLS has no per-user identity to enforce against — you have to carry identity in session variables and assert it in the application layer. The AIHUB production environment is a stark example: a single superuser role owned every database in a shared cluster and was the login credential for multiple separate applications. A compromise of any one application gave superuser access to all the others. Short-lived X.509 certificates, which bind a cryptographic identity to a time-limited session, address this problem directly.

Why offboarding and incident response break down without per-user credentials

Offboarding an employee who used a shared credential means rotating the password and finding every CI pipeline,.env file, tunnel config, and service that uses it. You also can’t tell what they queried in their final weeks. The AIHUB issue makes this explicit: multiple separate application backends shared one database role, so revoking one team’s access requires touching every other application’s connection configuration.

Incident response is just as broken. When an anomalous query pattern shows up in the logs, the first question is “who ran this?” A shared role makes that question unanswerable. The Intesa Sanpaolo case showed what happens at regulatory scale when you can’t answer it. A workforce marketplace running Aurora MySQL had a similar gap: the existing pull-request process had a paper trail of intent but no record of what actually ran. For a SOC 2 or ISO 27001 auditor, stitching together intent and execution from separate sources is not acceptable evidence.

What the database layer must enforce to replace the shared role

Replace the shared role with individual login roles for every human operator and every application service. mydbops’s PCI-DSS guide describes the required outcome: a role matrix where every account is traceable to a named individual or service, and no account has write access to tables it doesn’t touch in production. Short-lived certificates take this further by binding a cryptographic identity to a session and expiring with it.

Grant access per table. ALTER DEFAULT PRIVILEGES grants access to future tables automatically — StrataKB’s fix explicitly removed this and used named grants on exactly four tables. Explicitly REVOKE on sensitive tables (audit logs, user records, schema migrations, PII tables) even for roles that have schema USAGE. USAGE grants traversal only, but keeping traversal distinct from access requires deliberate exclusion.

Add a CI check that asserts the grant state: query information_schema.role_table_grants or assert with has_column_privilege. The royaraqamia audit’s core finding was that the gap between the documented baseline and the live grants went undetected because nothing checked. Without an assertion, the next migration can silently widen access.

Use FORCE ROW LEVEL SECURITY so table owners are subject to policies too. Combine row policies with column-level restrictions (via secure views or column grants) — they’re evaluated independently, and you need both. Scope RLS policies to auth.uid() or an equivalent session variable. Behind a pooler, assert the user in a session variable (SET LOCAL app.user_id) and write the policy against that. The SAMURA project’s test — a read-only transaction run as samura_runtime with no app-user context — confirmed the role could see rows in the auth tables (user, session, account). The role was NOLOGIN and correctly scoped, but those tables had no RLS policies at all.

Why database-layer controls alone are not enough for teams with non-technical users

Correct database configuration is necessary, but for many teams it’s not sufficient. If your analysts, ops staff, and support teams need self-serve data access and can’t hold individual database credentials, you’re back to the shared-role problem or a ticket-based bottleneck.

The answer is a tool layer that enforces the same identity, logging, and permission controls, but presents them to non-technical users in a governed way. BI permissions have four independent layers — identity, workspace, dataset, and row — and each one has to be enforced. Skipping one is how leaks happen even when the database is correctly configured.

This is also where AI-generated and natural-language queries create a specific compliance concern: AI-generated SQL must respect the same row-level security, column masking, and access control policies as pre-built dashboards. Tools that enforce access at the database layer ensure AI-generated queries inherit those policies automatically. If you’re evaluating tools with agent or MCP access, confirm that agent-generated queries follow each user’s permissions and row-level security — not the tool’s service account.

For teams that need to log database activity without capturing data content, pgaudit provides table-level access logging. It’s necessary but not sufficient for GDPR-regulated workloads where both the content of the query and its existence matter.

What internal database tools should enforce — and which ones do

An internal database tool closes the least-privilege gap only if it enforces individual authenticated identities, per-user query logging, object-level permission inheritance, and row-level policies. Not every tool that claims governed access actually delivers all four.

Basedash is an AI-native BI platform that connects directly to your database. Engineering and data teams configure it once — role-based access control, row-level permissions, column-level restrictions — and every downstream user operates within that access envelope. Each user logs in as themselves. Queries run under their identity and are logged against it. Users can update records they’re authorized to touch through editable data views, without needing database credentials. The connection to the database is held by Basedash’s backend.

Direct database access tools (DBeaver, TablePlus, DataGrip, psql) require each user to hold an individual database credential. That enforces per-user identity correctly, but it exposes the credential to the user and requires SQL literacy. They’re appropriate for database engineers and DBAs, while the analysts and ops staff who currently share the read-only role need other tools. Query logging is database-side (pgaudit), and attribution works when each user has their own role — but there’s no application-layer audit trail of what users intended versus what executed.

Custom internal admin panels can enforce any permission model you design, but you have to build and maintain them. The data team becomes a full-time internal-tools team. Permission drift is a common failure mode: the royaraqamia audit found that the live grant state had drifted from the documented baseline with no automated check to catch it. A custom panel without CI-enforced grant assertions has the same problem.

The enforcement checklist: moving from a shared role to attributed, governed access

Create individual login roles for every human operator and every application service. Restrict the shared role to a tightly scoped, non-human service with its own audit trail, or remove it. Replace schema-wide SELECT grants and ALTER DEFAULT PRIVILEGES with named per-table grants. Explicitly REVOKE on audit logs, user tables, and PII tables. Add a CI assertion on information_schema.role_table_grants so future migrations can’t silently widen access. Apply FORCE ROW LEVEL SECURITY. Audit role usage regularly via pg_roles and pg_stat_activity.

Behind connection poolers, assert user identity in a session variable and replace current_user with that variable in RLS policies. Confirm the runtime application role is not superuser, does not hold BYPASSRLS, and cannot connect to databases outside its scope. Test cross-tenant isolation explicitly: a read-only transaction as the runtime role with no app-user context should not see another user’s rows.

Replace direct credential sharing for non-technical users with a governed internal tool that authenticates users individually, logs queries against their identity, and enforces row-level and column-level restrictions. Verify that AI-generated or natural-language queries inherit the same RLS and column-masking policies as pre-built dashboards. Ensure MCP or agent access follows each user’s permissions. Consider short-lived certificates for automated or agent-based query access.

The end state is what auditors actually need: a role matrix where every account is traceable to a person or service, query logs that carry individual attribution, and evidence that approved access matches what actually ran. That’s least privilege, and it’s the same thing your security team has been asking for.

Sources

  1. PostgreSQL: Documentation: 19: 5.10. Row Security Policies
Filed underData Access

More in Data Access