Re: prevent users from SELECT-ing from pg_roles/pg_database

From: Muhammad Salahuddin Manzoor <salahuddin(dot)m(at)bitnine(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Andreas Joseph Krogh <andreas(at)visena(dot)com>, pgsql-general <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: prevent users from SELECT-ing from pg_roles/pg_database
Date: 2024-05-24 17:43:56
Message-ID: CAKD7CDkcRu8S6i=q8S06VoGyt9jfN5iS_2WvncAALrWwP3XyNg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Greetings,

Yes, you are correct. And

For applications/systems/scripts relying on this information may require
sgnificent modifications to handle the restricted access.

Alternative approches can be.

Auditing and monitoring.
You can use pgaudit extension for auditing and minitoring.

Use SE-PostgeSQL extension that give fine grained access control other than
PG standard permissions.

Try RLS row level security. May involve careful planning and may not cover
all use cases.

Regards,
Salahuddin.

On Fri, 24 May 2024, 22:02 Tom Lane, <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> Andreas Joseph Krogh <andreas(at)visena(dot)com> writes:
> > Hi, is there a way to prevent a user/role from SELECT-ing from certain
> > system-tables?
> > I'd like the contents of pg_{user,roles,database} to not be visible to
> all
> > users.
>
> As noted, you can in principle revoke the public SELECT grant from
> those views/catalogs. However, the system is not designed to hide
> such information, which means you'll have (at least) two kinds of
> issues to worry about:
>
> 1. Queries or tools breaking that you didn't expect to break.
> It's hardly uncommon for instance for queries on pg_class to
> join to pg_roles to get the owner names for tables.
>
> 2. Information leaks. For example, mapping role OID to role name
> is trivial with either regrole or pg_get_userbyid(), so it
> wouldn't take long to scan the plausible range of role OIDs and
> get all their names, even without SQL access to the underlying
> catalog.
>
> regards, tom lane
>
>
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Peter 2024-05-25 10:51:50 Autovacuum endless loop in heap_page_prune()?
Previous Message Tom Lane 2024-05-24 17:02:13 Re: prevent users from SELECT-ing from pg_roles/pg_database