From PostgreSQL 9.x Security Technical Implementation Guide
Part of SRG-APP-000353-DB-000324
Associated with: CCI-001914
If authorized individuals do not have the ability to modify auditing parameters in response to a changing threat environment, the organization may not be able to effectively respond, and important forensic information may be lost.
First, as the database administrator, check if pgaudit is present in shared_preload_libraries: $ sudo su - postgres $ psql -c "SHOW shared_preload_libraries" If pgaudit is not present in the result from the query, this is a finding.
Note: The following instructions use the PGDATA and PGVER environment variables. See supplementary content APPENDIX-F for instructions on configuring PGDATA and APPENDIX-H for PGVER.
To ensure that logging is enabled, review supplementary content APPENDIX-C for instructions on enabling logging.
For audit logging we suggest using pgaudit. For instructions on how to setup pgaudit, see supplementary content APPENDIX-B.
As a superuser (postgres), any pgaudit parameter can be changed in postgresql.conf. Configurations can only be changed by a superuser.
### Example: Change Auditing To Log Any ROLE Statements
Note: This will override any setting already configured.
Alter the configuration to do role-based logging:
$ sudo su - postgres
$ vi ${PGDATA?}/postgresql.conf
Add the following parameters (or edit existing parameters):
pgaudit.log = 'role'
Now, as the system administrator, reload the server with the new configuration:
# SYSTEMD SERVER ONLY
$ sudo systemctl reload postgresql-${PGVER?}
# INITD SERVER ONLY
$ sudo service postgresql-${PGVER?} reload
### Example: Set An Auditing Role And Grant Privileges
An audit role can be configured and granted privileges to specific tables and columns that need logging.
##### Create Test Table
$ sudo su - postgres
$ psql -c "CREATE TABLE public.stig_audit_example(id INT, name TEXT, password TEXT);"
##### Define Auditing Role
As PostgreSQL superuser (such as postgres), add the following to postgresql.conf or any included configuration files.
$ sudo su - postgres
$ vi ${PGDATA?}/postgresql.conf
Add the following parameters (or edit existing parameters):
pgaudit.role = 'auditor'
Now, as the system administrator, reload the server with the new configuration:
# SYSTEMD SERVER ONLY
$ sudo systemctl reload postgresql-${PGVER?}
# INITD SERVER ONLY
$ sudo service postgresql-${PGVER?} reload
Next in PostgreSQL create a new role:
postgres=# CREATE ROLE auditor;
postgres=# GRANT select(password) ON public.stig_audit_example TO auditor;
Note: This role is created with NOLOGIN privileges by default.
Now any SELECT on the column password will be logged:
$ sudo su - postgres
$ psql -c "SELECT password FROM public.stig_audit_example;"
$ cat ${PGDATA?}/pg_log/
Lavender hyperlinks in small type off to the right (of CSS
class id
, if you view the page source) point to
globally unique URIs for each document and item. Copy the
link location and paste anywhere you need to talk
unambiguously about these things.
You can obtain data about documents and items in other
formats. Simply provide an HTTP header Accept:
text/turtle
or
Accept: application/rdf+xml
.
Powered by sagemincer