4.7 Make use of predefined roles

Warning! Audit Deprecated

This audit has been deprecated and will be removed in a future update.

View Next Audit Version

Information

PostgreSQL provides a set of predefined roles that provide access to certain commonly needed privileged capabilities and information. Administrators can GRANT these roles to users and/or other roles in their environment, providing those users with access to the specified capabilities and information.

Rationale:

In keeping with the principle of least privilege, judicious use of the PostgreSQL predefined roles can greatly limit the access to privileged, or superuser, access.

NOTE: Nessus has provided the target output to assist in reviewing the benchmark to ensure target compliance.

Solution

If you've determined that one or more of the predefined roles can be used, simply GRANT it:

postgres=# GRANT pg_monitor TO doug;
GRANT ROLE

And then remove superuser from the account:

postgres=# ALTER ROLE doug NOSUPERUSER;
ALTER ROLE
postgres=# select rolname from pg_roles where rolsuper is true;
rolname
----------
postgres
(1 row)

Default Value:

The following predefined roles exist in PostgreSQL 15.x:

pg_read_all_data

Read all data (tables, views, sequences), as if having SELECT rights on those objects, and USAGE rights on all schemas, even without having it explicitly. This role does not have the role attribute BYPASSRLS set. If RLS is being used, an administrator may wish to set BYPASSRLS on roles to which this role is GRANTed.

pg_write_all_data

Write all data (tables, views, sequences), as if having INSERT, UPDATE, and DELETE rights on those objects, and USAGE rights on all schemas, even without having it explicitly. This role does not have the role attribute BYPASSRLS set. If RLS is being used, an administrator may wish to set BYPASSRLS on roles to which this role is GRANTed.

pg_read_all_settings

Read all configuration variables, even those normally visible only to superuser.

pg_read_all_stats

Read all pg_stat_* views and use various statistics related extensions, even those normally visible only to superuser.

pg_stat_scan_tables

Execute monitoring functions that may take ACCESS SHARE locks on tables, potentially for a long time.

pg_monitor

Read/execute various monitoring views and functions. This role is a member of pg_read_all_settings, pg_read_all_stats and pg_stat_scan_tables.

pg_database_owner

None. Membership consists, implicitly, of the current database owner.

pg_signal_backend

Signal another backend to cancel a query or terminate its session.

pg_read_server_files

Allow reading files from any location the database can access on the server with COPY and other file-access functions.

pg_write_server_files

Allow writing to files in any location the database can access on the server with COPY and other file-access functions.

pg_execute_server_program

Allow executing programs on the database server as the user the database runs as with COPY and other functions which allow executing a server-side program.

pg_checkpoint

Allow executing the CHECKPOINT command.

Administrators can grant access to these roles to users using the GRANT command.

See Also

https://workbench.cisecurity.org/files/4247

Item Details

References: CSCv7|5.1

Plugin: PostgreSQLDB

Control ID: afc92610b1c34d9f8e73780f76d4aff278c0b10a4aeffc7ad56b675f21a571f5