Crunchy Data Postgres 16 Security Technical Implementation Guide
Pick two releases to diff their requirements.
Open a previous version of this STIG.
Supporting documents 13 PDFs
Bundled by DISA alongside this STIG release: overview, revision history, and readme files. Download the full archive or open an individual PDF.
- APPENDIX-A.pdf 133 KB
- APPENDIX-B.pdf 173 KB
- APPENDIX-C.pdf 166 KB
- APPENDIX-D.pdf 135 KB
- APPENDIX-E.pdf 131 KB
- APPENDIX-F.pdf 100 KB
- APPENDIX-G.pdf 136 KB
- APPENDIX-H.pdf 103 KB
- APPENDIX-I.pdf 99 KB
- U_CD_Postgres_16_STIG_V1_Release_Memo.pdf 2,141 KB
- U_CD_Postgres_16_V1R2_Overview.pdf 421 KB
- U_CD_Postgres_16_V1R2_Revision_History.pdf 278 KB
- U_Readme_SRG_and_STIG.pdf 279 KB
Digest of Updates +1 −1 ✎ 1
Comparison against the immediately-prior release (V1R1). Rule matching uses the Group Vuln ID. Content-change detection compares the rule’s description, check, and fix text after stripping inline markup — cosmetic-only edits aren’t flagged.
Added rules 1
- V-283674 High PostgreSQL products must be a version supported by the vendor.
Removed rules 1
- V-261937 High PostgreSQL products must be a version supported by the vendor.
Content changes 1
- V-261896 High descriptioncheckfix PostgreSQL must use NIST FIPS 140-2/140-3 validated cryptographic modules for cryptographic operations.
- RMF Control
- AC-10
- Severity
- M
- CCI
- CCI-000054
- Version
- CD16-00-000100
- Vuln IDs
-
- V-261857
- Rule IDs
-
- SV-261857r1000976_rule
Checks: C-65711r1000976_chk
To check the total amount of connections allowed by the database, as the database administrator, run the following SQL: $ sudo su - postgres $ psql -c "SHOW max_connections" If the total amount of connections is greater than documented by an organization, this is a finding. To check the amount of connections allowed for each role, as the database administrator, run the following SQL: $ sudo su - postgres $ psql -c "SELECT rolname, rolconnlimit FROM pg_roles WHERE rolname NOT IN ( 'pg_database_owner', 'pg_read_all_data', 'pg_write_all_data', 'pg_monitor', 'pg_read_all_settings', 'pg_read_all_stats', 'pg_stat_scan_tables', 'pg_read_server_files', 'pg_write_server_files', 'pg_execute_server_program', 'pg_signal_backend', 'pg_checkpoint', 'pg_use_reserved_connections', 'pg_create_subscription');" If any roles have more connections configured than documented, this is a finding. A value of "-1" indicates Unlimited and is a finding.
Fix: F-65619r1000575_fix
Note: The following instructions use the PGDATA and PGVER environment variables. Refer to APPENDIX-F for instructions on configuring PGDATA and APPENDIX-H for PGVER. To configure the maximum amount of connections allowed to the database, as the database administrator (shown here as "postgres") change the following in postgresql.conf (the value 10 is an example; set the value to suit local conditions): $ sudo su - postgres $ vi ${PGDATA?}/postgresql.conf max_connections = 10 Restart the database: $ sudo systemctl restart postgresql-${PGVER?} To limit the amount of connections allowed by a specific role, as the database administrator, run the following SQL: $ psql -c "ALTER ROLE <rolname> CONNECTION LIMIT 1";
- RMF Control
- AC-2
- Severity
- H
- CCI
- CCI-000015
- Version
- CD16-00-000200
- Vuln IDs
-
- V-261858
- Rule IDs
-
- SV-261858r1043176_rule
Checks: C-65712r1000577_chk
Note: The following instructions use the PGDATA environment variable. Refer to APPENDIX-F for instructions on configuring PGDATA. If all accounts are authenticated by the organization-level authentication/access mechanism, such as LDAP or Kerberos and not by PostgreSQL, this is not a finding. As the database administrator (shown here as "postgres"), review pg_hba.conf authentication file settings: $ sudo su - postgres $ cat ${PGDATA?}/pg_hba.conf All records must use an auth-method of gss, sspi, ldap, or cert. For details on the specifics of these authentication methods refer to: http://www.postgresql.org/docs/current/static/auth-pg-hba-conf.html. If there are any records with a different auth-method than gss, sspi, ldap, or cert, review the system documentation for justification and approval of these records. If there are any records with a different auth-method than gss, sspi, ldap, or cert, that are not documented and approved, this is a finding.
Fix: F-65620r1000578_fix
Note: The following instructions use the PGDATA environment variable. Refer to APPENDIX-F for instructions on configuring PGDATA. Integrate PostgreSQL security with an organization-level authentication/access mechanism providing account management for all users, groups, roles, and any other principals. As the database administrator (shown here as "postgres"), edit pg_hba.conf authentication file: $ sudo su - postgres $ vi ${PGDATA?}/pg_hba.conf For each PostgreSQL-managed account that is not documented and approved, either transfer it to management by the external mechanism, or document the need for it and obtain approval, as appropriate.
- RMF Control
- AC-3
- Severity
- H
- CCI
- CCI-000213
- Version
- CD16-00-000300
- Vuln IDs
-
- V-261859
- Rule IDs
-
- SV-261859r1137654_rule
Checks: C-65713r1000580_chk
Note: The following instructions use the PGDATA environment variable. Refer to APPENDIX-F for instructions on configuring PGDATA. From the system security plan or equivalent documentation, determine the appropriate permissions on database objects for each kind (group role) of user. If this documentation is missing, this is a finding. As the database administrator (shown here as "postgres"), check the privileges of all roles in the database by running the following SQL: $ sudo su - postgres $ psql -c '\du' Review all roles and their associated privileges. If any roles' privileges exceed those documented, this is a finding. As the database administrator (shown here as "postgres"), check the configured privileges for tables and columns by running the following SQL: $ sudo su - postgres $ psql -c '\dp' Review all access privileges and column access privileges list. If any roles' privileges exceed those documented, this is a finding. As the database administrator (shown here as "postgres"), check the configured authentication settings in pg_hba.conf: $ sudo su - postgres $ cat ${PGDATA?}/pg_hba.conf Review all entries and their associated authentication methods. If any entries do not have their documented authentication requirements, this is a finding.
Fix: F-65621r1000581_fix
Note: The following instructions use the PGDATA environment variable. Refer to APPENDIX-F for instructions on configuring PGDATA. Create and/or maintain documentation of each group role's appropriate permissions on database objects. Implement these permissions in the database and remove any permissions that exceed those documented. The following are examples of how to use role privileges in PostgreSQL to enforce access controls. For a complete list of privileges, refer to the official documentation: https://www.postgresql.org/docs/current/static/sql-createrole.html. #### Roles Example 1 The following example demonstrates how to create an admin role with CREATEDB and CREATEROLE privileges. As the database administrator (shown here as "postgres"), run the following SQL: $ sudo su - postgres $ psql -c "CREATE ROLE admin WITH CREATEDB CREATEROLE" #### Roles Example 2 The following example demonstrates how to create a role with a password that expires and makes the role a member of the "admin" group. As the database administrator (shown here as "postgres"), run the following SQL: $ sudo su - postgres $ psql -c "CREATE ROLE joe LOGIN ENCRYPTED PASSWORD 'stig_2024' VALID UNTIL '2024-09-20' IN ROLE admin" #### Roles Example 3 The following demonstrates how to revoke privileges from a role using REVOKE. As the database administrator (shown here as "postgres"), run the following SQL: $ sudo su - postgres $ psql -c "REVOKE admin FROM joe" #### Roles Example 4 The following demonstrates how to alter privileges in a role using ALTER. As the database administrator (shown here as "postgres"), run the following SQL: $ sudo su - postgres $ psql -c "ALTER ROLE joe NOLOGIN" The following are examples of how to use grant privileges in PostgreSQL to enforce access controls on objects. For a complete list of privileges, refer to the official documentation: https://www.postgresql.org/docs/current/static/sql-grant.html. #### Grant Example 1 The following example demonstrates how to grant INSERT on a table to a role. As the database administrator (shown here as "postgres"), run the following SQL: $ sudo su - postgres $ psql -c "GRANT SELECT ON stig_test TO joe" #### Grant Example 2 The following example demonstrates how to grant ALL PRIVILEGES on a table to a role. As the database administrator (shown here as "postgres"), run the following SQL: $ sudo su - postgres $ psql -c "GRANT ALL PRIVILEGES ON stig_test TO joe" #### Grant Example 3 The following example demonstrates how to grant a role to a role. As the database administrator (shown here as "postgres"), run the following SQL: $ sudo su - postgres $ psql -c "GRANT admin TO joe" #### Revoke Example 1 The following example demonstrates how to revoke access from a role. As the database administrator (shown here as "postgres"), run the following SQL: $ sudo su - postgres $ psql -c "REVOKE admin FROM joe" To change authentication requirements for the database, as the database administrator (shown here as "postgres"), edit pg_hba.conf: $ sudo su - postgres $ vi ${PGDATA?}/pg_hba.conf Edit authentication requirements to the organizational requirements. Refer to the official documentation for the complete list of options for authentication: http://www.postgresql.org/docs/current/static/auth-pg-hba-conf.html. After changes to pg_hba.conf, reload the server: $ sudo systemctl reload postgresql-${PGVER?}
- RMF Control
- AU-10
- Severity
- M
- CCI
- CCI-000166
- Version
- CD16-00-000400
- Vuln IDs
-
- V-261860
- Rule IDs
-
- SV-261860r1000977_rule
Checks: C-65714r1000583_chk
As the database administrator, review the current log_line_prefix settings by running the following SQL: $ sudo su - postgres $ psql -c "SHOW log_line_prefix" If log_line_prefix does not contain at least '< %m %a %u %d %r %p >', this is a finding. Review the current shared_preload_libraries settings by running the following SQL: $ psql -c "SHOW shared_preload_libraries" If shared_preload_libraries does not contain "pgaudit", this is a finding.
Fix: F-65622r1000584_fix
Note: The following instructions use the PGDATA and PGVER environment variables. Refer to APPENDIX-F for instructions on configuring PGDATA and APPENDIX-H for PGVER. Configure the database to supply additional auditing information to protect against a user falsely repudiating having performed organization-defined actions. Using "pgaudit", PostgreSQL can be configured to audit these requests. Refer to supplementary content APPENDIX-B for documentation on installing pgaudit. To ensure logging is enabled, review supplementary content APPENDIX-C for instructions on enabling logging. Modify the configuration of audit logs to include details identifying the individual user: As the database administrator (shown here as "postgres"), edit postgresql.conf: $ sudo su - postgres $ vi ${PGDATA?}/postgresql.conf Extra parameters can be added to the setting log_line_prefix to identify the user: log_line_prefix = '< %m %a %u %d %r %p >' As the system administrator, reload the server with the new configuration: $ sudo systemctl reload postgresql-${PGVER?} Use accounts assigned to individual users. Where the application connects to PostgreSQL using a standard, shared account, ensure it also captures the individual user identification and passes it to PostgreSQL.
- RMF Control
- AU-12
- Severity
- M
- CCI
- CCI-000169
- Version
- CD16-00-000500
- Vuln IDs
-
- V-261861
- Rule IDs
-
- SV-261861r1000588_rule
Checks: C-65715r1000586_chk
Note: The following instructions use the PGLOG environment variables. Refer to supplementary content APPENDIX-I for instructions on configuring PGVER. Check PostgreSQL audit logs to determine whether organization-defined auditable events are being audited by the system. For example, if the organization defines 'CREATE TABLE' as an auditable event, issuing the following command should return a result: $ sudo su - postgres $ psql -c "CREATE TABLE example (id int)" $ grep 'AUDIT:.*,CREATE TABLE.*example' ${PGLOG?}/<latest_log> $ psql -c 'DROP TABLE example;' If organization-defined auditable events are not being audited, this is a finding.
Fix: F-65623r1000587_fix
Configure PostgreSQL to generate audit records for at least the DOD minimum set of events. Using "pgaudit", PostgreSQL can be configured to audit these requests. Refer to supplementary content APPENDIX-B for documentation on installing pgaudit. To ensure logging is enabled, see the instructions in the supplementary content APPENDIX-C.
- RMF Control
- AU-12
- Severity
- M
- CCI
- CCI-000171
- Version
- CD16-00-000600
- Vuln IDs
-
- V-261862
- Rule IDs
-
- SV-261862r1000591_rule
Checks: C-65716r1000589_chk
Note: The following instructions use the PGDATA environment variable. Refer to APPENDIX-F for instructions on configuring PGDATA. Check PostgreSQL settings and documentation to determine whether designated personnel are able to select which auditable events are being audited. As the database administrator (shown here as "postgres"), verify the permissions for PGDATA: $ ls -la ${PGDATA?} If anything in PGDATA is not owned by the database administrator, this is a finding. As the database administrator, run the following SQL: $ sudo su - postgres $ psql -c "\du" Review the role permissions, if any role is listed as superuser but should not have that access, this is a finding.
Fix: F-65624r1000590_fix
Configure PostgreSQL's settings to allow designated personnel to select which auditable events are audited. Using pgaudit allows administrators the flexibility to choose what they log. For an overview of the capabilities of pgaudit, refer to https://github.com/pgaudit/pgaudit. Refer to supplementary content APPENDIX-B for documentation on installing pgaudit. Refer to supplementary content APPENDIX-C for instructions on enabling logging. Only administrators/superuser can change PostgreSQL configurations. Access to the database administrator must be limited to designated personnel only. To ensure that postgresql.conf is owned by the database owner: $ chown postgres:postgres ${PGDATA?}/postgresql.conf $ chmod 600 ${PGDATA?}/postgresql.conf
- RMF Control
- AU-12
- Severity
- M
- CCI
- CCI-000172
- Version
- CD16-00-000700
- Vuln IDs
-
- V-261863
- Rule IDs
-
- SV-261863r1000954_rule
Checks: C-65717r1000592_chk
Note: The following instructions use the PGLOG environment variable. Refer to supplementary content APPENDIX-I for instructions on configuring PGLOG. As the database administrator (shown here as "postgres"), check if pgaudit is enabled by running the following SQL: $ sudo su - postgres $ psql -c "SHOW shared_preload_libraries" If pgaudit is not found in the results, this is a finding. As the database administrator (shown here as "postgres"), list all role memberships for the database: $ sudo su - postgres $ psql -c "\du" Verify the query was logged: $ sudo su - postgres $ cat ${PGLOG?}/<latest_log> This should, as an example, return (among other rows): < 2024-02-01 19:13:38.276 UTC psql postgres postgres [local] 15639 >LOG: duration: 29.932 ms statement: SELECT r.rolname, r.rolsuper, r.rolinherit, r.rolcreaterole, r.rolcreatedb, r.rolcanlogin, r.rolconnlimit, r.rolvaliduntil , r.rolreplication , r.rolbypassrls FROM pg_catalog.pg_roles r WHERE r.rolname !~ '^pg_' ORDER BY 1; If audit records are not produced, this is a finding.
Fix: F-65625r1000954_fix
Note: The following instructions use the PGDATA and PGVER environment variables. Refer to APPENDIX-F for instructions on configuring PGDATA and APPENDIX-H for PGVER. PostgreSQL can be configured to audit these requests using pgaudit. Refer to supplementary content APPENDIX-B for documentation on installing pgaudit. With pgaudit installed the following configurations can be made: $ sudo su - postgres $ vi ${PGDATA?}/postgresql.conf Add the following parameters (or edit existing parameters): pgaudit.log_catalog = 'on' pgaudit.log = 'read' Note: For this requirement the pgaudit.log must contain 'read' however APPENDIX-C suggests setting pgaudit.log='ddl, role, read, write' to fulfill all requirements. As the system administrator, reload the server with the new configuration: $ sudo systemctl reload postgresql-${PGVER?}
- RMF Control
- AU-12
- Severity
- M
- CCI
- CCI-000172
- Version
- CD16-00-000800
- Vuln IDs
-
- V-261864
- Rule IDs
-
- SV-261864r1000597_rule
Checks: C-65718r1000595_chk
Note: The following instructions use the PGLOG environment variables. Refer to supplementary content APPENDIX-I for instructions on configuring PGLOG. As the database administrator (shown here as "postgres"), create a role "bob" by running the following SQL: $ sudo su - postgres $ psql -c "CREATE ROLE bob" Attempt to retrieve information from the pg_authid table: $ psql -c "SET ROLE bob; SELECT * FROM pg_authid" $ psql -c "DROP ROLE bob;" As the database administrator (shown here as "postgres"), verify the event was logged in PGLOG: $ sudo su - postgres $ cat ${PGLOG?}/<latest_log> < 2024-02-13 16:49:58.864 UTC postgres postgres ERROR: > permission denied for relation pg_authid < 2024-02-13 16:49:58.864 UTC postgres postgres STATEMENT: > SELECT * FROM pg_authid If the above steps cannot verify that audit records are produced when PostgreSQL denies retrieval of privileges/permissions/role memberships, this is a finding.
Fix: F-65626r1000596_fix
Configure PostgreSQL to produce audit records when unsuccessful attempts to access privileges occur. All denials are logged if logging is enabled. To ensure logging is enabled, see the instructions in the supplementary content APPENDIX-C.
- RMF Control
- AU-14
- Severity
- M
- CCI
- CCI-001464
- Version
- CD16-00-000900
- Vuln IDs
-
- V-261865
- Rule IDs
-
- SV-261865r1000600_rule
Checks: C-65719r1000598_chk
As the database administrator (shown here as "postgres"), check the current settings by running the following SQL: $ sudo su - postgres $ psql -c "SHOW shared_preload_libraries" If pgaudit is not in the current setting, this is a finding. As the database administrator (shown here as "postgres"), check the current settings by running the following SQL: $ psql -c "SHOW log_destination" If stderr or syslog are not in the current setting, this is a finding.
Fix: F-65627r1000599_fix
Configure PostgreSQL to enable auditing. To ensure logging is enabled, review supplementary content APPENDIX-C for instructions on enabling logging. For session logging, using pgaudit is recommended. For instructions on how to setup pgaudit, refer to supplementary content APPENDIX-B.
- RMF Control
- AU-3
- Severity
- M
- CCI
- CCI-000130
- Version
- CD16-00-001000
- Vuln IDs
-
- V-261866
- Rule IDs
-
- SV-261866r1000603_rule
Checks: C-65720r1000601_chk
As the database administrator (shown here as "postgres"), verify the current log_line_prefix setting: $ sudo su - postgres $ psql -c "SHOW log_line_prefix" Verify that the current settings are appropriate for the organization. The following is what is possible for logged information: # %a = application name # %u = user name # %d = database name # %r = remote host and port # %h = remote host # %p = process ID # %t = timestamp without milliseconds # %m = timestamp with milliseconds # %i = command tag # %e = SQL state # %c = session ID # %l = session line number # %s = session start timestamp # %v = virtual transaction ID # %x = transaction ID (0 if none) # %q = stop here in non-session processes If the audit record does not log events required by the organization, this is a finding. Verify the current settings of log_connections and log_disconnections by running the following SQL: $ psql -c "SHOW log_connections" $ psql -c "SHOW log_disconnections" If either setting is off, this is a finding.
Fix: F-65628r1000602_fix
Note: The following instructions use the PGDATA and PGVER environment variables. Refer to APPENDIX-F for instructions on configuring PGDATA and APPENDIX-H for PGVER. To ensure logging is enabled, see the instructions in the supplementary content APPENDIX-C. If logging is enabled the following configurations must be made to log connections, date/time, username and session identifier. Edit the postgresql.conf file as a privileged user: $ sudo su - postgres $ vi ${PGDATA?}/postgresql.conf Edit the following parameters based on the organization's needs (minimum requirements are as follows): log_connections = on log_disconnections = on log_line_prefix = '< %m %u %d %c: >' As the system administrator, reload the server with the new configuration: $ sudo systemctl reload postgresql-${PGVER?}
- RMF Control
- AU-3
- Severity
- M
- CCI
- CCI-000131
- Version
- CD16-00-001100
- Vuln IDs
-
- V-261867
- Rule IDs
-
- SV-261867r1000955_rule
Checks: C-65721r1000604_chk
As the database administrator (usually postgres), run the following SQL: $ sudo su - postgres $ psql -c "SHOW log_line_prefix" If the query result does not contain "%m", this is a finding.
Fix: F-65629r1000605_fix
Note: The following instructions use the PGDATA and PGVER environment variables. Refer to APPENDIX-F for instructions on configuring PGDATA and APPENDIX-H for PGVER. Logging must be enabled to capture timestamps. To ensure logging is enabled, see the instructions in the supplementary content APPENDIX-C. If logging is enabled, the following configurations must be made to log events with timestamps: As the database administrator (shown here as "postgres"), edit postgresql.conf: $ sudo su - postgres $ vi ${PGDATA?}/postgresql.conf Add %m to log_line_prefix to enable timestamps with milliseconds: log_line_prefix = '< %m >' As the system administrator, reload the server with the new configuration: $ sudo systemctl reload postgresql-${PGVER?}
- RMF Control
- AU-3
- Severity
- M
- CCI
- CCI-000132
- Version
- CD16-00-001200
- Vuln IDs
-
- V-261868
- Rule IDs
-
- SV-261868r1000609_rule
Checks: C-65722r1000607_chk
As the database administrator (shown here as "postgres"), check the current log_line_prefix setting by running the following SQL: $ sudo su - postgres $ psql -c "SHOW log_line_prefix" If log_line_prefix does not contain "%m %u %d %s", this is a finding.
Fix: F-65630r1000608_fix
$ sudo su - postgres $ vi ${PGDATA?}/postgresql.conf Extra parameters can be added to the setting log_line_prefix to log application related information: # %a = application name # %u = user name # %d = database name # %r = remote host and port # %p = process ID # %m = timestamp with milliseconds # %i = command tag # %s = session startup # %e = SQL state For example: log_line_prefix = '< %m %a %u %d %r %p %i %e %s>' As the system administrator, reload the server with the new configuration: $ sudo systemctl reload postgresql-${PGVER?}
- RMF Control
- AU-3
- Severity
- M
- CCI
- CCI-000133
- Version
- CD16-00-001300
- Vuln IDs
-
- V-261869
- Rule IDs
-
- SV-261869r1000956_rule
Checks: C-65723r1000610_chk
Check PostgreSQL settings and existing audit records to verify information specific to the source (origin) of the event is being captured and stored with audit records. As the database administrator (usually postgres) check the current log_line_prefix and log_hostname setting by running the following SQL: $ sudo su - postgres $ psql -c "SHOW log_line_prefix" $ psql -c "SHOW log_hostname" For a complete list of extra information that can be added to log_line_prefix, refer to the official documentation: https://www.postgresql.org/docs/current/static/runtime-config-logging.html#GUC-LOG-LINE-PREFIX. If the current settings do not provide enough information regarding the source of the event, this is a finding.
Fix: F-65631r1000611_fix
Note: The following instructions use the PGDATA and PGVER environment variables. Refer to APPENDIX-F for instructions on configuring PGDATA and APPENDIX-H for PGVER. To ensure logging is enabled, review supplementary content APPENDIX-C for instructions on enabling logging. If logging is enabled, the following configurations can be made to log the source of an event. As the database administrator, edit postgresql.conf: $ sudo su - postgres $ vi ${PGDATA?}/postgresql.conf ###### Log Line Prefix Extra parameters can be added to the setting log_line_prefix to log source of event: # %a = application name # %u = user name # %d = database name # %r = remote host and port # %p = process ID # %m = timestamp with milliseconds For example: log_line_prefix = '< %m %a %u %d %r %p %m >' ###### Log Hostname By default, only IP address is logged. To also log the hostname, the following parameter can also be set in postgresql.conf: log_hostname = on As the system administrator, reload the server with the new configuration: $ sudo systemctl reload postgresql-${PGVER?}
- RMF Control
- AU-3
- Severity
- M
- CCI
- CCI-000134
- Version
- CD16-00-001400
- Vuln IDs
-
- V-261870
- Rule IDs
-
- SV-261870r1000615_rule
Checks: C-65724r1000613_chk
Note: The following instructions use the PGLOG environment variables. Refer to supplementary content APPENDIX-I for instructions on configuring them. As a database administrator (shown here as "postgres"), create a table, insert a value, alter the table and update the table by running the following SQL: CREATE TABLE stig_test(id INT); INSERT INTO stig_test(id) VALUES (0); ALTER TABLE stig_test ADD COLUMN name text; UPDATE stig_test SET id = 1 WHERE id = 0; As a user without access to the stig_test table, run the following SQL: INSERT INTO stig_test(id) VALUES (1); ALTER TABLE stig_test DROP COLUMN name; UPDATE stig_test SET id = 0 WHERE id = 1; The prior SQL should generate errors: ERROR: permission denied for relation stig_test ERROR: must be owner of relation stig_test ERROR: permission denied for relation stig_test As the database administrator, drop the test table by running the following SQL: DROP TABLE stig_test; Verify the errors were logged: $ sudo su - postgres $ cat ${PGLOG?}/<latest_logfile> < 2024-02-23 14:51:31.103 UTC psql postgres postgres 570bf22a.3af2 2024-04-11 14:51:22 EDT [local] >LOG: AUDIT: SESSION,1,1,DDL,CREATE TABLE,,,CREATE TABLE stig_test(id INT);,<none> < 2024-02-23 14:51:44.835 UTC psql postgres postgres 570bf22a.3af2 2024-04-11 14:51:22 EDT [local] >LOG: AUDIT: SESSION,2,1,WRITE,INSERT,,,INSERT INTO stig_test(id) VALUES (0);,<none> < 2024-02-23 14:53:25.805 UTC psql postgres postgres 570bf22a.3af2 2024-04-11 14:51:22 EDT [local] >LOG: AUDIT: SESSION,3,1,DDL,ALTER TABLE,,,ALTER TABLE stig_test ADD COLUMN name text;,<none> < 2024-02-23 14:53:54.381 UTC psql postgres postgres 570bf22a.3af2 2024-04-11 14:51:22 EDT [local] >LOG: AUDIT: SESSION,4,1,WRITE,UPDATE,,,UPDATE stig_test SET id = 1 WHERE id = 0;,<none> < 2024-02-23 14:54:20.832 UTC psql postgres postgres 570bf22a.3af2 2024-04-11 14:51:22 EDT [local] >ERROR: permission denied for relation stig_test < 2024-02-23 14:54:20.832 UTC psql postgres postgres 570bf22a.3af2 2024-04-11 14:51:22 EDT [local] >STATEMENT: INSERT INTO stig_test(id) VALUES (1); < 2024-02-23 14:54:41.032 UTC psql postgres postgres 570bf22a.3af2 2024-04-11 14:51:22 EDT [local] >ERROR: must be owner of relation stig_test < 2024-02-23 14:54:41.032 UTC psql postgres postgres 570bf22a.3af2 2024-04-11 14:51:22 EDT [local] >STATEMENT: ALTER TABLE stig_test DROP COLUMN name; < 2024-02-23 14:54:54.378 UTC psql postgres postgres 570bf22a.3af2 2024-04-11 14:51:22 EDT [local] >ERROR: permission denied for relation stig_test < 2024-02-23 14:54:54.378 UTC psql postgres postgres 570bf22a.3af2 2024-04-11 14:51:22 EDT [local] >STATEMENT: UPDATE stig_test SET id = 0 WHERE id = 1; < 2024-02-23 14:55:23.723 UTC psql postgres postgres 570bf307.3b0a 2024-04-11 14:55:03 EDT [local] >LOG: AUDIT: SESSION,1,1,DDL,DROP TABLE,,,DROP TABLE stig_test;,<none> If audit records exist without the outcome of the event that occurred, this is a finding.
Fix: F-65632r1000614_fix
Using pgaudit, PostgreSQL can be configured to audit various facets of PostgreSQL. Refer to supplementary content APPENDIX-B for documentation on installing pgaudit. All errors, denials, and unsuccessful requests are logged if logging is enabled. Refer to supplementary content APPENDIX-C for documentation on enabling logging. Note: The following instructions use the PGDATA and PGVER environment variables. Refer to APPENDIX-F for instructions on configuring PGDATA and APPENDIX-H for PGVER. With pgaudit and logging enabled, set the configuration settings in postgresql.conf, as the database administrator (shown here as "postgres"), to the following: $ sudo su - postgres $ vi ${PGDATA?}/postgresql.conf pgaudit.log_catalog='on' pgaudit.log_level='log' pgaudit.log_parameter='on' pgaudit.log_statement_once='off' pgaudit.log='ddl, role, read, write' Tune the following logging configurations in postgresql.conf: $ sudo su - postgres $ vi ${PGDATA?}/postgresql.conf log_line_prefix = '< %m %u %d %e: >' log_error_verbosity = default As the system administrator, restart PostgreSQL: $ sudo systemctl reload postgresql-${PGVER?}
- RMF Control
- AU-3
- Severity
- M
- CCI
- CCI-001487
- Version
- CD16-00-001500
- Vuln IDs
-
- V-261871
- Rule IDs
-
- SV-261871r1000618_rule
Checks: C-65725r1000616_chk
Check PostgreSQL settings and existing audit records to verify a username associated with the event is being captured and stored with the audit records. If audit records exist without specific user information, this is a finding. As the database administrator (shown here as "postgres"), verify the current setting of log_line_prefix by running the following SQL: $ sudo su - postgres $ psql -c "SHOW log_line_prefix" If log_line_prefix does not contain %m, %u, %d, %p, %r, %a, this is a finding.
Fix: F-65633r1000617_fix
Note: The following instructions use the PGDATA and PGVER environment variables. Refer to APPENDIX-F for instructions on configuring PGDATA and APPENDIX-H for PGVER. Logging must be enabled to capture the identity of any user/subject or process associated with an event. To ensure logging is enabled, see the instructions in the supplementary content APPENDIX-C. To enable username, database name, process ID, remote host/port and application name in logging, as the database administrator (shown here as "postgres"), edit the following in postgresql.conf: $ sudo su - postgres $ vi ${PGDATA?}/postgresql.conf log_line_prefix = '< %m %u %d %p %r %a >' As the system administrator, reload the server with the new configuration: $ sudo systemctl reload postgresql-${PGVER?}
- RMF Control
- AU-3
- Severity
- M
- CCI
- CCI-000135
- Version
- CD16-00-001600
- Vuln IDs
-
- V-261872
- Rule IDs
-
- SV-261872r1000621_rule
Checks: C-65726r1000619_chk
Note: The following instructions use the PGDATA and PGLOG environment variables. Refer to APPENDIX-F and APPENDIX-I for instructions on configuring them. Review the system documentation to identify what additional information the organization has determined necessary. Check PostgreSQL settings by examining ${PGDATA?}/postgresql.conf to ensure additional auditing is configured and then examine existing audit records in ${PGLOG?}/<latest.log> to verify that all organization-defined additional, more detailed information is in the audit records for audit events identified by type, location, or subject after executing SQL commands that fall under the additional audit classes. If any additional information is defined and is not contained in the audit records, this is a finding.
Fix: F-65634r1000620_fix
Configure PostgreSQL audit settings to include all organization-defined detailed information in the audit records for audit events identified by type, location, or subject. Using pgaudit, PostgreSQL can be configured to audit these requests. Refer to supplementary content APPENDIX-B for documentation on installing pgaudit. To ensure logging is enabled, see the instructions in the supplementary content APPENDIX-C.
- RMF Control
- AU-5
- Severity
- M
- CCI
- CCI-000140
- Version
- CD16-00-001700
- Vuln IDs
-
- V-261873
- Rule IDs
-
- SV-261873r1043188_rule
Checks: C-65727r1000622_chk
If the application owner has determined that the need for system availability outweighs the need for a complete audit trail, this is Not Applicable. Review the procedures, either manually and/or automated, for monitoring the space used by audit trail(s) and for offloading audit records to a centralized log management system. If the procedures do not exist, this is a finding. If the procedures exist, request evidence that they are followed. If the evidence indicates that the procedures are not followed, this is a finding. If the procedures exist, inquire if the system has ever run out of audit trail space in the last two years or since the last system upgrade, whichever is more recent. If it has run out of space in this period, and the procedures have not been updated to compensate, this is a finding.
Fix: F-65635r1000623_fix
Modify PostgreSQL, OS, or third-party logging application settings to alert appropriate personnel when a specific percentage of log storage capacity is reached.
- RMF Control
- AU-5
- Severity
- M
- CCI
- CCI-000140
- Version
- CD16-00-001800
- Vuln IDs
-
- V-261874
- Rule IDs
-
- SV-261874r1043188_rule
Checks: C-65728r1000625_chk
If the Authorizing Official (AO)-approved system documentation states that system availability takes precedence, this requirement is Not Applicable. If an externally managed and monitored partition or logical volume that can be grown dynamically is being used for logging, this is not a finding. If PostgreSQL is auditing to a directory that is not being actively checked for availability of disk space, and if a tool, utility, script, or other mechanism is not being used to ensure sufficient disk space is available for the creation of new audit logs, this is a finding. If a tool, utility, script, or other mechanism is being used to rotate audit logs and oldest logs are not being removed to ensure sufficient space for newest logs or oldest logs are not being replaced by newest logs, this is a finding.
Fix: F-65636r1000626_fix
Establish a process with accompanying tools for monitoring available disk space and ensuring that sufficient disk space is maintained to continue generating audit logs, overwriting the oldest existing records if necessary.
- RMF Control
- AU-9
- Severity
- M
- CCI
- CCI-000162
- Version
- CD16-00-002000
- Vuln IDs
-
- V-261875
- Rule IDs
-
- SV-261875r1000630_rule
Checks: C-65729r1000628_chk
Note: The following instructions use the PGLOG environment variable. Refer to supplementary content APPENDIX-I for instructions on configuring PGLOG. Review locations of audit logs, both internal to the database and database audit logs located at the operating system level. Verify appropriate controls and permissions exist to protect the audit information from unauthorized access. #### syslog Logging If PostgreSQL is configured to use syslog for logging, consult organization location and permissions for syslog log files. #### stderr Logging As the database administrator (shown here as "postgres"), check the current log_file_mode configuration by running the following: Note: Consult the organization's documentation on acceptable log privileges. $ sudo su - postgres $ psql -c "SHOW log_file_mode" If log_file_mode is not 600, this is a finding. Verify the log files have the set permissions in ${PGLOG?}: $ ls -l ${PGLOG?}/ total 32 -rw-------. 1 postgres postgres 0 Apr 8 00:00 postgresql-Fri.log -rw-------. 1 postgres postgres 8288 Apr 11 17:36 postgresql-Mon.log -rw-------. 1 postgres postgres 0 Apr 9 00:00 postgresql-Sat.log -rw-------. 1 postgres postgres 0 Apr 10 00:00 postgresql-Sun.log -rw-------. 1 postgres postgres 16212 Apr 7 17:05 postgresql-Thu.log -rw-------. 1 postgres postgres 1130 Apr 6 17:56 postgresql-Wed.log If logs with 600 permissions do not exist in ${PGLOG?}, this is a finding.
Fix: F-65637r1000629_fix
Note: The following instructions use the PGDATA and PGVER environment variables. Refer to APPENDIX-F for instructions on configuring PGDATA and APPENDIX-H for PGVER. To ensure logging is enabled, see the instructions in the supplementary content APPENDIX-C. #### syslog Logging If PostgreSQL is configured to use syslog for logging, consult organization location and permissions for syslog log files. #### stderr Logging If PostgreSQL is configured to use stderr for logging, permissions of the log files can be set in postgresql.conf. As the database administrator (shown here as "postgres"), edit the following settings of logs in the postgresql.conf file: Note: Consult the organization's documentation on acceptable log privileges. $ sudo su - postgres $ vi ${PGDATA?}/postgresql.conf log_file_mode = 0600 As the system administrator, reload the server with the new configuration: $ sudo systemctl reload postgresql-${PGVER?}
- RMF Control
- AU-9
- Severity
- M
- CCI
- CCI-000163
- Version
- CD16-00-002100
- Vuln IDs
-
- V-261876
- Rule IDs
-
- SV-261876r1000978_rule
Checks: C-65730r1000631_chk
Review locations of audit logs, both internal to the database and database audit logs located at the operating system level. Verify there are appropriate controls and permissions to protect the audit information from unauthorized modification. Note: The following instructions use the PGLOG environment variable. Refer to supplementary content APPENDIX-I for instructions on configuring PGLOG. #### stderr Logging If the PostgreSQL server is configured to use stderr for logging, the logs will be owned by the database owner (usually postgres user) with a default permissions level of 0600. The permissions can be configured in postgresql.conf. To check the permissions for log files in postgresql.conf, as the database owner (shown here as "postgres"), run the following command: $ sudo su - postgres $ psql -c "show log_file_mode;" If the permissions are not 0600, this is a finding. As the database owner (shown here as "postgres"), list the permissions of the logs: $ sudo su - postgres $ ls -la ${PGLOG?} If logs are not owned by the database owner (shown here as "postgres") and are not the same permissions as configured in postgresql.conf, this is a finding. #### syslog Logging If the PostgreSQL server is configured to use syslog for logging, consult the organization syslog setting for permissions and ownership of logs.
Fix: F-65638r1000632_fix
To ensure logging is enabled, see the instructions in the supplementary content APPENDIX-C. Note: The following instructions use the PGDATA environment variable. Refer to APPENDIX-F for instructions on configuring PGDATA and APPENDIX-I for instructions on configuring PGLOG. #### stderr Logging With stderr logging enabled, as the database owner (shown here as "postgres"), set the following parameter in postgresql.conf: $ vi ${PGDATA?}/postgresql.conf log_file_mode = 0600 To change the owner and permissions of the log files, run the following: $ chown postgres:postgres ${PGDATA?}/${PGLOG?} $ chmod 0700 ${PGDATA?}/${PGLOG?} $ chmod 600 ${PGDATA?}/${PGLOG?}/*.log #### syslog Logging If PostgreSQL is configured to use syslog for logging, the log files must be configured to be owned by root with 0600 permissions. $ chown root:root <log directory name>/<log_filename> $ chmod 0700 <log directory name> $ chmod 0600 <log directory name>/*.log
- RMF Control
- AU-9
- Severity
- M
- CCI
- CCI-000164
- Version
- CD16-00-002200
- Vuln IDs
-
- V-261877
- Rule IDs
-
- SV-261877r1000968_rule
Checks: C-65731r1000968_chk
Note: The following instructions use the PGLOG environment variable. Refer to supplementary content APPENDIX-I for instructions on configuring PGLOG. Review locations of audit logs, both internal to the database and database audit logs located at the operating system level. Verify there are appropriate controls and permissions to protect the audit information from unauthorized modification. #### stderr Logging If the PostgreSQL server is configured to use stderr for logging, the logs will be owned by the database administrator (shown here as "postgres") with a default permissions level of 0600. The permissions can be configured in postgresql.conf. To check the permissions for log files, as the database administrator (shown here as "postgres"), run the following command: $ sudo su - postgres $ psql -c "show log_file_mode" If the permissions are not 0600, this is a finding. As the database administrator (shown here as "postgres"), list the permissions of the logs: $ sudo su - postgres $ ls -la ${PGLOG?} If logs are not owned by the database administrator (shown here as "postgres") and are not the same permissions as configured in postgresql.conf, this is a finding. #### syslog Logging If the PostgreSQL server is configured to use syslog for logging, consult organization syslog setting for permissions and ownership of logs.
Fix: F-65639r1000635_fix
To ensure logging is enabled, see the instructions in the supplementary content APPENDIX-C. Note: The following instructions use the PGDATA environment variable. Refer to APPENDIX-F for instructions on configuring PGDATA and APPENDIX-I for instructions on configuring PGLOG. #### stderr Logging With stderr logging enabled, as the database owner (shown here as "postgres"), set the following parameter in postgresql.conf: $ vi ${PGDATA?}/postgresql.conf log_file_mode = 0600 To change the owner and permissions of the log files, run the following: $ chown postgres:postgres ${PGDATA?}/${PGLOG?} $ chmod 0700 ${PGDATA?}/${PGLOG?} $ chmod 600 ${PGDATA?}/${PGLOG?}/*.log #### syslog Logging If PostgreSQL is configured to use syslog for logging, the log files must be configured to be owned by root with 0600 permissions. $ chown root:root <log directory name>/<log_filename> $ chmod 0700 <log directory name> $ chmod 0600 <log directory name>/*.log
- RMF Control
- AU-9
- Severity
- M
- CCI
- CCI-001493
- Version
- CD16-00-002300
- Vuln IDs
-
- V-261878
- Rule IDs
-
- SV-261878r1000958_rule
Checks: C-65732r1000637_chk
Note: The following instructions use the PGDATA and PGVER environment variables. Refer to APPENDIX-F for instructions on configuring PGDATA, APPENDIX-H for PGVER, and APPENDIX-I for PGLOG. Only the database owner and superuser can alter configuration of PostgreSQL. Ensure the PGLOG directory is owned by postgres user and group: $ sudo su - postgres $ ls -la ${PGLOG?} If PGLOG is not owned by the database owner, this is a finding. Ensure the data directory is owned by postgres user and group. $ sudo su - postgres $ ls -la ${PGDATA?} If PGDATA is not owned by the database owner, this is a finding. Ensure the pgaudit installation is owned by root: $ sudo su - postgres $ ls -la /usr/pgsql-${PGVER?}/share/extension/pgaudit* If the pgaudit installation is not owned by root, this is a finding. As the database administrator (shown here as "postgres"), run the following SQL to list all roles and their privileges: $ sudo su - postgres $ psql -x -c "\du" If any role has "superuser" that should not, this is a finding.
Fix: F-65640r1000638_fix
Note: The following instructions use the PGDATA and PGVER environment variables. Refer to APPENDIX-F for instructions on configuring PGDATA, APPENDIX-H for PGVER and APPENDIX-I for PGLOG. If PGLOG or PGDATA are not owned by postgres user and group, configure them as follows: $ sudo chown -R postgres:postgres ${PGDATA?} $ sudo chown -R postgres:postgres ${PGLOG?} If the pgaudit installation is not owned by root user and group, configure it as follows: $ sudo chown -R root:root /usr/pgsql-${PGVER?}/share/extension/pgaudit* To remove superuser from a role, as the database administrator (shown here as "postgres"), run the following SQL: $ sudo su - postgres $ psql -c "ALTER ROLE <role-name> WITH NOSUPERUSER"
- RMF Control
- AU-9
- Severity
- M
- CCI
- CCI-001494
- Version
- CD16-00-002400
- Vuln IDs
-
- V-261879
- Rule IDs
-
- SV-261879r1000960_rule
Checks: C-65733r1000640_chk
Note: The following instructions use the PGDATA environment variable. Refer to APPENDIX-F for instructions on configuring PGDATA. All configurations for auditing and logging can be found in the postgresql.conf configuration file. By default, this file is owned by the database administrator account. To check that the permissions of the postgresql.conf are owned by the database administrator with permissions of 0600, run the following as the database administrator (shown here as "postgres"): $ sudo su - postgres $ ls -la ${PGDATA?} If postgresql.conf is not owned by the database administrator or does not have 0600 permissions, this is a finding. #### stderr Logging To check that logs are created with 0600 permissions, check the following setting: $ sudo su - postgres $ psql -c "SHOW log_file_mode" If permissions are not 0600, this is a finding. #### syslog Logging If PostgreSQL is configured to use syslog, verify that the logs are owned by root and have 0600 permissions. If they are not, this is a finding.
Fix: F-65641r1000641_fix
Note: The following instructions use the PGDATA environment variable. Refer to APPENDIX-F for instructions on configuring PGDATA. Apply or modify access controls and permissions (both within PostgreSQL and in the file system/operating system) to tools used to view or modify audit log data. Tools must be configurable by authorized personnel only. $ sudo su - postgres $ vi ${PGDATA?}/postgresql.conf log_file_mode = 0600 As the database administrator (shown here as "postgres"), change the ownership and permissions of configuration files in PGDATA: $ sudo su - postgres $ chown postgres:postgres ${PGDATA?}/*.conf $ chmod 0600 ${PGDATA?}/*.conf
- RMF Control
- AU-9
- Severity
- M
- CCI
- CCI-001495
- Version
- CD16-00-002500
- Vuln IDs
-
- V-261880
- Rule IDs
-
- SV-261880r1000959_rule
Checks: C-65734r1000643_chk
Note: The following instructions use the PGDATA and PGVER environment variables. Refer to APPENDIX-F for instructions on configuring PGDATA and APPENDIX-H for PGVER. As the database administrator (shown here as "postgres"), verify the permissions of PGDATA: $ sudo su - postgres $ ls -la ${PGDATA?} If PGDATA is not owned by postgres:postgres or if files can be accessed by others, this is a finding. As the system administrator, verify the permissions of pgsql shared objects and compiled binaries: $ ls -la /usr/pgsql-${PGVER?}/bin $ ls -la /usr/pgsql-${PGVER?}/include $ ls -la /usr/pgsql-${PGVER?}/lib $ ls -la /usr/pgsql-${PGVER?}/share If any of these are not owned by root:root, this is a finding.
Fix: F-65642r1000644_fix
Note: The following instructions use the PGDATA and PGVER environment variables. Refer to APPENDIX-F for instructions on configuring PGDATA and APPENDIX-H for PGVER. As the system administrator, change the permissions of PGDATA: $ sudo chown -R postgres:postgres ${PGDATA?} $ sudo chmod 700 ${PGDATA?} As the system administrator, change the permissions of pgsql: $ sudo chown -R root:root /usr/pgsql-${PGVER?}
- RMF Control
- CM-5
- Severity
- M
- CCI
- CCI-001499
- Version
- CD16-00-002600
- Vuln IDs
-
- V-261881
- Rule IDs
-
- SV-261881r1000648_rule
Checks: C-65735r1000646_chk
Note: The following instructions use the PGDATA and PGVER environment variables. Refer to APPENDIX-F for instructions on configuring PGDATA and APPENDIX-H for PGVER. As the database administrator (shown here as "postgres"), check the permissions of configuration files for the database: $ sudo su - postgres $ ls -la ${PGDATA?} If any files are not owned by the database owner or have permissions allowing others to modify (write) configuration files, this is a finding. As the server administrator, check the permissions on the shared libraries for PostgreSQL: $ sudo ls -la /usr/pgsql-${PGVER?} $ sudo ls -la /usr/pgsql-${PGVER?}/bin $ sudo ls -la /usr/pgsql-${PGVER?}/include $ sudo ls -la /usr/pgsql-${PGVER?}/lib $ sudo ls -la /usr/pgsql-${PGVER?}/share If any files are not owned by root or have permissions allowing others to modify (write) configuration files, this is a finding.
Fix: F-65643r1000647_fix
Note: The following instructions use the PGDATA and PGVER environment variables. Refer to APPENDIX-F for instructions on configuring PGDATA and APPENDIX-H for PGVER. As the database administrator (shown here as "postgres"), change the ownership and permissions of configuration files in PGDATA: $ sudo su - postgres $ chown postgres:postgres ${PGDATA?}/postgresql.conf $ chmod 0600 ${PGDATA?}/postgresql.conf As the server administrator, change the ownership and permissions of shared objects in /usr/pgsql-${PGVER?}/*.so $ sudo chown root:root /usr/pgsql-${PGVER?}/lib/*.so $ sudo chmod 0755 /usr/pgsql-${PGVER?}/lib/*.so As the service administrator, change the ownership and permissions of executables in /usr/pgsql-${PGVER?}/bin: $ sudo chown root:root /usr/pgsql-${PGVER?}/bin/* $ sudo chmod 0755 /usr/pgsql-${PGVER?}/bin/*
- RMF Control
- CM-5
- Severity
- H
- CCI
- CCI-001499
- Version
- CD16-00-002700
- Vuln IDs
-
- V-261882
- Rule IDs
-
- SV-261882r1000651_rule
Checks: C-65736r1000649_chk
Review procedures for controlling, granting access to, and tracking use of the PostgreSQL software installation account(s). If access or use of this account is not restricted to the minimum number of personnel required or if unauthorized access to the account has been granted, this is a finding.
Fix: F-65644r1000650_fix
Develop, document, and implement procedures to restrict and track use of the PostgreSQL software installation account(s).
- RMF Control
- CM-5
- Severity
- M
- CCI
- CCI-001499
- Version
- CD16-00-002800
- Vuln IDs
-
- V-261883
- Rule IDs
-
- SV-261883r1000654_rule
Checks: C-65737r1000652_chk
Review the PostgreSQL software library directory and any subdirectories. If any non-PostgreSQL software directories exist on the disk directory, examine or investigate their use. If any of the directories are used by other applications, including third-party applications that use the PostgreSQL, this is a finding. Only applications that are required for the functioning and administration, not use, of the PostgreSQL software library should be located in the same disk directory as the PostgreSQL software libraries. If other applications are located in the same directory as PostgreSQL, this is a finding.
Fix: F-65645r1000653_fix
Install all applications on directories separate from the PostgreSQL software library directory. Relocate any directories or reinstall other application software that currently shares the PostgreSQL software library directory.
- RMF Control
- CM-5
- Severity
- M
- CCI
- CCI-001499
- Version
- CD16-00-002900
- Vuln IDs
-
- V-261884
- Rule IDs
-
- SV-261884r1000657_rule
Checks: C-65738r1000655_chk
Review system documentation to identify accounts authorized to own database objects. Review accounts that own objects in the database(s). If any database objects are found to be owned by users not authorized to own database objects, this is a finding. To check the ownership of objects in the database, as the database administrator, run the following SQL: $ sudo su - postgres $ psql -X -c '\dnS' $ psql -x -c "\dt *.*" $ psql -X -c '\dsS' $ psql -x -c "\dv *.*" $ psql -x -c "\df+ *.*" If any object is not owned by an authorized role for ownership, this is a finding.
Fix: F-65646r1000656_fix
Assign ownership of authorized objects to authorized object owner accounts. #### Schema Owner To create a schema owned by the user "bob", run the following SQL: $ sudo su - postgres $ psql -c "CREATE SCHEMA test AUTHORIZATION bob" To alter the ownership of an existing object to be owned by the user "bob", run the following SQL: $ sudo su - postgres $ psql -c "ALTER SCHEMA test OWNER TO bob"
- RMF Control
- CM-5
- Severity
- M
- CCI
- CCI-001499
- Version
- CD16-00-003000
- Vuln IDs
-
- V-261885
- Rule IDs
-
- SV-261885r1000949_rule
Checks: C-65739r1000658_chk
Note: The following instructions use the PGDATA environment variable. Refer to APPENDIX-F for instructions on configuring PGDATA. As the database administrator (shown here as "postgres"), list all users and their permissions by running the following SQL: $ sudo su - postgres $ psql -c "\dp *.*" Verify that all objects have the correct privileges. If they do not, this is a finding. As the database administrator (shown here as "postgres"), verify the permissions of the database directory on the filesystem: $ ls -la ${PGDATA?} If permissions of the database directory are not limited to an authorized user account, this is a finding.
Fix: F-65647r1000659_fix
As the database administrator, revoke any permissions from a role that are deemed unnecessary by running the following SQL: ALTER ROLE bob NOCREATEDB; ALTER ROLE bob NOCREATEROLE; ALTER ROLE bob NOSUPERUSER; ALTER ROLE bob NOINHERIT; REVOKE SELECT ON some_function FROM bob;
- RMF Control
- CM-7
- Severity
- M
- CCI
- CCI-000381
- Version
- CD16-00-003200
- Vuln IDs
-
- V-261886
- Rule IDs
-
- SV-261886r1000951_rule
Checks: C-65740r1000661_chk
To get a list of all extensions installed, use the following commands: $ sudo su - postgres $ psql -c "select * from pg_extension where extname != 'plpgsql'" If any extensions exist that are not approved, this is a finding.
Fix: F-65648r1000951_fix
To remove extensions, use the following commands: $ sudo su - postgres $ psql -c "DROP EXTENSION <extension_name>" Note: Removal of plpgsql is not recommended.
- RMF Control
- CM-7
- Severity
- M
- CCI
- CCI-000381
- Version
- CD16-00-003300
- Vuln IDs
-
- V-261887
- Rule IDs
-
- SV-261887r1000666_rule
Checks: C-65741r1000664_chk
To list all installed packages, as the system administrator, run the following: # RHEL/CENT 8/9 Systems $ sudo dnf list installed | grep postgres # RHEL/CENT 7 Systems $ sudo yum list installed | grep postgres # Debian Systems $ dpkg --get-selections | grep postgres If any of the packages installed not required, this is a finding.
Fix: F-65649r1000665_fix
To remove any unneeded executables, as the system administrator, run the following: # RHEL/CENT Systems $ sudo yum erase <package_name> # Debian Systems $ sudo apt-get remove <package_name>
- RMF Control
- CM-7
- Severity
- M
- CCI
- CCI-000381
- Version
- CD16-00-003400
- Vuln IDs
-
- V-261888
- Rule IDs
-
- SV-261888r1000669_rule
Checks: C-65742r1000667_chk
PostgreSQL's COPY command can interact with the underlying OS. Only superuser has access to this command. As the database administrator (shown here as "postgres"), run the following SQL to list all roles and their privileges: $ sudo su - postgres $ psql -x -c "\du" If any role has "superuser" that should not, this is a finding. It is possible for an extension to contain code that could access external executables via SQL. To list all installed extensions, as the database administrator (shown here as "postgres"), run the following SQL: $ sudo su - postgres $ psql -x -c "SELECT * FROM pg_available_extensions WHERE installed_version IS NOT NULL" If any installed extensions are not approved, this is a finding.
Fix: F-65650r1000668_fix
To remove superuser from a role, as the database administrator (shown here as "postgres"), run the following SQL: $ sudo su - postgres $ psql -c "ALTER ROLE <role-name> WITH NOSUPERUSER" To remove extensions from PostgreSQL, as the database administrator (shown here as "postgres"), run the following SQL: $ sudo su - postgres $ psql -c "DROP EXTENSION extension_name"
- RMF Control
- CM-7
- Severity
- M
- CCI
- CCI-000382
- Version
- CD16-00-003500
- Vuln IDs
-
- V-261889
- Rule IDs
-
- SV-261889r1043177_rule
Checks: C-65743r1000670_chk
As the database administrator, run the following SQL: $ psql -c "SHOW port" $ psql -c "SHOW listen_addresses" If the currently defined address:port configuration is deemed prohibited, this is a finding.
Fix: F-65651r1000671_fix
Note: The following instructions use the PGDATA and PGVER environment variables. Refer to APPENDIX-F for instructions on configuring PGDATA and APPENDIX-H for PGVER. To change the listening port of the database, as the database administrator, change the following setting in postgresql.conf: $ sudo su - postgres $ vi $PGDATA/postgresql.conf Change the port parameter to the desired port. To change the listening address of the database, as the database administrator, change the following setting in postgresql.conf: listen_addresses = '10.0.0.1, 127.0.0.1' Restart the database: # SYSTEMD SERVER ONLY $ sudo systemctl restart postgresql-${PGVER?} Note: psql uses the port 5432 by default. This can be changed by specifying the port with psql or by setting the PGPORT environment variable: $ psql -p 5432 -c "SHOW port" $ export PGPORT=5432
- RMF Control
- IA-2
- Severity
- M
- CCI
- CCI-000764
- Version
- CD16-00-003600
- Vuln IDs
-
- V-261890
- Rule IDs
-
- SV-261890r1051115_rule
Checks: C-65744r1000673_chk
Review PostgreSQL settings to determine whether organizational users are uniquely identified and authenticated when logging on/connecting to the system. To list all roles in the database, as the database administrator (shown here as "postgres"), run the following SQL: $ sudo su - postgres $ psql -c "\du" If organizational users are not uniquely identified and authenticated, this is a finding. As the database administrator (shown here as "postgres"), verify the current pg_hba.conf authentication settings: $ sudo su - postgres $ cat ${PGDATA?}/pg_hba.conf If every role does not have unique authentication requirements, this is a finding. If accounts are determined to be shared, determine if individuals are first individually authenticated. If individuals are not individually authenticated before using the shared account, this is a finding.
Fix: F-65652r1000674_fix
Note: The following instructions use the PGDATA environment variable. Refer to APPENDIX-F for instructions on configuring PGDATA. Configure PostgreSQL settings to uniquely identify and authenticate all organizational users who log on/connect to the system. To create roles, use the following SQL: CREATE ROLE <role_name> [OPTIONS] For more information on CREATE ROLE, refer to the official documentation: https://www.postgresql.org/docs/current/static/sql-createrole.html. For each role created, the database administrator can specify database authentication by editing pg_hba.conf: $ sudo su - postgres $ vi ${PGDATA?}/pg_hba.conf An example pg_hba entry looks like this: # TYPE DATABASE USER ADDRESS METHOD host test_db bob 192.168.0.0/16 scram-sha-256 For more information on pg_hba.conf, refer to the official documentation: https://www.postgresql.org/docs/current/static/auth-pg-hba-conf.html.
- RMF Control
- IA-5
- Severity
- H
- CCI
- CCI-000196
- Version
- CD16-00-003800
- Vuln IDs
-
- V-261891
- Rule IDs
-
- SV-261891r1000970_rule
Checks: C-65745r1000676_chk
Note: The following instructions use the PGVER environment variables. Refer to supplementary content APPENDIX-H for PGVER. To check if password encryption is enabled, as the database administrator (shown here as "postgres"), run the following SQL: $ sudo su - postgres $ psql -c "SHOW password_encryption" If password_encryption is not "scram-sha-256", this is a finding. To identify if any passwords have been stored without being hashed and salted, as the database administrator (shown here as "postgres"), run the following SQL: $ sudo su - postgres $ psql -x -c "SELECT username, passwd FROM pg_shadow WHERE passwd IS NULL OR passwd NOT LIKE 'SCRAM-SHA-256%';" If any password is in plaintext, this is a finding.
Fix: F-65653r1000970_fix
Note: The following instructions use the PGDATA and PGVER environment variables. Refer to APPENDIX-F for instructions on configuring PGDATA and APPENDIX-H for PGVER. To enable password_encryption, as the database administrator, edit postgresql.conf: $ sudo su - postgres $ vi ${PGDATA?}/postgresql.conf password_encryption = 'scram-sha-256' Institute a policy of not using the "WITH UNENCRYPTED PASSWORD" option with the CREATE ROLE/USER and ALTER ROLE/USER commands. (This option overrides the setting of the password_encryption configuration parameter.) As the system administrator, restart the server with the new configuration: # SYSTEMD SERVER ONLY $ sudo systemctl restart postgresql-${PGVER?}
- RMF Control
- IA-5
- Severity
- H
- CCI
- CCI-000197
- Version
- CD16-00-003900
- Vuln IDs
-
- V-261892
- Rule IDs
-
- SV-261892r1000681_rule
Checks: C-65746r1000679_chk
Note: The following instructions use the PGDATA environment variable. Refer to APPENDIX-F for instructions on configuring PGDATA. As the database administrator (shown here as "postgres"), review the authentication entries in pg_hba.conf: $ sudo su - postgres $ cat ${PGDATA?}/pg_hba.conf If any entries use the auth_method (last column in records) "password" or "md5", this is a finding.
Fix: F-65654r1000680_fix
Note: The following instructions use the PGDATA environment variable. Refer to APPENDIX-F for instructions on configuring PGDATA. As the database administrator (shown here as "postgres"), edit pg_hba.conf authentication file and change all entries of "password" to "scram-sha-256": $ sudo su - postgres $ vi ${PGDATA?}/pg_hba.conf host all all .example.com scram-sha-256
- RMF Control
- IA-5
- Severity
- M
- CCI
- CCI-000185
- Version
- CD16-00-004000
- Vuln IDs
-
- V-261893
- Rule IDs
-
- SV-261893r1000684_rule
Checks: C-65747r1000682_chk
Note: The following instructions use the PGDATA environment variable. Refer to APPENDIX-F for instructions on configuring PGDATA. To verify that a CRL file exists, as the database administrator (shown here as "postgres"), run the following: $ sudo su - postgres $ psql -c "SELECT CASE WHEN length(setting) > 0 THEN CASE WHEN substring(setting, 1, 1) = '/' THEN setting ELSE (SELECT setting FROM pg_settings WHERE name = 'data_directory') || '/' || setting END ELSE '' END AS ssl_crl_file FROM pg_settings WHERE name = 'ssl_crl_file';" If this is not set to a CRL file, this is a finding. Verify the existence of the CRL file by checking the directory from above: $ sudo su - postgres $ ls -ld <ssl_crl_file> If the CRL file does not exist, this is a finding. Verify that hostssl entries in pg_hba.conf have "cert" and "clientcert=verify-ca" enabled: $ sudo su - postgres $ grep '^hostssl.*cert.*clientcert=verify-ca ' ${PGDATA?}/pg_hba.conf If hostssl entries are not returned, this is a finding. If certificates are not being validated by performing RFC 5280-compliant certification path validation, this is a finding.
Fix: F-65655r1000683_fix
Note: The following instructions use the PGDATA and PGVER environment variables. Refer to APPENDIX-F for instructions on configuring PGDATA and APPENDIX-H for PGVER. To configure PostgreSQL to use SSL, refer to supplementary content APPENDIX-G. To generate a Certificate Revocation List, refer to the official Red Hat Documentation: https://access.redhat.com/documentation/en-US/Red_Hat_Update_Infrastructure/2.1/html/Administration_Guide/chap-Red_Hat_Update_Infrastructure-Administration_Guide-Certification_Revocation_List_CRL.html. As the database administrator (shown here as "postgres"), copy the CRL file into the data directory: As the system administrator, copy the CRL file into the PostgreSQL Data Directory: $ sudo cp root.crl ${PGDATA?}/root.crl As the database administrator (shown here as "postgres"), set the ssl_crl_file parameter to the filename of the CRL: $ sudo su - postgres $ vi ${PGDATA?}/postgresql.conf ssl_crl_file = 'root.crl' In pg_hba.conf, require ssl authentication: $ sudo su - postgres $ vi ${PGDATA?}/pg_hba.conf hostssl <database> <user> <address> cert clientcert=verify-ca As the system administrator, reload the server with the new configuration: # SYSTEMD SERVER ONLY $ sudo systemctl reload postgresql-${PGVER?}
- RMF Control
- IA-5
- Severity
- H
- CCI
- CCI-000186
- Version
- CD16-00-004100
- Vuln IDs
-
- V-261894
- Rule IDs
-
- SV-261894r1000687_rule
Checks: C-65748r1000685_chk
As the database administrator (shown here as "postgres"), verify the following settings: $ sudo su - postgres $ psql -c "select name, case when setting = '' then '<undefined>' when substring(setting, 1, 1) = '/' then setting else (select setting from pg_settings where name = 'data_directory') || '/' || setting end as setting from pg_settings where name in ('ssl_ca_file', 'ssl_cert_file', 'ssl_crl_file', 'ssl_key_file');" If the directory in which these files are stored is not protected, this is a finding.
Fix: F-65656r1000686_fix
Note: The following instructions use the PGDATA and PGVER environment variables. Refer to APPENDIX-F for instructions on configuring PGDATA and APPENDIX-H for PGVER. Store all PostgreSQL PKI private keys in a FIPS 140-2-validated cryptographic module. Ensure access to PostgreSQL PKI private keys is restricted to only authenticated and authorized users. PostgreSQL private key(s) can be stored in $PGDATA directory, which is only accessible by the database owner (usually postgres, DBA) user. Do not allow access to this system account to unauthorized users. To put the keys in a different directory, as the database administrator (shown here as "postgres"), set the following settings to a protected directory: $ sudo su - postgres $ vi ${PGDATA?}/postgresql.conf ssl_ca_file = "/some/protected/directory/root.crt" ssl_crl_file = "/some/protected/directory/root.crl" ssl_cert_file = "/some/protected/directory/server.crt" ssl_key_file = "/some/protected/directory/server.key" As the system administrator, restart the server with the new configuration: # SYSTEMD SERVER ONLY $ sudo systemctl restart postgresql-${PGVER?} For more information on configuring PostgreSQL to use SSL, refer to supplementary content APPENDIX-G.
- RMF Control
- IA-5
- Severity
- M
- CCI
- CCI-000187
- Version
- CD16-00-004200
- Vuln IDs
-
- V-261895
- Rule IDs
-
- SV-261895r1000690_rule
Checks: C-65749r1000688_chk
The Common Name (cn) attribute of the certificate will be compared to the requested database username and, if they match, the login will be allowed. To check the cn of the certificate, using openssl, do the following: $ openssl x509 -noout -subject -in /path/to/your/client_cert.file If the cn does not match the users listed in PostgreSQL and no user mapping is used, this is a finding. User name mapping can be used to allow cn to be different from the database username. If User Name Maps are used, run the following as the database administrator (shown here as "postgres"), to get a list of maps used for authentication: $ sudo su - postgres $ grep "map" ${PGDATA?}/pg_hba.conf With the names of the maps used, check those maps against the username mappings in pg_ident.conf: $ sudo su - postgres $ cat ${PGDATA?}/pg_ident.conf If user accounts are not being mapped to authenticated identities, this is a finding. If the cn and the username mapping do not match, this is a finding.
Fix: F-65657r1000689_fix
Configure PostgreSQL to map authenticated identities directly to PostgreSQL user accounts. For information on configuring PostgreSQL to use SSL, refer to supplementary content APPENDIX-G.
- RMF Control
- IA-7
- Severity
- H
- CCI
- CCI-000803
- Version
- CD16-00-004400
- Vuln IDs
-
- V-261896
- Rule IDs
-
- SV-261896r1193213_rule
Checks: C-65750r1193211_chk
Verify FIPS is enabled for the OS. Following are example Linux commands: # sysctl crypto.fips_enabled crypto.fips_enabled = 1 If crypto.fips_enabled = 0, this is a finding. OR $ sudo fips-mode-setup --check FIPS mode is enabled. If FIPS mode is not enabled, this is a finding. Run the following command to check the OpenSSL version: $ openssl -version Note: FIPS-compliant libraries for OpenSSL 1.x.x contain "fips" in the version. If the value of OpenSSL library is not FIPS compliant, this is a finding. If using OpenSSL 3.x, check the providers: openssl list -providers Providers: default name: OpenSSL Default Provider version: 3.2.2 status: active fips name: Red Hat Enterprise Linux 9 - OpenSSL FIPS Provider version: 3.2.2-622cc79c634cbbef status: active If the response does not list a FIPS provider with a status of "active", this is a finding.
Fix: F-65658r1193212_fix
If crypto.fips_enabled = 0 for Red Hat Linux, configure the operating system to implement DOD-approved encryption. To enable strict FIPS compliance, the fips=1 kernel option must be added to the kernel command line during system installation so key generation is done with FIPS-approved algorithms and continuous monitoring tests in place. Enable FIPS mode with the following command: # sudo fips-mode-setup --enable Modify the kernel command line of the current kernel in the "grub.cfg" file by adding the following option to the GRUB_CMDLINE_LINUX key in the "/etc/default/grub" file and then rebuilding the "grub.cfg" file: fips=1 Changes to "/etc/default/grub" require rebuilding the "grub.cfg" file. On BIOS-based machines, use the following command: # sudo grub2-mkconfig -o /boot/grub2/grub.cfg On UEFI-based machines, use the following command: # sudo grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg If /boot or /boot/efi reside on separate partitions, the kernel parameter "boot=<partition of /boot or /boot/efi>" must be added to the kernel command line. Identify a partition by running the df /boot or df /boot/efi command: # sudo df /boot Filesystem 1K-blocks Used Available Use% Mounted on /dev/sda1 495844 53780 416464 12% /boot To ensure the "boot=" configuration option will work even if device naming changes occur between boots, identify the universally unique identifier (UUID) of the partition with the following command: # sudo blkid /dev/sda1 /dev/sda1: UUID="05c000f1-a213-759e-c7a2-f11b7424c797" TYPE="ext4" For the example above, append the following string to the kernel command line: boot=UUID=05c000f1-a213-759e-c7a2-f11b7424c797 Reboot the system for the changes to take effect. More information can be found here: RedHat: https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/security_guide/chap-federal_standards_and_regulations Ubuntu: https://security-certs.docs.ubuntu.com/en/fips For more information on configuring PostgreSQL to use SSL, refer to supplementary content APPENDIX-G.
- RMF Control
- IA-8
- Severity
- M
- CCI
- CCI-000804
- Version
- CD16-00-004500
- Vuln IDs
-
- V-261897
- Rule IDs
-
- SV-261897r1000696_rule
Checks: C-65751r1000694_chk
PostgreSQL uniquely identifies and authenticates PostgreSQL users through the use of DBMS roles. To list all roles in the database, as the database administrator (shown here as "postgres"), run the following SQL: $ sudo su - postgres $ psql -c "\du" If users are not uniquely identified per organizational documentation, this is a finding.
Fix: F-65659r1000695_fix
To drop a role, as the database administrator (shown here as "postgres"), run the following SQL: $ sudo su - postgres $ psql -c "DROP ROLE <role_to_drop>" To create a role, as the database administrator, run the following SQL: $ sudo su - postgres $ psql -c "CREATE ROLE <role name> LOGIN" For the complete list of permissions allowed by roles, refer to the official documentation: https://www.postgresql.org/docs/current/static/sql-createrole.html.
- RMF Control
- SC-2
- Severity
- M
- CCI
- CCI-001082
- Version
- CD16-00-004600
- Vuln IDs
-
- V-261898
- Rule IDs
-
- SV-261898r1137655_rule
Checks: C-65752r1000697_chk
Check PostgreSQL settings and vendor documentation to verify that administrative functionality is separate from user functionality. As the database administrator (shown here as "postgres"), list all roles and permissions for the database: $ sudo su - postgres $ psql -c "\du" If any nonadministrative role has the attribute "Superuser", "Create role", "Create DB" or "Bypass RLS", this is a finding. If administrator and general user functionality are not separated either physically or logically, this is a finding.
Fix: F-65660r1000698_fix
Configure PostgreSQL to separate database administration and general user functionality. Do not grant superuser, create role, create db, or bypass rls role attributes to users that do not require it. To remove privileges, refer to the following example: ALTER ROLE <username> NOSUPERUSER NOCREATEDB NOCREATEROLE NOBYPASSRLS;
- RMF Control
- SC-23
- Severity
- M
- CCI
- CCI-001185
- Version
- CD16-00-004700
- Vuln IDs
-
- V-261899
- Rule IDs
-
- SV-261899r1043179_rule
Checks: C-65753r1000700_chk
As the database administrator (shown here as "postgres"), run the following SQL: $ sudo su - postgres $ psql -h localhost -c "SHOW tcp_keepalives_idle" $ psql -h localhost -c "SHOW tcp_keepalives_interval" $ psql -h localhost -c "SHOW tcp_keepalives_count" $ psql -h localhost -c "SHOW statement_timeout" If these settings are not set to something other than zero, this is a finding.
Fix: F-65661r1000701_fix
Note: The following instructions use the PGDATA and PGVER environment variables. Refer to APPENDIX-F for instructions on configuring PGDATA and APPENDIX-H for PGVER. As the database administrator (shown here as "postgres"), edit postgresql.conf: $ sudo su - postgres $ vi $PGDATA/postgresql.conf Set the following parameters to organizational requirements: statement_timeout = 10000 #milliseconds tcp_keepalives_idle = 10 # seconds tcp_keepalives_interval = 10 # seconds tcp_keepalives_count = 10 As the system administrator, restart the server with the new configuration: $ sudo systemctl restart postgresql-${PGVER?}
- RMF Control
- SC-23
- Severity
- M
- CCI
- CCI-001188
- Version
- CD16-00-004900
- Vuln IDs
-
- V-261900
- Rule IDs
-
- SV-261900r1043181_rule
Checks: C-65754r1000703_chk
To check if PostgreSQL is configured to use ssl, as the database administrator (shown here as "postgres"), run the following SQL: $ sudo su - postgres $ psql -c "SHOW ssl" If this is not set to on, this is a finding.
Fix: F-65662r1000704_fix
Note: The following instructions use the PGDATA and PGVER environment variables. Refer to APPENDIX-F for instructions on configuring PGDATA and APPENDIX-H for PGVER. To configure PostgreSQL to use SSL, as a database owner (shown here as "postgres"), edit postgresql.conf: $ sudo su - postgres $ vi ${PGDATA?}/postgresql.conf Add the following parameter: ssl = on As the system administrator, reload the server with the new configuration: $ sudo systemctl reload postgresql-${PGVER?} For more information on configuring PostgreSQL to use SSL, refer to supplementary content APPENDIX-G. For further SSL configurations, refer to the official documentation: https://www.postgresql.org/docs/current/static/ssl-tcp.html.
- RMF Control
- SC-28
- Severity
- H
- CCI
- CCI-001199
- Version
- CD16-00-005200
- Vuln IDs
-
- V-261901
- Rule IDs
-
- SV-261901r1000708_rule
Checks: C-65755r1000706_chk
If the application owner and Authorizing Official (AO) have determined that encryption of data at rest is NOT required, this is not a finding. One possible way to encrypt data within PostgreSQL is to use the pgcrypto extension. To check if pgcrypto is installed on PostgreSQL, as a database administrator (shown here as "postgres"), run the following command: $ sudo su - postgres $ psql -c "SELECT * FROM pg_available_extensions where name='pgcrypto'" If data in the database requires encryption and pgcrypto is not available, this is a finding. If disk or filesystem requires encryption, ask the system owner, database administrator (DBA), and system administrator (SA) to demonstrate the use of disk-level encryption. If this is required and is not found, this is a finding. If controls do not exist or are not enabled, this is a finding.
Fix: F-65663r1000707_fix
Apply appropriate controls to protect the confidentiality and integrity of data at rest in the database. The pgcrypto module provides cryptographic functions for PostgreSQL. Refer to supplementary content APPENDIX-E for documentation on installing pgcrypto. With pgcrypto installed, it is possible to insert encrypted data into the database: INSERT INTO accounts(username, password) VALUES ('bob', crypt('a_secure_password', gen_salt('xdes')));
- RMF Control
- SC-3
- Severity
- M
- CCI
- CCI-001084
- Version
- CD16-00-005300
- Vuln IDs
-
- V-261902
- Rule IDs
-
- SV-261902r1000711_rule
Checks: C-65756r1000709_chk
Check PostgreSQL settings to determine whether objects or code implementing security functionality are located in a separate security domain, such as a separate database or schema created specifically for security functionality. By default, all objects in pg_catalog and information_schema are owned by the database administrator. To check the access controls for those schemas, as the database administrator (shown here as "postgres"), run the following commands to review the access privileges granted on the data dictionary and security tables, views, sequences, functions and trigger procedures: $ sudo su - postgres $ psql -x -c "\dp pg_catalog.*" $ psql -x -c "\dp information_schema.*" Repeat the \dp statements for any additional schemas that contain locally defined security objects. Repeat using \df+*.* to review ownership of PostgreSQL functions: $ sudo su - postgres $ psql -x -c "\df+ pg_catalog.*" $ psql -x -c "\df+ information_schema.*" Refer to the PostgreSQL online documentation for GRANT for help in interpreting the Access Privileges column in the output from \du. Note that an entry starting with an equals sign indicates privileges granted to Public (all users). By default, most of the tables and views in the pg_catalog and information_schema schemas can be read by Public. If any user besides the database administrator(s) is listed in access privileges and not documented, this is a finding. If security-related database objects or code are not kept separate, this is a finding.
Fix: F-65664r1000710_fix
Do not locate security-related database objects with application tables or schema. Review any site-specific applications security modules built into the database: determine what schema they are located in and take appropriate action. Do not grant access to pg_catalog or information_schema to anyone but the database administrator(s). Access to the database administrator account(s) must not be granted to anyone without official approval.
- RMF Control
- SC-4
- Severity
- M
- CCI
- CCI-001090
- Version
- CD16-00-005400
- Vuln IDs
-
- V-261903
- Rule IDs
-
- SV-261903r1137656_rule
Checks: C-65757r1000712_chk
Review the procedures for the refreshing of development/test data from production. Review any scripts or code that exists for the movement of production data to development/test systems, or to any other location or for any other purpose. Verify that copies of production data are not left in unprotected locations. If the code that exists for data movement does not comply with the organization-defined data transfer policy and/or fails to remove any copies of production data from unprotected locations, this is a finding.
Fix: F-65665r1000713_fix
Modify any code used for moving data from production to development/test systems to comply with the organization-defined data transfer policy, and to ensure copies of production data are not left in unsecured locations.
- RMF Control
- SC-4
- Severity
- M
- CCI
- CCI-001090
- Version
- CD16-00-005600
- Vuln IDs
-
- V-261904
- Rule IDs
-
- SV-261904r1137658_rule
Checks: C-65758r1000715_chk
Note: The following instructions use the PGDATA environment variable. Refer to APPENDIX-F for instructions on configuring PGDATA. Review the permissions granted to users by the operating system/file system on the database files, database log files and database backup files. To verify that all files are owned by the database administrator and have the correct permissions, run the following as the database administrator (shown here as "postgres"): $ sudo su - postgres $ ls -lR ${PGDATA?} If any files are not owned by the database administrator or allow anyone but the database administrator to read/write/execute, this is a finding. If any user/role that is not an authorized system administrator with a need-to-know or database administrator with a need-to-know, or a system account for running PostgreSQL processes, is permitted to read/view any of these files, this is a finding.
Fix: F-65666r1000716_fix
Note: The following instructions use the PGDATA environment variable. Refer to APPENDIX-F for instructions on configuring PGDATA. Configure the permissions granted by the operating system/file system on the database files, database log files, and database backup files so that only relevant system accounts and authorized system administrators and database administrators with a need to know are permitted to read/view these files. Any files (for example: extra configuration files) created in ${PGDATA?} must be owned by the database administrator, with only owner permissions to read, write, and execute.
- RMF Control
- SI-10
- Severity
- M
- CCI
- CCI-001310
- Version
- CD16-00-005700
- Vuln IDs
-
- V-261905
- Rule IDs
-
- SV-261905r1000720_rule
Checks: C-65759r1000718_chk
Review PostgreSQL code (trigger procedures, functions), application code, settings, column and field definitions, and constraints to determine whether the database is protected against invalid input. If code exists that allows invalid data to be acted upon or input into the database, this is a finding. If column/field definitions do not exist in the database, this is a finding. If columns/fields do not contain constraints and validity checking where required, this is a finding. Where a column/field is noted in the system documentation as necessarily free-form, even though its name and context suggest that it should be strongly typed and constrained, the absence of these protections is not a finding. Where a column/field is clearly identified by name, caption or context as Notes, Comments, Description, Text, etc., the absence of these protections is not a finding. Check application code that interacts with PostgreSQL for the use of prepared statements. If prepared statements are not used, this is a finding.
Fix: F-65667r1000719_fix
Modify database code to properly validate data before it is put into the database or acted upon by the database. Modify the database to contain constraints and validity checking on database columns and tables that require them for data integrity. Use prepared statements when taking user input. Do not allow general users direct console access to PostgreSQL.
- RMF Control
- SI-10
- Severity
- M
- CCI
- CCI-001310
- Version
- CD16-00-005800
- Vuln IDs
-
- V-261906
- Rule IDs
-
- SV-261906r1000979_rule
Checks: C-65760r1000721_chk
Review PostgreSQL source code (trigger procedures, functions) and application source code, to identify cases of dynamic code execution. Any user input should be handled through prepared statements. If dynamic code execution is employed in circumstances where the objective could practically be satisfied by static execution with strongly typed parameters, this is a finding.
Fix: F-65668r1000722_fix
Where dynamic code execution is employed in circumstances where the objective could practically be satisfied by static execution with strongly typed parameters, modify the code to do so.
- RMF Control
- SI-10
- Severity
- M
- CCI
- CCI-001310
- Version
- CD16-00-005900
- Vuln IDs
-
- V-261907
- Rule IDs
-
- SV-261907r1000726_rule
Checks: C-65761r1000724_chk
Review PostgreSQL source code (trigger procedures, functions) and application source code to identify cases of dynamic code execution. If dynamic code execution is employed without protective measures against code injection, this is a finding.
Fix: F-65669r1000725_fix
Where dynamic code execution is used, modify the code to implement protections against code injection (i.e., prepared statements).
- RMF Control
- SI-11
- Severity
- M
- CCI
- CCI-001312
- Version
- CD16-00-006000
- Vuln IDs
-
- V-261908
- Rule IDs
-
- SV-261908r1000729_rule
Checks: C-65762r1000727_chk
To check the level of detail for errors exposed to clients, as the DBA (shown here as "postgres"), run the following: $ sudo su - postgres $ psql -c "SHOW client_min_messages;" If client_min_messages is not set to error, this is a finding.
Fix: F-65670r1000728_fix
Note: The following instructions use the PGDATA and PGVER environment variables. Refer to APPENDIX-F for instructions on configuring PGDATA and APPENDIX-H for PGVER. As the database administrator, edit "postgresql.conf": $ sudo su - postgres $ vi $PGDATA/postgresql.conf Change the client_min_messages parameter to be "error": client_min_messages = error Reload the server with the new configuration (this just reloads settings currently in memory; it will not cause an interruption): $ sudo systemctl reload postgresql-${PGVER?}
- RMF Control
- SI-11
- Severity
- M
- CCI
- CCI-001314
- Version
- CD16-00-006100
- Vuln IDs
-
- V-261909
- Rule IDs
-
- SV-261909r1000980_rule
Checks: C-65763r1000972_chk
Note: The following instructions use the PGDATA and PGLOG environment variables. Refer to APPENDIX-F for instructions on configuring PGDATA and APPENDIX-I for instructions on configuring PGLOG. Check PostgreSQL settings and custom database code to determine if detailed error messages are ever displayed to unauthorized individuals. To check the level of detail for errors exposed to clients, as the DBA (shown here as "postgres"), run the following: $ sudo su - postgres $ psql -c "SHOW client_min_messages;" If client_min_messages is not set to error, this is a finding. If detailed error messages are displayed to individuals not authorized to view them, this is a finding. #### stderr Logging Logs may contain detailed information and should only be accessible by the database owner. As the database administrator, verify the following settings of logs. Note: Consult the organization's documentation on acceptable log privileges. $ sudo su - postgres $ psql -c "SHOW log_file_mode;" Verify the log files have the set configurations. $ ls -l ${PGLOG?} total 32 -rw-------. 1 postgres postgres 0 Apr 8 00:00 postgresql-Fri.log -rw-------. 1 postgres postgres 8288 Apr 11 17:36 postgresql-Mon.log -rw-------. 1 postgres postgres 0 Apr 9 00:00 postgresql-Sat.log -rw-------. 1 postgres postgres 0 Apr 10 00:00 postgresql-Sun.log -rw-------. 1 postgres postgres 16212 Apr 7 17:05 postgresql-Thu.log -rw-------. 1 postgres postgres 1130 Apr 6 17:56 postgresql-Wed.log If logs are not owned by the database administrator or have permissions that are not 0600, this is a finding. #### syslog Logging If PostgreSQL is configured to use syslog for logging, consult organization location and permissions for syslog log files. If the logs are not owned by root or have permissions that are not 0600, this is a finding.
Fix: F-65671r1000731_fix
Note: The following instructions use the PGDATA environment variable. Refer to APPENDIX-F for instructions on configuring PGDATA. To set the level of detail for error messages exposed to clients, as the DBA (shown here as "postgres"), run the following commands: $ sudo su - postgres $ vi ${PGDATA?}/postgresql.conf client_min_messages = error
- RMF Control
- AC-12
- Severity
- M
- CCI
- CCI-002361
- Version
- CD16-00-006200
- Vuln IDs
-
- V-261910
- Rule IDs
-
- SV-261910r1043182_rule
Checks: C-65764r1000733_chk
Review system documentation to obtain the organization's definition of circumstances requiring automatic session termination. If the documentation explicitly states that such termination is not required or is prohibited, this is not a finding. If the documentation requires automatic session termination, but PostgreSQL is not configured accordingly, this is a finding.
Fix: F-65672r1000734_fix
Configure PostgreSQL to automatically terminate a user session after organization-defined conditions or trigger events requiring session termination. Examples follow. ### Change a role to nologin and disconnect the user ALTER ROLE '<username>' NOLOGIN; SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE usename='<usename>'; ### Disconnecting users during a specific time range Refer to supplementary content APPENDIX-A for a bash script for this example. The script found in APPENDIX-A using the -l command can disable all users with rolcanlogin=t from logging in. The script keeps track of who it disables in a .restore_login file. After the specified time is over, the same script can be run with the -r command to restore all login connections. This script would be added to a cron job: # lock at 5 am every day of the week, month, year at the 0 minute mark. 0 5 * * * postgres /var/lib/pgsql/no_login.sh -d postgres -l # restore at 5 pm every day of the week, month, year at the 0 minute mark. 0 17 * * * postgres /var/lib/pgsql/no_login.sh -d postgres -r
- RMF Control
- AC-16
- Severity
- M
- CCI
- CCI-002262
- Version
- CD16-00-006400
- Vuln IDs
-
- V-261911
- Rule IDs
-
- SV-261911r1138540_rule
Checks: C-65765r1000736_chk
If security labeling is not required, this is not a finding. As the database administrator (shown here as "postgres"), run the following SQL against each table that requires security labels: $ sudo su - postgres $ psql -c "\d+ <schema_name>.<table_name>" If security labeling is required and the results of the SQL above do not show a policy attached to the table, this is a finding. If security labeling is required and not implemented according to the system documentation, such as SSP, this is a finding. If security labeling requirements have been specified, but the security labeling is not implemented or does not reliably maintain labels on information in storage, this is a finding.
Fix: F-65673r1000737_fix
In addition to the SQL-standard privilege system available through GRANT, tables can have row security policies that restrict, on a per-user basis, which rows can be returned by normal queries or inserted, updated, or deleted by data modification commands. This feature is also known as Row-Level Security (RLS). RLS policies can be very different depending on their use case. For one example of using RLS for Security Labels, refer to supplementary content APPENDIX-D.
- RMF Control
- AC-16
- Severity
- M
- CCI
- CCI-002263
- Version
- CD16-00-006500
- Vuln IDs
-
- V-261912
- Rule IDs
-
- SV-261912r1138541_rule
Checks: C-65766r1000739_chk
If security labeling is not required, this is not a finding. As the database administrator (shown here as "postgres"), run the following SQL against each table that requires security labels: $ sudo su - postgres $ psql -c "\d+ <schema_name>.<table_name>" If security labeling requirements have been specified, but the security labeling is not implemented or does not reliably maintain labels on information in process, this is a finding.
Fix: F-65674r1000740_fix
In addition to the SQL-standard privilege system available through GRANT, tables can have row security policies that restrict, on a per-user basis, which rows can be returned by normal queries or inserted, updated, or deleted by data modification commands. This feature is also known as Row-Level Security (RLS). RLS policies can be very different depending on their use case. For one example of using RLS for Security Labels, refer to supplementary content APPENDIX-D.
- RMF Control
- AC-16
- Severity
- M
- CCI
- CCI-002264
- Version
- CD16-00-006600
- Vuln IDs
-
- V-261913
- Rule IDs
-
- SV-261913r1138542_rule
Checks: C-65767r1000742_chk
If security labeling is not required, this is not a finding. As the database administrator (shown here as "postgres"), run the following SQL against each table that requires security labels: $ sudo su - postgres $ psql -c "\d+ <schema_name>.<table_name>" If security labeling is required and the results of the SQL above do not show a policy attached to the table, this is a finding. If security labeling is required and not implemented according to the system documentation, such as SSP, this is a finding. If security labeling requirements have been specified, but the security labeling is not implemented or does not reliably maintain labels on information in storage, this is a finding.
Fix: F-65675r1000743_fix
In addition to the SQL-standard privilege system available through GRANT, tables can have row security policies that restrict, on a per-user basis, which rows can be returned by normal queries or inserted, updated, or deleted by data modification commands. This feature is also known as Row-Level Security (RLS). RLS policies can be very different depending on their use case. For one example of using RLS for Security Labels, refer to supplementary content APPENDIX-D.
- RMF Control
- AC-3
- Severity
- M
- CCI
- CCI-002165
- Version
- CD16-00-006700
- Vuln IDs
-
- V-261914
- Rule IDs
-
- SV-261914r1000747_rule
Checks: C-65768r1000745_chk
Review system documentation to identify the required discretionary access control (DAC). Review the security configuration of the database and PostgreSQL. If applicable, review the security configuration of the application(s) using the database. If the discretionary access control defined in the documentation is not implemented in the security configuration, this is a finding. If any database objects are found to be owned by users not authorized to own database objects, this is a finding. To check the ownership of objects in the database, as the database administrator, run the following: $ sudo su - postgres $ psql -X -c '\dnS' $ psql -x -c "\dt *.*" $ psql -X -c '\dsS' $ psql -x -c "\dv *.*" $ psql -x -c "\df+ *.*" If any role is given privileges to objects it should not have, this is a finding.
Fix: F-65676r1000746_fix
Implement the organization's DAC policy in the security configuration of the database and PostgreSQL, and, if applicable, the security configuration of the application(s) using the database. To GRANT privileges to roles, as the database administrator (shown here as "postgres"), run statements like the following examples: $ sudo su - postgres $ psql -c "CREATE SCHEMA test" $ psql -c "GRANT CREATE ON SCHEMA test TO bob" $ psql -c "CREATE TABLE test.test_table(id INT)" $ psql -c "GRANT SELECT ON TABLE test.test_table TO bob" To REVOKE privileges to roles, as the database administrator (shown here as "postgres"), run statements like the following examples: $ psql -c "REVOKE SELECT ON TABLE test.test_table FROM bob" $ psql -c "REVOKE CREATE ON SCHEMA test FROM bob"
- RMF Control
- AC-6
- Severity
- M
- CCI
- CCI-002235
- Version
- CD16-00-006800
- Vuln IDs
-
- V-261915
- Rule IDs
-
- SV-261915r1000750_rule
Checks: C-65769r1000748_chk
Review the system documentation to obtain the definition of the PostgreSQL functionality considered privileged in the context of the system in question. Review the PostgreSQL security configuration and/or other means used to protect privileged functionality from unauthorized use. If the configuration does not protect all of the actions defined as privileged, this is a finding. If PostgreSQL instance uses procedural languages, such as pl/Python or pl/R, without Authorizing Official (AO) authorization, this is a finding.
Fix: F-65677r1000749_fix
Configure PostgreSQL security to protect all privileged functionality. If pl/R and pl/Python are used, document their intended use, document users that have access to pl/R and pl/Python, as well as their business use case, such as data-analytics or data-mining. Because of the risks associated with using pl/R and pl/Python, their use must have AO risk acceptance. To remove unwanted extensions, use: DROP EXTENSION <extension_name> To remove unwanted privileges from a role, use the REVOKE command. Refer to the PostgreSQL documentation for more details: http://www.postgresql.org/docs/current/static/sql-revoke.html.
- RMF Control
- AC-6
- Severity
- M
- CCI
- CCI-002233
- Version
- CD16-00-006900
- Vuln IDs
-
- V-261916
- Rule IDs
-
- SV-261916r1000981_rule
Checks: C-65770r1000751_chk
Functions in PostgreSQL can be created with the SECURITY DEFINER option. When SECURITY DEFINER functions are executed by a user, said function is run with the privileges of the user who created it. To list all functions that have SECURITY DEFINER, as, the DBA (shown here as "postgres"), run the following SQL: $ sudo su - postgres $ psql -c "SELECT nspname, proname, proargtypes, prosecdef, rolname, proconfig FROM pg_proc p JOIN pg_namespace n ON p.pronamespace = n.oid JOIN pg_authid a ON a.oid = p.proowner WHERE prosecdef OR NOT proconfig IS NULL" In the query results, a prosecdef value of "t" on a row indicates that that function uses privilege elevation. If elevation of PostgreSQL privileges is used but not documented, this is a finding. If elevation of PostgreSQL privileges is documented, but not implemented as described in the documentation, this is a finding. If the privilege-elevation logic can be invoked in ways other than intended, or in contexts other than intended, or by subjects/principals other than intended, this is a finding.
Fix: F-65678r1000752_fix
Determine where, when, how, and by what principals/subjects elevated privilege is needed. To change a SECURITY DEFINER function to SECURITY INVOKER, as the database administrator (shown here as "postgres"), run the following SQL: $ sudo su - postgres $ psql -c "ALTER FUNCTION <function_name> SECURITY INVOKER"
- RMF Control
- AU-3
- Severity
- M
- CCI
- CCI-001844
- Version
- CD16-00-007000
- Vuln IDs
-
- V-261917
- Rule IDs
-
- SV-261917r1000962_rule
Checks: C-65771r1000962_chk
On Unix systems, PostgreSQL can be configured to use stderr, csvlog, and syslog. To send logs to a centralized location, syslog should be used. As the database owner (shown here as "postgres"), ensure PostgreSQL uses syslog by running the following SQL: $ sudo su - postgres $ psql -c "SHOW log_destination" As the database owner (shown here as "postgres"), check to which log facility PostgreSQL is configured by running the following SQL: $ sudo su - postgres $ psql -c "SHOW syslog_facility" Check with the organization to refer to how syslog facilities are defined in their organization. If PostgreSQL audit records are not written directly to or systematically transferred to a centralized log management system, this is a finding.
Fix: F-65679r1000755_fix
Note: The following instructions use the PGDATA and PGVER environment variables. Refer to APPENDIX-F for instructions on configuring PGDATA and APPENDIX-H for PGVER. To ensure logging is enabled, review supplementary content APPENDIX-C for instructions on enabling logging. With logging enabled, as the database owner (shown here as "postgres"), configure the following parameters in postgresql.conf: Note: Consult the organization on how syslog facilities are defined in the syslog daemon configuration. $ sudo su - postgres $ vi ${PGDATA?}/postgresql.conf log_destination = 'syslog' syslog_facility = 'LOCAL0' syslog_ident = 'postgres' As the system administrator, reload the server with the new configuration: $ sudo systemctl reload postgresql-${PGVER?}
- RMF Control
- AU-4
- Severity
- M
- CCI
- CCI-001849
- Version
- CD16-00-007200
- Vuln IDs
-
- V-261918
- Rule IDs
-
- SV-261918r1000759_rule
Checks: C-65772r1000757_chk
Investigate whether there have been any incidents where PostgreSQL ran out of audit log space since the last time the space was allocated or other corrective measures were taken. If there have been incidents where PostgreSQL ran out of audit log space, this is a finding.
Fix: F-65680r1000758_fix
Allocate sufficient audit file/table space to support peak demand.
- RMF Control
- AU-5
- Severity
- M
- CCI
- CCI-001855
- Version
- CD16-00-007300
- Vuln IDs
-
- V-261919
- Rule IDs
-
- SV-261919r1000762_rule
Checks: C-65773r1000760_chk
Review system configuration. If no script or tool is monitoring the partition for the PostgreSQL log directories, this is a finding. If appropriate support staff are not notified immediately upon storage volume utilization reaching 75 percent, this is a finding.
Fix: F-65681r1000761_fix
Note: The following instructions use the PGDATA and PGVER environment variables. Refer to APPENDIX-F for instructions on configuring PGDATA and APPENDIX-H for PGVER. Configure the system to notify appropriate support staff immediately upon storage volume utilization reaching 75 percent. PostgreSQL does not monitor storage; however, it is possible to monitor storage with a script. ##### Example Monitoring Script #!/bin/bash PGDATA=/var/lib/pgsql/${PGVER?}/data CURRENT=$(df ${PGDATA?} | grep / | awk '{ print $5}' | sed 's/%//g') THRESHOLD=75 if [ "$CURRENT" -gt "$THRESHOLD" ] ; then mail -s 'Disk Space Alert' mail@support.com << EOF The data directory volume is almost full. Used: $CURRENT EOF fi Schedule this script in cron to run around the clock.
- RMF Control
- AU-5
- Severity
- M
- CCI
- CCI-001858
- Version
- CD16-00-007400
- Vuln IDs
-
- V-261920
- Rule IDs
-
- SV-261920r1000973_rule
Checks: C-65774r1000973_chk
Review PostgreSQL, OS, or third-party logging software settings to determine whether a real-time alert will be sent to the appropriate personnel when auditing fails for any reason. If real-time alerts are not sent upon auditing failure, this is a finding.
Fix: F-65682r1000764_fix
Configure the system to provide an immediate real-time alert to appropriate support staff when an audit log failure occurs. It is possible to create scripts or implement third-party tools to enable real-time alerting for audit failures in PostgreSQL.
- RMF Control
- AU-8
- Severity
- M
- CCI
- CCI-001890
- Version
- CD16-00-007500
- Vuln IDs
-
- V-261921
- Rule IDs
-
- SV-261921r1000994_rule
Checks: C-65775r1000766_chk
When a PostgreSQL cluster is initialized using initdb, the PostgreSQL cluster will be configured to use the same time zone as the target server. As the database administrator (shown here as "postgres"), check the current log_timezone setting by running the following SQL: $ sudo su - postgres $ psql -c "SHOW log_timezone" log_timezone -------------- UTC (1 row) If log_timezone is not set to the desired time zone, this is a finding.
Fix: F-65683r1000767_fix
Note: The following instructions use the PGDATA and PGVER environment variables. Refer to APPENDIX-F for instructions on configuring PGDATA and APPENDIX-H for PGVER. To change log_timezone in postgresql.conf to use a different time zone for logs, as the database administrator (shown here as "postgres"), run the following: $ sudo su - postgres $ vi ${PGDATA?}/postgresql.conf log_timezone='UTC' Restart the database: $ sudo systemctl reload postgresql-${PGVER?}
- RMF Control
- AU-8
- Severity
- M
- CCI
- CCI-001889
- Version
- CD16-00-007600
- Vuln IDs
-
- V-261922
- Rule IDs
-
- SV-261922r1000771_rule
Checks: C-65776r1000769_chk
Note: The following instructions use the PGDATA environment variable. Refer to APPENDIX-F for instructions on configuring PGDATA and APPENDIX-I for PGLOG. As the database administrator (shown here as "postgres"), verify the current log_line_prefix setting by running the following SQL: $ sudo su - postgres $ psql -c "SHOW log_line_prefix" If log_line_prefix does not contain %m, this is a finding. Check the logs to verify time stamps are being logged: $ sudo su - postgres $ cat ${PGDATA?}/${PGLOG?}/<latest_log> < 2024-02-23 12:53:33.947 EDT postgres postgres 570bd68d.3912 >LOG: connection authorized: user=postgres database=postgres < 2024-02-23 12:53:41.576 EDT postgres postgres 570bd68d.3912 >LOG: AUDIT: SESSION,1,1,DDL,CREATE TABLE,,,CREATE TABLE test_srg(id INT);,<none> < 2024-02-23 12:53:44.372 EDT postgres postgres 570bd68d.3912 >LOG: disconnection: session time: 0:00:10.426 user=postgres database=postgres host=[local] If time stamps are not being logged, this is a finding.
Fix: F-65684r1000770_fix
Note: The following instructions use the PGDATA and PGVER environment variables. Refer to APPENDIX-F for instructions on configuring PGDATA and APPENDIX-H for PGVER. PostgreSQL will not log anything if logging is not enabled. To ensure logging is enabled, see the instructions in the supplementary content APPENDIX-C. If logging is enabled, the following configurations must be made to log events with time stamps: As the database administrator (shown here as "postgres"), edit postgresql.conf: $ sudo su - postgres $ vi ${PGDATA?}/postgresql.conf Add %m to log_line_prefix to enable time stamps with milliseconds: log_line_prefix = '< %m >' As the system administrator, reload the server with the new configuration: $ sudo systemctl reload postgresql-${PGVER?}
- RMF Control
- CM-11
- Severity
- M
- CCI
- CCI-001812
- Version
- CD16-00-007700
- Vuln IDs
-
- V-261923
- Rule IDs
-
- SV-261923r1000993_rule
Checks: C-65777r1000772_chk
If PostgreSQL supports only software development, experimentation and/or developer-level testing (that is, excluding production systems, integration testing, stress testing, and user acceptance testing), this is not a finding. Review PostgreSQL and database security settings with respect to nonadministrative users ability to create, alter, or replace logic modules, to include but not necessarily only stored procedures, functions, triggers, and views. To list the privileges for all tables and schemas, as the database administrator (shown here as "postgres"), run the following: $ sudo su - postgres $ psql -c "\dp" $ psql -c "\dn+" The privileges are as follows: rolename=xxxx -- privileges granted to a role =xxxx -- privileges granted to PUBLIC r -- SELECT ("read") w -- UPDATE ("write") a -- INSERT ("append") d -- DELETE D -- TRUNCATE x -- REFERENCES t -- TRIGGER X -- EXECUTE U -- USAGE C -- CREATE c -- CONNECT T -- TEMPORARY arwdDxt -- ALL PRIVILEGES (for tables, varies for other objects) * -- grant option for preceding privilege /yyyy -- role that granted this privilege If any such permissions exist and are not documented and approved, this is a finding.
Fix: F-65685r1000773_fix
Document and obtain approval for any nonadministrative users who require the ability to create, alter, or replace logic modules. Implement the approved permissions. Revoke any unapproved permissions.
- RMF Control
- CM-5
- Severity
- M
- CCI
- CCI-001813
- Version
- CD16-00-007800
- Vuln IDs
-
- V-261924
- Rule IDs
-
- SV-261924r1000777_rule
Checks: C-65778r1000775_chk
To list all the permissions of individual roles, as the database administrator (shown here as "postgres"), run the following SQL: $ sudo su - postgres $ psql -c "\du" If any role has SUPERUSER that should not, this is a finding. List all the permissions of databases and schemas by running the following SQL: $ sudo su - postgres $ psql -c "\l" $ psql -c "\dn+" If any database or schema has update ("W") or create ("C") privileges and should not, this is a finding.
Fix: F-65686r1000776_fix
Configure PostgreSQL to enforce access restrictions associated with changes to the configuration of PostgreSQL or database(s). Use ALTER ROLE to remove accesses from roles: $ psql -c "ALTER ROLE <role_name> NOSUPERUSER" Use REVOKE to remove privileges from databases and schemas: $ psql -c "REVOKE ALL PRIVILEGES ON <table> FROM <role_name>"
- RMF Control
- CM-5
- Severity
- M
- CCI
- CCI-001814
- Version
- CD16-00-007900
- Vuln IDs
-
- V-261925
- Rule IDs
-
- SV-261925r1000780_rule
Checks: C-65779r1000778_chk
Note: The following instructions use the PGDATA environment variable. Refer to APPENDIX-F for instructions on configuring PGDATA and APPENDIX-I for PGLOG. To verify that system denies are logged when unprivileged users attempt to change database configuration, as the database administrator (shown here as "postgres"), run the following commands: $ sudo su - postgres $ psql Create a role with no privileges, change the current role to that user, and attempt to change a configuration by running the following SQL: CREATE ROLE bob; SET ROLE bob; SET pgaudit.role='test'; RESET ROLE; DROP ROLE bob; Check ${PGLOG?} (use the latest log): $ cat ${PGDATA?}/${PGLOG?}/postgresql-Thu.log < 2024-01-28 17:57:34.092 UTC bob postgres: >ERROR: permission denied to set parameter "pgaudit.role" < 2024-01-28 17:57:34.092 UTC bob postgres: >STATEMENT: SET pgaudit.role='test'; If the denial is not logged, this is a finding. By default PostgreSQL configuration files are owned by the Postgres user and cannot be edited by nonprivileged users: $ ls -la ${PGDATA?} | grep postgresql.conf -rw-------. 1 postgres postgres 21758 Jan 22 10:27 postgresql.conf If postgresql.conf is not owned by the database owner and does not have read and write permissions for the owner, this is a finding.
Fix: F-65687r1000779_fix
Enable logging. All denials are logged by default if logging is enabled. To ensure logging is enabled, see the instructions in the supplementary content APPENDIX-C.
- RMF Control
- CM-7
- Severity
- M
- CCI
- CCI-001762
- Version
- CD16-00-008000
- Vuln IDs
-
- V-261926
- Rule IDs
-
- SV-261926r1000783_rule
Checks: C-65780r1000781_chk
As the database administrator, run the following SQL: $ psql -c "SHOW port" If the currently defined port configuration is deemed prohibited, this is a finding.
Fix: F-65688r1000782_fix
Note: The following instructions use the PGDATA and PGVER environment variables. Refer to APPENDIX-F for instructions on configuring PGDATA and APPENDIX-H for PGVER. To change the listening port of the database, as the database administrator, change the following setting in postgresql.conf: $ sudo su - postgres $ vi $PGDATA/postgresql.conf Change the port parameter to the desired port. Restart the database: $ sudo systemctl restart postgresql-${PGVER?} Note: psql uses the port 5432 by default. This can be changed by specifying the port with psql or by setting the PGPORT environment variable: $ psql -p 5432 -c "SHOW port" $ export PGPORT=5432
- RMF Control
- IA-11
- Severity
- M
- CCI
- CCI-002038
- Version
- CD16-00-008100
- Vuln IDs
-
- V-261927
- Rule IDs
-
- SV-261927r1050788_rule
Checks: C-65781r1000784_chk
Determine all situations where a user must reauthenticate. Check if the mechanisms that handle such situations use the following SQL: To make a single user reauthenticate, the following must be present: SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE user='<username>' To make all users reauthenticate, run the following: SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE user LIKE '%' If the provided SQL does not force reauthentication, this is a finding.
Fix: F-65689r1000785_fix
Modify and/or configure PostgreSQL and related applications and tools so that users are always required to reauthenticate when changing role or escalating privileges. To make a single user reauthenticate, the following must be present: SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE user='<username>' To make all users reauthenticate, the following must be present: SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE user LIKE '%'
- RMF Control
- SC-13
- Severity
- H
- CCI
- CCI-002450
- Version
- CD16-00-008300
- Vuln IDs
-
- V-261928
- Rule IDs
-
- SV-261928r1117186_rule
Checks: C-65782r1000787_chk
If PostgreSQL is deployed in an unclassified environment, this is not applicable. If PostgreSQL is not using NSA-approved cryptography to protect classified information in accordance with applicable federal laws, Executive Orders, directives, policies, regulations, and standards, this is a finding. To check if PostgreSQL is configured to use SSL, as the database administrator (shown here as "postgres"), run the following SQL: $ sudo su - postgres $ psql -c "SHOW ssl" If SSL is off, this is a finding. Consult network administration staff to determine whether the server is protected by NSA-approved encrypting devices. If not, this a finding.
Fix: F-65690r1000788_fix
Note: The following instructions use the PGDATA and PGVER environment variables. Refer to APPENDIX-F for instructions on configuring PGDATA and APPENDIX-H for PGVER. To configure PostgreSQL to use SSL as a database administrator (shown here as "postgres"), edit postgresql.conf: $ sudo su - postgres $ vi ${PGDATA?}/postgresql.conf Add the following parameter: ssl = on As the system administrator, reload the server with the new configuration: $ sudo systemctl reload postgresql-${PGVER?} For more information on configuring PostgreSQL to use SSL, refer to supplementary content APPENDIX-G. Deploy NSA-approved encrypting devices to protect the server on the network.
- RMF Control
- SC-23
- Severity
- M
- CCI
- CCI-002470
- Version
- CD16-00-008400
- Vuln IDs
-
- V-261929
- Rule IDs
-
- SV-261929r1193220_rule
Checks: C-65783r1000790_chk
As the database administrator (shown here as "postgres"), verify the following setting in postgresql.conf: $ sudo su - postgres $ psql -c "SHOW ssl_ca_file" $ psql -c "SHOW ssl_cert_file" If the database is not configured to use only DOD-approved certificates, this is a finding.
Fix: F-65691r1000791_fix
Revoke trust in any certificates not issued by a DOD-approved certificate authority. Configure PostgreSQL to accept only DOD and DOD-approved PKI end-entity certificates. To configure PostgreSQL to accept approved CAs, refer to the official PostgreSQL documentation: http://www.postgresql.org/docs/current/static/ssl-tcp.html For more information on configuring PostgreSQL to use SSL, refer to supplementary content APPENDIX-G.
- RMF Control
- SC-28
- Severity
- M
- CCI
- CCI-002475
- Version
- CD16-00-008500
- Vuln IDs
-
- V-261930
- Rule IDs
-
- SV-261930r1018552_rule
Checks: C-65784r1000793_chk
Review the system documentation to determine whether the organization has defined the information at rest that is to be protected from modification, which must include, at a minimum, PII and classified information. If no information is identified as requiring such protection, this is not a finding. Review the configuration of PostgreSQL, operating system/file system, and additional software as relevant. If any of the information defined as requiring cryptographic protection from modification is not encrypted in a manner that provides the required level of protection, this is a finding. One possible way to encrypt data within PostgreSQL is to use pgcrypto extension. To check if pgcrypto is installed on PostgreSQL, as a database administrator (shown here as "postgres"), run the following command: $ sudo su - postgres $ psql -c "SELECT * FROM pg_available_extensions where name='pgcrypto'" If data in the database requires encryption and pgcrypto is not available, this is a finding. If disk or filesystem requires encryption, ask the system owner, database administrator (DBA), and system administrator (SA) to demonstrate filesystem or disk level encryption. If this is required and is not found, this is a finding.
Fix: F-65692r1000794_fix
Configure PostgreSQL, operating system/file system, and additional software as relevant, to provide the required level of cryptographic protection. The pgcrypto module provides cryptographic functions for PostgreSQL. Refer to supplementary content APPENDIX-E for documentation on installing pgcrypto. With pgcrypto installed, it is possible to insert encrypted data into the database: INSERT INTO accounts(username, password) VALUES ('bob', crypt('mypass', gen_salt('bf', 4));
- RMF Control
- SC-28
- Severity
- M
- CCI
- CCI-002476
- Version
- CD16-00-008600
- Vuln IDs
-
- V-261931
- Rule IDs
-
- SV-261931r1018553_rule
Checks: C-65785r1000796_chk
To check if pgcrypto is installed on PostgreSQL, as a database administrator (shown here as "postgres"), run the following command: $ sudo su - postgres $ psql -c "SELECT * FROM pg_available_extensions where name='pgcrypto'" If data in the database requires encryption and pgcrypto is not available, this is a finding. If a disk or filesystem requires encryption, ask the system owner, database administrator (DBA), and system administrator (SA) to demonstrate the use of filesystem and/or disk-level encryption. If this is required and is not found, this is a finding.
Fix: F-65693r1000797_fix
Configure PostgreSQL, operating system/file system, and additional software as relevant, to provide the required level of cryptographic protection for information requiring cryptographic protection against disclosure. Secure the premises, equipment, and media to provide the required level of physical protection. The pgcrypto module provides cryptographic functions for PostgreSQL. Refer to supplementary content APPENDIX-E for documentation on installing pgcrypto. With pgcrypto installed, it is possible to insert encrypted data into the database: INSERT INTO accounts(username, password) VALUES ('bob', crypt('mypass', gen_salt('bf', 4));
- RMF Control
- SC-8
- Severity
- M
- CCI
- CCI-002420
- Version
- CD16-00-008800
- Vuln IDs
-
- V-261932
- Rule IDs
-
- SV-261932r1000801_rule
Checks: C-65786r1000799_chk
If the data owner does not have a strict requirement for ensuring data integrity and confidentiality is maintained at every step of the data transfer and handling process, this is not a finding. As the database administrator (shown here as "postgres"), verify SSL is enabled by running the following SQL: $ sudo su - postgres $ psql -c "SHOW ssl" If SSL is not enabled, this is a finding. If PostgreSQL does not employ protective measures against unauthorized disclosure and modification during preparation for transmission, this is a finding.
Fix: F-65694r1000800_fix
Note: The following instructions use the PGDATA and PGVER environment variables. Refer to APPENDIX-F for instructions on configuring PGDATA and APPENDIX-H for PGVER. Implement protective measures against unauthorized disclosure and modification during preparation for transmission. To configure PostgreSQL to use SSL, as a database administrator (shown here as "postgres"), edit postgresql.conf: $ sudo su - postgres $ vi ${PGDATA?}/postgresql.conf Add the following parameter: ssl = on As the system administrator, reload the server with the new configuration: $ sudo systemctl reload postgresql-${PGVER?} For more information on configuring PostgreSQL to use SSL, refer to supplementary content APPENDIX-G.
- RMF Control
- SC-8
- Severity
- M
- CCI
- CCI-002422
- Version
- CD16-00-008900
- Vuln IDs
-
- V-261933
- Rule IDs
-
- SV-261933r1000804_rule
Checks: C-65787r1000802_chk
If the data owner does not have a strict requirement for ensuring data integrity and confidentiality is maintained at every step of the data transfer and handling process, this is not a finding. As the database administrator (shown here as "postgres"), verify SSL is enabled in postgresql.conf by running the following SQL: $ sudo su - postgres $ psql -c "SHOW ssl" If SSL is off, this is a finding. If PostgreSQL, associated applications, and infrastructure do not employ protective measures against unauthorized disclosure and modification during reception, this is a finding.
Fix: F-65695r1000803_fix
Implement protective measures against unauthorized disclosure and modification during reception. To configure PostgreSQL to use SSL, refer to supplementary content APPENDIX-G for instructions on enabling SSL.
- RMF Control
- SI-10
- Severity
- M
- CCI
- CCI-002754
- Version
- CD16-00-009000
- Vuln IDs
-
- V-261934
- Rule IDs
-
- SV-261934r1000807_rule
Checks: C-65788r1000805_chk
Review system documentation to determine how input errors from application to PostgreSQL are to be handled in general and if any special handling is defined for specific circumstances. If it does not implement the documented behavior, this is a finding. As the database administrator (shown here as "postgres"), make a small SQL syntax error in psql by running the following: $ sudo su - postgres $ psql -c "CREAT TABLE incorrect_syntax(id INT)" ERROR: syntax error at or near "CREAT" Note: The following instructions use the PGVER and PGLOG environment variables. Refer to supplementary content APPENDIX-H for instructions on configuring PGVER and APPENDIX-I for PGLOG. As the database administrator (shown here as "postgres"), verify the syntax error was logged (change the log file name and part to suit the circumstances): $ sudo su - postgres $ cat ~/${PGVER?}/data/${PGLOG?}/<latest log> 2024-03-30 16:18:10.772 EDT postgres postgres 5706bb87.90dERROR: syntax error at or near "CREAT" at character 1 2024-03-30 16:18:10.772 EDT postgres postgres 5706bb87.90dSTATEMENT: CREAT TABLE incorrect_syntax(id INT); If no matching log entry containing the 'ERROR: syntax error' is present, this is a finding.
Fix: F-65696r1000806_fix
Enable logging. To ensure logging is enabled, see the instructions in the supplementary content APPENDIX-C. All errors and denials are logged if logging is enabled.
- RMF Control
- SI-2
- Severity
- M
- CCI
- CCI-002617
- Version
- CD16-00-009100
- Vuln IDs
-
- V-261935
- Rule IDs
-
- SV-261935r1000810_rule
Checks: C-65789r1000808_chk
To check software installed by packages, as the system administrator, run the following command: $ sudo rpm -qa | grep postgres If multiple versions of postgres are installed but are unused, this is a finding.
Fix: F-65697r1000809_fix
Use package managers (RPM or apt-get) for installing PostgreSQL. Unused software is removed when updated.
- RMF Control
- SI-2
- Severity
- M
- CCI
- CCI-002605
- Version
- CD16-00-009200
- Vuln IDs
-
- V-261936
- Rule IDs
-
- SV-261936r1137667_rule
Checks: C-65790r1000811_chk
If new packages are available for PostgreSQL, they can be reviewed in the package manager appropriate for the server operating system: To list the version of installed PostgreSQL using psql: $ sudo su - postgres $ psql --version To list the current version of software for RPM: $ rpm -qa | grep postgres To list the current version of software for APT: $ apt-cache policy postgres All versions of PostgreSQL are listed here: http://www.postgresql.org/support/versioning/. All security-relevant software updates for PostgreSQL are listed here: http://www.postgresql.org/support/security/. If PostgreSQL is not at the latest version, this is a finding. If PostgreSQL is not at the latest version and the evaluated version has CVEs (IAVAs), then this is a CAT I finding.
Fix: F-65698r1000812_fix
Institute and adhere to policies and procedures to ensure that patches are consistently applied to PostgreSQL within the time allowed.
- RMF Control
- AU-12
- Severity
- M
- CCI
- CCI-000172
- Version
- CD16-00-009400
- Vuln IDs
-
- V-261938
- Rule IDs
-
- SV-261938r1000819_rule
Checks: C-65792r1000817_chk
As the database administrator, verify pgaudit is enabled by running the following SQL: $ sudo su - postgres $ psql -c "SHOW shared_preload_libraries" If the output does not contain pgaudit, this is a finding. Verify that role, read, write, and ddl auditing are enabled: $ psql -c "SHOW pgaudit.log" If the output does not contain role, read, write, and ddl, this is a finding.
Fix: F-65700r1000818_fix
Note: The following instructions use the PGDATA and PGVER environment variables. Refer to APPENDIX-F for instructions on configuring PGDATA and APPENDIX-H for PGVER. PostgreSQL can be configured to audit these requests using pgaudit.. Refer to supplementary content APPENDIX-B for documentation on installing pgaudit. With pgaudit installed, the following configurations can be made: $ sudo su - postgres $ vi ${PGDATA?}/postgresql.conf Add the following parameters (or edit existing parameters): pgaudit.log='ddl, role, read, write' As the system administrator, reload the server with the new configuration: $ sudo systemctl reload postgresql-${PGVER?}
- RMF Control
- AU-12
- Severity
- M
- CCI
- CCI-000172
- Version
- CD16-00-009500
- Vuln IDs
-
- V-261939
- Rule IDs
-
- SV-261939r1000822_rule
Checks: C-65793r1000820_chk
Note: The following instructions use the PGDATA and PGLOG environment variables. Refer to APPENDIX-F for instructions on configuring PGDATA and APPENDIX-I for PGLOG. As the database administrator (shown here as "postgres"), setup a test schema and revoke users privileges from using it by running the following SQL: $ sudo su - postgres $ psql -c "CREATE SCHEMA stig_test_schema AUTHORIZATION postgres" $ psql -c "REVOKE ALL ON SCHEMA stig_test_schema FROM public" $ psql -c "GRANT ALL ON SCHEMA stig_test_schema TO postgres" Create a test table and insert a value into that table for the following checks by running the following SQL: $ psql -c "CREATE TABLE stig_test_schema.stig_test_table(id INT)" $ psql -c "INSERT INTO stig_test_schema.stig_test_table(id) VALUES (0)" #### CREATE Attempt to CREATE a table in the stig_test_schema schema with a role that does not have privileges by running the following SQL: psql -c "CREATE ROLE bob; SET ROLE bob; CREATE TABLE stig_test_schema.test_table(id INT);" ERROR: permission denied for schema stig_test_schema As a database administrator (shown here as "postgres"), verify that the denial was logged: $ sudo su - postgres $ cat ${PGDATA?}/${PGLOG?}/<latest_log> < 2024-03-09 09:55:19.423 UTC postgres 56e0393f.186b postgres: >ERROR: permission denied for schema stig_test_schema at character 14 < 2024-03-09 09:55:19.423 UTC postgres 56e0393f.186b postgres: >STATEMENT: CREATE TABLE stig_test_schema.test_table(id INT); If the denial is not logged, this is a finding. #### INSERT As role bob, attempt to INSERT into the table created earlier, stig_test_table by running the following SQL: $ sudo su - postgres $ psql -c "SET ROLE bob; INSERT INTO stig_test_schema.stig_test_table(id) VALUES (0);" As a database administrator (shown here as "postgres"), verify that the denial was logged: $ sudo su - postgres $ cat ${PGDATA?}/${PGLOG?}/<latest_log> < 2024-03-09 09:58:30.709 UTC postgres 56e0393f.186b postgres: >ERROR: permission denied for schema stig_test_schema at character 13 < 2024-03-09 09:58:30.709 UTC postgres 56e0393f.186b postgres: >STATEMENT: INSERT INTO stig_test_schema.stig_test_table(id) VALUES (0); If the denial is not logged, this is a finding. #### SELECT As role bob, attempt to SELECT from the table created earlier, stig_test_table by running the following SQL: $ sudo su - postgres $ psql -c "SET ROLE bob; SELECT * FROM stig_test_schema.stig_test_table;" As a database administrator (shown here as "postgres"), verify that the denial was logged: $ sudo su - postgres $ cat ${PGDATA?}/${PGLOG?}/<latest_log> < 2024-03-09 09:57:58.327 UTC postgres 56e0393f.186b postgres: >ERROR: permission denied for schema stig_test_schema at character 15 < 2024-03-09 09:57:58.327 UTC postgres 56e0393f.186b postgres: >STATEMENT: SELECT * FROM stig_test_schema.stig_test_table; If the denial is not logged, this is a finding. #### ALTER As role bob, attempt to ALTER the table created earlier, stig_test_table by running the following SQL: $ sudo su - postgres $ psql -c "SET ROLE bob; ALTER TABLE stig_test_schema.stig_test_table ADD COLUMN name TEXT;" As a database administrator (shown here as "postgres"), verify that the denial was logged: $ sudo su - postgres $ cat ${PGDATA?}/${PGLOG?}/<latest_log> < 2024-03-09 10:03:43.765 UTC postgres 56e0393f.186b postgres: >STATEMENT: ALTER TABLE stig_test_schema.stig_test_table ADD COLUMN name TEXT; If the denial is not logged, this is a finding. #### UPDATE As role bob, attempt to UPDATE a row created earlier, stig_test_table by running the following SQL: $ sudo su - postgres $ psql -c "SET ROLE bob; UPDATE stig_test_schema.stig_test_table SET id=1 WHERE id=0;" As a database administrator (shown here as "postgres"), verify that the denial was logged: $ sudo su - postgres $ cat ${PGDATA?}/${PGLOG?}/<latest_log> < 2024-03-09 10:08:27.696 UTC postgres 56e0393f.186b postgres: >ERROR: permission denied for schema stig_test_schema at character 8 < 2024-03-09 10:08:27.696 UTC postgres 56e0393f.186b postgres: >STATEMENT: UPDATE stig_test_schema.stig_test_table SET id=1 WHERE id=0; If the denial is not logged, this is a finding. #### DELETE As role bob, attempt to DELETE a row created earlier, stig_test_table by running the following SQL: $ sudo su - postgres $ psql -c "SET ROLE bob; DELETE FROM stig_test_schema.stig_test_table WHERE id=0;" As a database administrator (shown here as "postgres"), verify that the denial was logged: $ sudo su - postgres $ cat ${PGDATA?}/${PGLOG?}/<latest_log> < 2024-03-09 10:09:29.607 UTC postgres 56e0393f.186b postgres: >ERROR: permission denied for schema stig_test_schema at character 13 < 2024-03-09 10:09:29.607 UTC postgres 56e0393f.186b postgres: >STATEMENT: DELETE FROM stig_test_schema.stig_test_table WHERE id=0; If the denial is not logged, this is a finding. #### PREPARE As role bob, attempt to execute a prepared system using PREPARE by running the following SQL: $ sudo su - postgres $ psql -c "SET ROLE bob; PREPARE stig_test_plan(int) AS SELECT id FROM stig_test_schema.stig_test_table WHERE id=$1;" As a database administrator (shown here as "postgres"), verify that the denial was logged: $ sudo su - postgres $ cat ${PGDATA?}/${PGLOG?}/<latest_log> < 2024-03-09 10:16:22.628 UTC postgres 56e03e02.18e4 postgres: >ERROR: permission denied for schema stig_test_schema at character 46 < 2024-03-09 10:16:22.628 UTC postgres 56e03e02.18e4 postgres: >STATEMENT: PREPARE stig_test_plan(int) AS SELECT id FROM stig_test_schema.stig_test_table WHERE id=$1; If the denial is not logged, this is a finding. #### DROP As role bob, attempt to DROP the table created earlier stig_test_table by running the following SQL: $ sudo su - postgres $ psql -c "SET ROLE bob; DROP TABLE stig_test_schema.stig_test_table;" As a database administrator (shown here as "postgres"), verify that the denial was logged: $ sudo su - postgres $ cat ${PGDATA?}/${PGLOG?}/<latest_log> < 2024-03-09 10:18:55.255 UTC postgres 56e03e02.18e4 postgres: >ERROR: permission denied for schema stig_test_schema < 2024-03-09 10:18:55.255 UTC postgres 56e03e02.18e4 postgres: >STATEMENT: DROP TABLE stig_test_schema.stig_test_table; If the denial is not logged, this is a finding.
Fix: F-65701r1000821_fix
Configure PostgreSQL to produce audit records when unsuccessful attempts to access security objects occur. All denials are logged if logging is enabled. To ensure logging is enabled, see the instructions in the supplementary content APPENDIX-C.
- RMF Control
- AU-12
- Severity
- M
- CCI
- CCI-000172
- Version
- CD16-00-009600
- Vuln IDs
-
- V-261940
- Rule IDs
-
- SV-261940r1000825_rule
Checks: C-65794r1000823_chk
As the database administrator (shown here as "postgres"), run the following SQL: $ sudo su - postgres $ psql -c "SHOW pgaudit.log" If pgaudit.log does not contain, "ddl, write, role", this is a finding.
Fix: F-65702r1000824_fix
Note: The following instructions use the PGDATA and PGVER environment variables. Refer to APPENDIX-F for instructions on configuring PGDATA and APPENDIX-H for PGVER. The DBMS (PostgreSQL) can be configured to audit these requests using pgaudit. Refer to supplementary content APPENDIX-B for documentation on installing pgaudit. With pgaudit installed the following configurations can be made: $ sudo su - postgres $ vi ${PGDATA?}/postgresql.conf Add the following parameters (or edit existing parameters): pgaudit.log = 'ddl, write, role' As the system administrator, reload the server with the new configuration: $ sudo systemctl reload postgresql- ${PGVER?}
- RMF Control
- AU-12
- Severity
- M
- CCI
- CCI-000172
- Version
- CD16-00-009700
- Vuln IDs
-
- V-261941
- Rule IDs
-
- SV-261941r1000828_rule
Checks: C-65795r1000826_chk
As the database administrator (shown here as "postgres"), run the following SQL: $ sudo su - postgres $ psql -c "SHOW pgaudit.log" If pgaudit.log does not contain, "ddl, write, role", this is a finding.
Fix: F-65703r1000827_fix
Note: The following instructions use the PGDATA and PGVER environment variables. Refer to APPENDIX-F for instructions on configuring PGDATA and APPENDIX-H for PGVER. Configure PostgreSQL to produce audit records when unsuccessful attempts to access categories of information occur. All denials are logged if logging is enabled. To ensure logging is enabled, see the instructions in the supplementary content APPENDIX-C. With pgaudit installed the following configurations can be made: $ sudo su - postgres $ vi ${PGDATA?}/postgresql.conf Add the following parameters (or edit existing parameters): pgaudit.log = 'ddl, write, role' As the system administrator, reload the server with the new configuration: $ sudo systemctl reload postgresql-${PGVER?}
- RMF Control
- AU-12
- Severity
- M
- CCI
- CCI-000172
- Version
- CD16-00-009800
- Vuln IDs
-
- V-261942
- Rule IDs
-
- SV-261942r1000831_rule
Checks: C-65796r1000829_chk
Note: The following instructions use the PGDATA and PGLOG environment variables. Refer to APPENDIX-F for instructions on configuring PGDATA and APPENDIX-I for PGLOG. As the database administrator (shown here as "postgres"), create a role by running the following SQL: Change the privileges of another user: $ sudo su - postgres $ psql -c "CREATE ROLE bob" GRANT then REVOKE privileges from the role: $ psql -c "GRANT CONNECT ON DATABASE postgres TO bob" $ psql -c "REVOKE CONNECT ON DATABASE postgres FROM bob" postgres=# REVOKE CONNECT ON DATABASE postgres FROM bob; REVOKE postgres=# GRANT CONNECT ON DATABASE postgres TO bob; GRANT As the database administrator (shown here as "postgres"), verify the events were logged: $ sudo su - postgres $ cat ${PGDATA?}/${PGLOG?}/<latest_log> < 2024-07-13 16:25:21.103 EDT postgres postgres LOG: > AUDIT: SESSION,1,1,ROLE,GRANT,,,GRANT CONNECT ON DATABASE postgres TO bob,<none> < 2024-07-13 16:25:25.520 EDT postgres postgres LOG: > AUDIT: SESSION,1,1,ROLE,REVOKE,,,REVOKE CONNECT ON DATABASE postgres FROM bob,<none> If the above steps cannot verify that audit records are produced when privileges/permissions/role memberships are added, this is a finding.
Fix: F-65704r1000830_fix
Note: The following instructions use the PGDATA and PGVER environment variables. Refer to APPENDIX-F for instructions on configuring PGDATA and APPENDIX-H for PGVER. PostgreSQL can be configured to audit these requests using pgaudit,. Refer to supplementary content APPENDIX-B for documentation on installing pgaudit. With pgaudit installed, the following configurations can be made: $ sudo su - postgres $ vi ${PGDATA?}/postgresql.conf Add the following parameters (or edit existing parameters): pgaudit.log = 'role' As the system administrator, reload the server with the new configuration: $ sudo systemctl reload postgresql-${PGVER?}
- RMF Control
- AU-12
- Severity
- M
- CCI
- CCI-000172
- Version
- CD16-00-009900
- Vuln IDs
-
- V-261943
- Rule IDs
-
- SV-261943r1000834_rule
Checks: C-65797r1000832_chk
Note: The following instructions use the PGDATA and PGLOG environment variables. Refer to APPENDIX-F for instructions on configuring PGDATA and APPENDIX-I for PGLOG. As the database administrator (shown here as "postgres"), create a role "bob" and a test table by running the following SQL: $ sudo su - postgres $ psql -c "CREATE ROLE bob; CREATE TABLE test(id INT);" Set current role to "bob" and attempt to modify privileges: $ psql -c "SET ROLE bob; GRANT ALL PRIVILEGES ON test TO bob;" As the database administrator (shown here as "postgres"), verify the unsuccessful attempt was logged: $ sudo su - postgres $ cat ${PGDATA?}/${PGLOG?}/<latest_log> 2024-07-14 18:12:23.208 EDT postgres postgres ERROR: permission denied for relation test 2024-07-14 18:12:23.208 EDT postgres postgres STATEMENT: GRANT ALL PRIVILEGES ON test TO bob; If audit logs are not generated when unsuccessful attempts to add privileges/permissions occur, this is a finding.
Fix: F-65705r1000833_fix
Configure PostgreSQL to produce audit records when unsuccessful attempts to add privileges occur. All denials are logged by default if logging is enabled. To ensure logging is enabled, review supplementary content APPENDIX-C for instructions on enabling logging.
- RMF Control
- AU-12
- Severity
- M
- CCI
- CCI-000172
- Version
- CD16-00-010000
- Vuln IDs
-
- V-261944
- Rule IDs
-
- SV-261944r1000837_rule
Checks: C-65798r1000835_chk
As the database administrator, verify pgaudit is enabled by running the following SQL: $ sudo su - postgres $ psql -c "SHOW shared_preload_libraries" If the output does not contain pgaudit, this is a finding. Verify that role is enabled: $ psql -c "SHOW pgaudit.log" If the output does not contain role, this is a finding.
Fix: F-65706r1000836_fix
Note: The following instructions use the PGDATA and PGVER environment variables. Refer to APPENDIX-F for instructions on configuring PGDATA and APPENDIX-H for PGVER. PostgreSQL can be configured to audit these requests using pgaudit. Refer to supplementary content APPENDIX-B for documentation on installing pgaudit. With pgaudit installed, the following configurations can be made: $ sudo su - postgres $ vi ${PGDATA?}/postgresql.conf Add the following parameters (or edit existing parameters): pgaudit.log='role' As the system administrator, reload the server with the new configuration: $ sudo systemctl reload postgresql-${PGVER?}
- RMF Control
- AU-12
- Severity
- M
- CCI
- CCI-000172
- Version
- CD16-00-010100
- Vuln IDs
-
- V-261945
- Rule IDs
-
- SV-261945r1000840_rule
Checks: C-65799r1000838_chk
Note: The following instructions use the PGDATA and PGLOG environment variables. Refer to APPENDIX-F for instructions on configuring PGDATA and APPENDIX-I for PGLOG. As the database administrator (shown here as "postgres"), create a role "bob" and a test table by running the following SQL: $ sudo su - postgres $ psql -c "CREATE ROLE bob; CREATE TABLE test(id INT)" Set current role to "bob" and attempt to modify privileges: $ psql -c "SET ROLE bob; GRANT ALL PRIVILEGES ON test TO bob;" $ psql -c "SET ROLE bob; REVOKE ALL PRIVILEGES ON test FROM bob;" As the database administrator (shown here as "postgres"), verify the unsuccessful attempt was logged: $ sudo su - postgres $ cat ${PGDATA?}/${PGLOG?}/<latest_log> 2024-07-14 18:12:23.208 EDT postgres postgres ERROR: permission denied for relation test 2024-07-14 18:12:23.208 EDT postgres postgres STATEMENT: GRANT ALL PRIVILEGES ON test TO bob; 2024-07-14 18:14:52.895 EDT postgres postgres ERROR: permission denied for relation test 2024-07-14 18:14:52.895 EDT postgres postgres STATEMENT: REVOKE ALL PRIVILEGES ON test FROM bob; If audit logs are not generated when unsuccessful attempts to modify privileges/permissions occur, this is a finding.
Fix: F-65707r1000839_fix
Configure PostgreSQL to produce audit records when unsuccessful attempts to modify privileges occur. All denials are logged by default if logging is enabled. To ensure logging is enabled, see the instructions in the supplementary content APPENDIX-C.
- RMF Control
- AU-12
- Severity
- M
- CCI
- CCI-000172
- Version
- CD16-00-010200
- Vuln IDs
-
- V-261946
- Rule IDs
-
- SV-261946r1000843_rule
Checks: C-65800r1000841_chk
As the database administrator, verify pgaudit is enabled by running the following SQL: $ sudo su - postgres $ psql -c "SHOW shared_preload_libraries" If the results does not contain pgaudit, this is a finding. Verify that role, read, write, and ddl auditing are enabled: $ psql -c "SHOW pgaudit.log" If the output does not contain role, read, write, and ddl, this is a finding. Verify that accessing the catalog is audited by running the following SQL: $ psql -c "SHOW pgaudit.log_catalog" If log_catalog is not on, this is a finding.
Fix: F-65708r1000842_fix
Note: The following instructions use the PGDATA and PGVER environment variables. Refer to APPENDIX-F for instructions on configuring PGDATA and APPENDIX-H for PGVER. To ensure logging is enabled, see the instructions in the supplementary content APPENDIX-C. PostgreSQL can be configured to audit these requests using pgaudit. Refer to supplementary content APPENDIX-B for documentation on installing pgaudit. With pgaudit installed, the following configurations can be made: $ sudo su - postgres $ vi ${PGDATA?}/postgresql.conf Add the following parameters (or edit existing parameters): pgaudit.log_catalog = 'on' pgaudit.log='ddl, role, read, write' As the system administrator, reload the server with the new configuration: $ sudo systemctl reload postgresql-${PGVER?}
- RMF Control
- AU-12
- Severity
- M
- CCI
- CCI-000172
- Version
- CD16-00-010300
- Vuln IDs
-
- V-261947
- Rule IDs
-
- SV-261947r1000846_rule
Checks: C-65801r1000844_chk
Note: The following instructions use the PGDATA and PGLOG environment variables. Refer to APPENDIX-F for instructions on configuring PGDATA and APPENDIX-I for PGLOG. As the database administrator (shown here as "postgres"), create a test role by running the following SQL: $ sudo su - postgres $ psql -c "CREATE ROLE bob" To test if audit records are generated from unsuccessful attempts at modifying security objects, run the following SQL: $ sudo su - postgres $ psql -c "SET ROLE bob; UPDATE pg_authid SET rolsuper = 't' WHERE rolname = 'bob';" As the database administrator (shown here as "postgres"), verify the denials were logged: $ sudo su - postgres $ cat ${PGDATA?}/${PGLOG?}/<latest_log> < 2024-03-17 10:34:00.017 EDT bob 56eabf52.b62 postgres: >ERROR: permission denied for relation pg_authid < 2024-03-17 10:34:00.017 EDT bob 56eabf52.b62 postgres: >STATEMENT: UPDATE pg_authid SET rolsuper = 't' WHERE rolname = 'bob'; If denials are not logged, this is a finding.
Fix: F-65709r1000845_fix
Configure PostgreSQL to produce audit records when unsuccessful attempts to modify security objects occur. Unsuccessful attempts to modify security objects can be logged if logging is enabled. To ensure logging is enabled, review supplementary content APPENDIX-C for instructions on enabling logging.
- RMF Control
- AU-12
- Severity
- M
- CCI
- CCI-000172
- Version
- CD16-00-010400
- Vuln IDs
-
- V-261948
- Rule IDs
-
- SV-261948r1000849_rule
Checks: C-65802r1000847_chk
If category tracking is not required in the database, this is not applicable. As the database administrator, verify pgaudit is enabled by running the following SQL: $ sudo su - postgres $ psql -c "SHOW shared_preload_libraries" If the output does not contain pgaudit, this is a finding. Verify that role, read, write, and ddl auditing are enabled: $ psql -c "SHOW pgaudit.log" If the output does not contain role, read, write, and ddl, this is a finding.
Fix: F-65710r1000848_fix
Note: The following instructions use the PGDATA and PGVER environment variables. Refer to APPENDIX-F for instructions on configuring PGDATA and APPENDIX-H for PGVER. To ensure logging is enabled, see the instructions in the supplementary content APPENDIX-C. PostgreSQL can be configured to audit these requests using pgaudit. Refer to supplementary content APPENDIX-B for documentation on installing pgaudit. With pgaudit installed the following configurations can be made: $ sudo su - postgres $ vi ${PGDATA?}/postgresql.conf Add the following parameters (or edit existing parameters): pgaudit.log='ddl, role, read, write' As the system administrator, reload the server with the new configuration: $ sudo systemctl reload postgresql-${PGVER?}
- RMF Control
- AU-12
- Severity
- M
- CCI
- CCI-000172
- Version
- CD16-00-010500
- Vuln IDs
-
- V-261949
- Rule IDs
-
- SV-261949r1000852_rule
Checks: C-65803r1000850_chk
As the database administrator, verify pgaudit is enabled by running the following SQL: $ sudo su - postgres $ psql -c "SHOW shared_preload_libraries" If the output does not contain "pgaudit", this is a finding. Verify that role, read, write, and ddl auditing are enabled: $ psql -c "SHOW pgaudit.log" If the output does not contain role, read, write, and ddl, this is a finding.
Fix: F-65711r1000851_fix
Note: The following instructions use the PGDATA and PGVER environment variables. Refer to APPENDIX-F for instructions on configuring PGDATA and APPENDIX-H for PGVER. Configure PostgreSQL to produce audit records when unsuccessful attempts to modify categories of information occur. To ensure logging is enabled, see the instructions in the supplementary content APPENDIX-C. All denials are logged when logging is enabled. With pgaudit installed the following configurations can be made: $ sudo su - postgres $ vi ${PGDATA?}/postgresql.conf Add the following parameters (or edit existing parameters): pgaudit.log='ddl, role, read, write' As the system administrator, reload the server with the new configuration: $ sudo systemctl reload postgresql-${PGVER?}
- RMF Control
- AU-12
- Severity
- M
- CCI
- CCI-000172
- Version
- CD16-00-010600
- Vuln IDs
-
- V-261950
- Rule IDs
-
- SV-261950r1000855_rule
Checks: C-65804r1000853_chk
As the database administrator, verify pgaudit is enabled by running the following SQL: $ sudo su - postgres $ psql -c "SHOW shared_preload_libraries" If the output does not contain pgaudit, this is a finding. Verify that role, read, write, and ddl auditing are enabled: $ psql -c "SHOW pgaudit.log" If the output does not contain role, read, write, and ddl, this is a finding.
Fix: F-65712r1000854_fix
Note: The following instructions use the PGDATA and PGVER environment variables. Refer to APPENDIX-F for instructions on configuring PGDATA and APPENDIX-H for PGVER. PostgreSQL can be configured to audit these requests using pgaudit. Refer to supplementary content APPENDIX-B for documentation on installing pgaudit. With pgaudit installed, the following configurations can be made: $ sudo su - postgres $ vi ${PGDATA?}/postgresql.conf Add the following parameters (or edit existing parameters): pgaudit.log = 'role' As the system administrator, reload the server with the new configuration: $ sudo systemctl reload postgresql-${PGVER?}
- RMF Control
- AU-12
- Severity
- M
- CCI
- CCI-000172
- Version
- CD16-00-010700
- Vuln IDs
-
- V-261951
- Rule IDs
-
- SV-261951r1000858_rule
Checks: C-65805r1000856_chk
Note: The following instructions use the PGDATA and PGLOG environment variables. Refer to APPENDIX-F for instructions on configuring PGDATA and APPENDIX-I for PGLOG. As the database administrator (shown here as "postgres"), create the roles "joe" and "bob" with LOGIN by running the following SQL: $ sudo su - postgres $ psql -c "CREATE ROLE joe LOGIN" $ psql -c "CREATE ROLE bob LOGIN" Set current role to "bob" and attempt to alter the role "joe": $ psql -c "SET ROLE bob; ALTER ROLE joe NOLOGIN;" As the database administrator (shown here as "postgres"), verify the denials are logged: $ sudo su - postgres $ cat ${PGDATA?}/${PGLOG?}/<latest_log> < 2024-03-17 11:28:10.004 UTC bob 56eacd05.cda postgres: >ERROR: permission denied to alter role < 2024-03-17 11:28:10.004 UTC bob 56eacd05.cda postgres: >STATEMENT: ALTER ROLE joe; If audit logs are not generated when unsuccessful attempts to delete privileges/permissions occur, this is a finding.
Fix: F-65713r1000857_fix
Configure PostgreSQL to produce audit records when unsuccessful attempts to delete privileges occur. All denials are logged if logging is enabled. To ensure logging is enabled, review supplementary content APPENDIX-C for instructions on enabling logging.
- RMF Control
- AU-12
- Severity
- M
- CCI
- CCI-000172
- Version
- CD16-00-010800
- Vuln IDs
-
- V-261952
- Rule IDs
-
- SV-261952r1000861_rule
Checks: C-65806r1000859_chk
Note: The following instructions use the PGDATA and PGLOG environment variables. Refer to APPENDIX-F for instructions on configuring PGDATA and APPENDIX-I for PGLOG. As the database administrator (shown here as "postgres"), create a test table stig_test, enable row level security, and create a policy by running the following SQL: $ sudo su - postgres $ psql -c "CREATE TABLE stig_test(id INT)" $ psql -c "ALTER TABLE stig_test ENABLE ROW LEVEL SECURITY" $ psql -c "CREATE POLICY lock_table ON stig_test USING ('postgres' = current_user)" Drop the policy and disable row level security: $ psql -c "DROP POLICY lock_table ON stig_test" $ psql -c "ALTER TABLE stig_test DISABLE ROW LEVEL SECURITY" As the database administrator (shown here as "postgres"), verify the security objects deletions were logged: $ cat ${PGDATA?}/${PGLOG?}/<latest_log> 2024-03-30 14:54:18.991 UTC postgres postgres LOG: AUDIT: SESSION,11,1,DDL,DROP POLICY,,,DROP POLICY lock_table ON stig_test;,<none> 2024-03-30 14:54:42.373 UTC postgres postgres LOG: AUDIT: SESSION,12,1,DDL,ALTER TABLE,,,ALTER TABLE stig_test DISABLE ROW LEVEL SECURITY;,<none> If audit records are not produced when security objects are dropped, this is a finding.
Fix: F-65714r1000860_fix
Note: The following instructions use the PGDATA and PGVER environment variables. Refer to APPENDIX-F for instructions on configuring PGDATA and APPENDIX-H for PGVER. PostgreSQL can be configured to audit these requests using pgaudit. Refer to supplementary content APPENDIX-B for documentation on installing pgaudit. With pgaudit installed the following configurations can be made: $ sudo su - postgres $ vi ${PGDATA?}/postgresql.conf Add the following parameters (or edit existing parameters): pgaudit.log = 'ddl' As the system administrator, reload the server with the new configuration: $ sudo systemctl reload postgresql-${PGVER?}
- RMF Control
- AU-12
- Severity
- M
- CCI
- CCI-000172
- Version
- CD16-00-010900
- Vuln IDs
-
- V-261953
- Rule IDs
-
- SV-261953r1000864_rule
Checks: C-65807r1000862_chk
As the database administrator, verify pgaudit is enabled by running the following SQL: $ sudo su - postgres $ psql -c "SHOW shared_preload_libraries" If the output does not contain pgaudit, this is a finding. Verify that role, read, write, and ddl auditing are enabled: $ psql -c "SHOW pgaudit.log" If the output does not contain role, read, write, and ddl, this is a finding.
Fix: F-65715r1000863_fix
Note: The following instructions use the PGDATA and PGVER environment variables. Refer to APPENDIX-F for instructions on configuring PGDATA and APPENDIX-H for PGVER. Configure PostgreSQL to produce audit records when unsuccessful attempts to delete security objects occur. All errors and denials are logged if logging is enabled. To ensure logging is enabled, see the instructions in the supplementary content APPENDIX-C. With pgaudit installed the following configurations can be made: $ sudo su - postgres $ vi ${PGDATA?}/postgresql.conf Add the following parameters (or edit existing parameters): pgaudit.log='ddl, role, read, write' As the system administrator, reload the server with the new configuration: $ sudo systemctl reload postgresql-${PGVER?}
- RMF Control
- AU-12
- Severity
- M
- CCI
- CCI-000172
- Version
- CD16-00-011000
- Vuln IDs
-
- V-261954
- Rule IDs
-
- SV-261954r1000867_rule
Checks: C-65808r1000865_chk
As the database administrator, verify pgaudit is enabled by running the following SQL: $ sudo su - postgres $ psql -c "SHOW shared_preload_libraries" If the output does not contain "pgaudit", this is a finding. Verify that role, read, write, and ddl auditing are enabled: $ psql -c "SHOW pgaudit.log" If the output does not contain role, read, write, and ddl, this is a finding.
Fix: F-65716r1000866_fix
Note: The following instructions use the PGDATA and PGVER environment variables. Refer to APPENDIX-F for instructions on configuring PGDATA and APPENDIX-H for PGVER. To ensure logging is enabled, review supplementary content APPENDIX-C for instructions on enabling logging. PostgreSQL can be configured to audit these requests using pgaudit. Refer to supplementary content APPENDIX-B for documentation on installing pgaudit. With pgaudit installed, the following configurations can be made: $ sudo su - postgres $ vi ${PGDATA?}/postgresql.conf Add the following parameters (or edit existing parameters): pgaudit.log='ddl, role, read, write' As the system administrator, reload the server with the new configuration: $ sudo systemctl reload postgresql-${PGVER?}
- RMF Control
- AU-12
- Severity
- M
- CCI
- CCI-000172
- Version
- CD16-00-011100
- Vuln IDs
-
- V-261955
- Rule IDs
-
- SV-261955r1000870_rule
Checks: C-65809r1000868_chk
As the database administrator, verify pgaudit is enabled by running the following SQL: $ sudo su - postgres $ psql -c "SHOW shared_preload_libraries" If the output does not contain "pgaudit", this is a finding. Verify that role, read, write, and ddl auditing are enabled: $ psql -c "SHOW pgaudit.log" If the output does not contain role, read, write, and ddl, this is a finding.
Fix: F-65717r1000869_fix
Note: The following instructions use the PGDATA and PGVER environment variables. Refer to APPENDIX-F for instructions on configuring PGDATA and APPENDIX-H for PGVER. All errors and denials are logged if logging is enabled. To ensure logging is enabled, review supplementary content APPENDIX-C for instructions on enabling logging. PostgreSQL can be configured to audit these requests using pgaudit. Refer to supplementary content APPENDIX-B for documentation on installing pgaudit. With pgaudit installed the following configurations can be made: $ sudo su - postgres $ vi ${PGDATA?}/postgresql.conf Add the following parameters (or edit existing parameters): pgaudit.log='ddl, role, read, write' As the system administrator, reload the server with the new configuration: $ sudo systemctl reload postgresql-${PGVER?}
- RMF Control
- AU-12
- Severity
- M
- CCI
- CCI-000172
- Version
- CD16-00-011200
- Vuln IDs
-
- V-261956
- Rule IDs
-
- SV-261956r1000975_rule
Checks: C-65810r1000975_chk
Note: The following instructions use the PGDATA and PGLOG environment variables. Refer to APPENDIX-F for instructions on configuring PGDATA and APPENDIX-I for PGLOG. As the database administrator (shown here as "postgres"), check if log_connections is enabled by running the following SQL: $ sudo su - postgres $ psql -c "SHOW log_connections" If log_connections is off, this is a finding. Verify the logs that the previous connection to the database was logged: $ sudo su - postgres $ cat ${PGDATA?}/${PGLOG?}/<latest_log> < 2024-02-16 15:54:03.934 UTC postgres postgres 56c64b8b.aeb: >LOG: connection authorized: user=postgres database=postgres If an audit record is not generated each time a user (or other principal) logs on or connects to PostgreSQL, this is a finding.
Fix: F-65718r1000872_fix
Note: The following instructions use the PGDATA and PGVER environment variables. Refer to APPENDIX-F for instructions on configuring PGDATA and APPENDIX-H for PGVER. To ensure logging is enabled, see the instructions in the supplementary content APPENDIX-C. If logging is enabled the following configurations must be made to log connections, date/time, username, and session identifier. As the database administrator (shown here as "postgres"), edit postgresql.conf: $ sudo su - postgres $ vi ${PGDATA?}/postgresql.conf Edit the following parameters as such: log_connections = on log_line_prefix = '< %m %u %d %c: >' Where: * %m is the time and date * %u is the username * %d is the database * %c is the session ID for the connection As the system administrator, reload the server with the new configuration: $ sudo systemctl reload postgresql-${PGVER?}
- RMF Control
- AU-12
- Severity
- M
- CCI
- CCI-000172
- Version
- CD16-00-011300
- Vuln IDs
-
- V-261957
- Rule IDs
-
- SV-261957r1000876_rule
Checks: C-65811r1000874_chk
Note: The following instructions use the PGDATA and PGLOG environment variables. Refer to APPENDIX-F for instructions on configuring PGDATA and APPENDIX-I on PGLOG. In this example the user "joe" will log in to the Postgres database unsuccessfully: $ psql -d postgres -U joe As the database administrator (shown here as "postgres"), check ${PGLOG?} for a FATAL connection audit trail: $ sudo su - postgres $ cat ${PGDATA?}/${PGLOG?}/{latest_log> < 2024-02-16 16:18:13.027 UTC joe 56c65135.b5f postgres: >LOG: connection authorized: user=joe database=postgres < 2024-02-16 16:18:13.027 UTC joe 56c65135.b5f postgres: >FATAL: role "joe" does not exist If an audit record is not generated each time a user (or other principal) attempts, but fails to log on or connect to PostgreSQL (including attempts where the user ID is invalid/unknown), this is a finding.
Fix: F-65719r1000875_fix
Note: The following instructions use the PGDATA and PGVER environment variables. Refer to APPENDIX-F for instructions on configuring PGDATA and APPENDIX-H for PGVER. To ensure logging is enabled, see the instructions in the supplementary content APPENDIX-C. If logging is enabled the following configurations must be made to log unsuccessful connections, date/time, username, and session identifier. As the database administrator (shown here as "postgres"), edit postgresql.conf: $ sudo su - postgres $ vi ${PGDATA?}/postgresql.conf Edit the following parameters: log_connections = on log_line_prefix = '< %m %u %c: >' Where: * %m is the time and date * %u is the username * %c is the session ID for the connection As the system administrator, reload the server with the new configuration: $ sudo systemctl reload postgresql-${PGVER?}
- RMF Control
- AU-12
- Severity
- M
- CCI
- CCI-000172
- Version
- CD16-00-011400
- Vuln IDs
-
- V-261958
- Rule IDs
-
- SV-261958r1000879_rule
Checks: C-65812r1000877_chk
As the database administrator, verify pgaudit is enabled by running the following SQL: $ sudo su - postgres $ psql -c "SHOW shared_preload_libraries" If the output does not contain pgaudit, this is a finding. Verify that role, read, write, and ddl auditing are enabled: $ psql -c "SHOW pgaudit.log" If the output does not contain role, read, write, and ddl, this is a finding.
Fix: F-65720r1000878_fix
Note: The following instructions use the PGDATA and PGVER environment variables. Refer to APPENDIX-F for instructions on configuring PGDATA and APPENDIX-H for PGVER. PostgreSQL can be configured to audit these requests using pgaudit. Refer to supplementary content APPENDIX-B for documentation on installing pgaudit. With pgaudit installed the following configurations can be made: $ sudo su - postgres $ vi ${PGDATA?}/postgresql.conf Add the following parameters (or edit existing parameters): shared_preload_libraries = 'pgaudit' pgaudit.log='ddl, role, read, write' As the system administrator, reload the server with the new configuration: $ sudo systemctl reload postgresql-${PGVER?}
- RMF Control
- AU-12
- Severity
- M
- CCI
- CCI-000172
- Version
- CD16-00-011500
- Vuln IDs
-
- V-261959
- Rule IDs
-
- SV-261959r1000882_rule
Checks: C-65813r1000880_chk
Note: The following instructions use the PGDATA and PGLOG environment variables. Refer to APPENDIX-F for instructions on configuring PGDATA and APPENDIX-I on PGLOG. As the database administrator (shown here as "postgres"), create the role "bob" by running the following SQL: $ sudo su - postgres $ psql -c "CREATE ROLE bob" Change the current role to bob and attempt to execute privileged activity: $ psql -c "CREATE ROLE stig_test SUPERUSER" $ psql -c "CREATE ROLE stig_test CREATEDB" $ psql -c "CREATE ROLE stig_test CREATEROLE" $ psql -c "CREATE ROLE stig_test CREATEUSER" As the database administrator (shown here as "postgres"), verify that an audit event was produced (use the latest log): $ sudo su - postgres $ cat ${PGDATA?}/${PGLOG?}/<latest_log> < 2024-02-23 20:16:32.396 UTC postgres 56cfa74f.79eb postgres: >ERROR: must be superuser to create superusers < 2024-02-23 20:16:32.396 UTC postgres 56cfa74f.79eb postgres: >STATEMENT: CREATE ROLE stig_test SUPERUSER; < 2024-02-23 20:16:48.725 UTC postgres 56cfa74f.79eb postgres: >ERROR: permission denied to create role < 2024-02-23 20:16:48.725 UTC postgres 56cfa74f.79eb postgres: >STATEMENT: CREATE ROLE stig_test CREATEDB; < 2024-02-23 20:16:54.365 UTC postgres 56cfa74f.79eb postgres: >ERROR: permission denied to create role < 2024-02-23 20:16:54.365 UTC postgres 56cfa74f.79eb postgres: >STATEMENT: CREATE ROLE stig_test CREATEROLE; < 2024-02-23 20:17:05.949 UTC postgres 56cfa74f.79eb postgres: >ERROR: must be superuser to create superusers < 2024-02-23 20:17:05.949 UTC postgres 56cfa74f.79eb postgres: >STATEMENT: CREATE ROLE stig_test CREATEUSER; If audit records are not produced, this is a finding.
Fix: F-65721r1000881_fix
Configure PostgreSQL to produce audit records when unsuccessful attempts to execute privileged SQL. All denials are logged by default if logging is enabled. To ensure logging is enabled, see the instructions in the supplementary content APPENDIX-C.
- RMF Control
- AU-12
- Severity
- M
- CCI
- CCI-000172
- Version
- CD16-00-011600
- Vuln IDs
-
- V-261960
- Rule IDs
-
- SV-261960r1000885_rule
Checks: C-65814r1000883_chk
Note: The following instructions use the PGDATA and PGLOG environment variables. Refer to APPENDIX-F for instructions on configuring PGDATA and APPENDIX-I for PGLOG. Log into the database with the postgres user by running the following commands: $ sudo su - postgres $ psql -U postgres As the database administrator, verify the log for a connection audit trail: $ sudo su - postgres $ cat ${PGDATA?}/${PGLOG?}/<latest_log> < 2024-02-23 20:25:39.931 UTC postgres 56cfa993.7a72 postgres: >LOG: connection authorized: user=postgres database=postgres < 2024-02-23 20:27:45.428 UTC postgres 56cfa993.7a72 postgres: >LOG: AUDIT: SESSION,1,1,READ,SELECT,,,SELECT current_user;,<none> < 2024-02-23 20:27:47.988 UTC postgres 56cfa993.7a72 postgres: >LOG: disconnection: session time: 0:00:08.057 user=postgres database=postgres host=[local] If connections are not logged, this is a finding.
Fix: F-65722r1000884_fix
Note: The following instructions use the PGDATA and PGVER environment variables. Refer to APPENDIX-F for instructions on configuring PGDATA and APPENDIX-H for PGVER. To ensure logging is enabled, see the instructions in the supplementary content APPENDIX-C. If logging is enabled the following configurations must be made to log connections, date/time, username, and session identifier. As the database administrator (shown here as "postgres"), edit postgresql.conf by running the following: $ sudo su - postgres $ vi ${PGDATA?}/postgresql.conf Edit the following parameters: log_connections = on log_disconnections = on log_line_prefix = '< %m %u %c: >' Where: * %m is the time and date * %u is the username * %c is the session ID for the connection As the system administrator, reload the server with the new configuration: $ sudo systemctl reload postgresql-${PGVER?}
- RMF Control
- AU-12
- Severity
- M
- CCI
- CCI-000172
- Version
- CD16-00-011700
- Vuln IDs
-
- V-261961
- Rule IDs
-
- SV-261961r1000888_rule
Checks: C-65815r1000886_chk
As the database administrator, verify that log_connections and log_disconnections are enabled by running the following SQL: $ sudo su - postgres $ psql -c "SHOW log_connections" $ psql -c "SHOW log_disconnections" If either is off, this is a finding. Verify that log_line_prefix contains sufficient information by running the following SQL: $ sudo su - postgres $ psql -c "SHOW log_line_prefix" If log_line_prefix does not contain at least %m %u %d %c, this is a finding.
Fix: F-65723r1000887_fix
Note: The following instructions use the PGDATA and PGVER environment variables. Refer to APPENDIX-F for instructions on configuring PGDATA and APPENDIX-H for PGVER. To ensure logging is enabled, review supplementary content APPENDIX-C for instructions on enabling logging. As the database administrator (shown here as "postgres"), edit postgresql.conf: $ sudo su - postgres $ vi ${PGDATA?}/postgresql.conf Edit the following parameters as such: log_connections = on log_disconnections = on log_line_prefix = '< %m %u %d %c: >' Where: * %m is the time and date * %u is the username * %d is the database * %c is the session ID for the connection As the system administrator, reload the server with the new configuration: $ sudo systemctl reload postgresql-${PGVER?}
- RMF Control
- AU-12
- Severity
- M
- CCI
- CCI-000172
- Version
- CD16-00-011800
- Vuln IDs
-
- V-261962
- Rule IDs
-
- SV-261962r1000891_rule
Checks: C-65816r1000889_chk
As the database administrator, verify pgaudit is enabled by running the following SQL: $ sudo su - postgres $ psql -c "SHOW shared_preload_libraries" If the output does not contain "pgaudit", this is a finding. Verify that role, read, write, and ddl auditing are enabled: $ psql -c "SHOW pgaudit.log" If the output does not contain role, read, write, and ddl, this is a finding.
Fix: F-65724r1000890_fix
Note: The following instructions use the PGDATA and PGVER environment variables. Refer to APPENDIX-F for instructions on configuring PGDATA and APPENDIX-H for PGVER. To ensure logging is enabled, review supplementary content APPENDIX-C for instructions on enabling logging. If logging is enabled, the following configurations must be made to log unsuccessful connections, date/time, username, and session identifier. As the database administrator (shown here as "postgres"), edit postgresql.conf: $ sudo su - postgres $ vi ${PGDATA?}/postgresql.conf Edit the following parameters: log_connections = on log_line_prefix = '< %m %u %c: >' pgaudit.log = 'read, write' Where: * %m is the time and date * %u is the username * %c is the session ID for the connection As the system administrator, reload the server with the new configuration: $ sudo systemctl reload postgresql-${PGVER?}
- RMF Control
- AU-12
- Severity
- M
- CCI
- CCI-000172
- Version
- CD16-00-011900
- Vuln IDs
-
- V-261963
- Rule IDs
-
- SV-261963r1000894_rule
Checks: C-65817r1000892_chk
Note: The following instructions use the PGDATA and PGLOG environment variables. Refer to APPENDIX-F for instructions on configuring PGDATA and APPENDIX-I for PGLOG. As the database administrator (shown here as "postgres"), create a schema, test_schema, create a table, test_table, within test_schema, and insert a value: $ sudo su - postgres $ psql -c "CREATE SCHEMA test_schema" $ psql -c "CREATE TABLE test_schema.test_table(id INT)" $ psql -c "INSERT INTO test_schema.test_table(id) VALUES (0)" Create a role "bob" and attempt to SELECT, INSERT, UPDATE, and DROP from the test table: $ psql -c "CREATE ROLE BOB" $ psql -c "SET ROLE bob; SELECT * FROM test_schema.test_table" $ psql -c "SET ROLE bob; INSERT INTO test_schema.test_table VALUES (0)" $ psql -c "SET ROLE bob; UPDATE test_schema.test_table SET id = 1 WHERE id = 0" $ psql -c "SET ROLE bob; DROP TABLE test_schema.test_table" $ psql -c "SET ROLE bob; DROP SCHEMA test_schema" As the database administrator (shown here as "postgres"), review PostgreSQL/database security and audit settings to verify that audit records are created for unsuccessful attempts at the specified access to the specified objects: $ sudo su - postgres $ cat ${PGDATA?}/${PGLOG?}/<latest_log> 2024-03-30 17:23:41.254 EDT postgres postgres ERROR: permission denied for schema test_schema at character 15 2024-03-30 17:23:41.254 EDT postgres postgres STATEMENT: SELECT * FROM test_schema.test_table; 2024-03-30 17:23:53.973 EDT postgres postgres ERROR: permission denied for schema test_schema at character 13 2024-03-30 17:23:53.973 EDT postgres postgres STATEMENT: INSERT INTO test_schema.test_table VALUES (0); 2024-03-30 17:24:32.647 EDT postgres postgres ERROR: permission denied for schema test_schema at character 8 2024-03-30 17:24:32.647 EDT postgres postgres STATEMENT: UPDATE test_schema.test_table SET id = 1 WHERE id = 0; 2024-03-30 17:24:46.197 EDT postgres postgres ERROR: permission denied for schema test_schema 2024-03-30 17:24:46.197 EDT postgres postgres STATEMENT: DROP TABLE test_schema.test_table; 2024-03-30 17:24:51.582 EDT postgres postgres ERROR: must be owner of schema test_schema 2024-03-30 17:24:51.582 EDT postgres postgres STATEMENT: DROP SCHEMA test_schema; If any of the above steps did not create audit records for SELECT, INSERT, UPDATE, and DROP, this is a finding.
Fix: F-65725r1000893_fix
Configure PostgreSQL to produce audit records when unsuccessful attempts to access objects occur. All errors and denials are logged if logging is enabled. To ensure logging is enabled, see the instructions in the supplementary content APPENDIX-C.
- RMF Control
- AU-12
- Severity
- M
- CCI
- CCI-000172
- Version
- CD16-00-012000
- Vuln IDs
-
- V-261964
- Rule IDs
-
- SV-261964r1000897_rule
Checks: C-65818r1000895_chk
As the database administrator, verify pgaudit is enabled by running the following SQL: $ sudo su - postgres $ psql -c "SHOW shared_preload_libraries" If the output does not contain "pgaudit", this is a finding. Verify that connections and disconnections are being logged by running the following SQL: $ sudo su - postgres $ psql -c "SHOW log_connections" $ psql -c "SHOW log_disconnections" If the output does not contain "on", this is a finding.
Fix: F-65726r1000896_fix
Note: The following instructions use the PGDATA and PGVER environment variables. Refer to APPENDIX-F for instructions on configuring PGDATA and APPENDIX-H for PGVER. To ensure logging is enabled, review supplementary content APPENDIX-C for instructions on enabling logging. PostgreSQL can be configured to audit these requests using pgaudit. Refer to supplementary content APPENDIX-B for documentation on installing pgaudit. With pgaudit installed, the following configurations should be made: $ sudo su - postgres $ vi ${PGDATA?}/postgresql.conf Add the following parameters (or edit existing parameters): pgaudit.log='ddl, role, read, write' log_connections='on' log_disconnections='on' As the system administrator, reload the server with the new configuration: $ sudo systemctl reload postgresql-${PGVER?}
- RMF Control
- SC-13
- Severity
- M
- CCI
- CCI-002450
- Version
- CD16-00-012200
- Vuln IDs
-
- V-261965
- Rule IDs
-
- SV-261965r1137661_rule
Checks: C-65819r1000964_chk
As the system administrator, run the following to ensure FIPS is enabled: $ cat /proc/sys/crypto/fips_enabled If fips_enabled is not "1", this is a finding.
Fix: F-65727r1000899_fix
Configure OpenSSL to be FIPS compliant. PostgreSQL uses OpenSSL for cryptographic modules. To configure OpenSSL to be FIPS 140-2 compliant, refer to the official RHEL Documentation: https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/security_hardening/using-the-system-wide-cryptographic-policies_security-hardening#switching-the-system-to-fips-mode_using-the-system-wide-cryptographic-policies. For more information on configuring PostgreSQL to use SSL, refer to supplementary content APPENDIX-G.
- RMF Control
- SC-13
- Severity
- M
- CCI
- CCI-002450
- Version
- CD16-00-012300
- Vuln IDs
-
- V-261966
- Rule IDs
-
- SV-261966r1137664_rule
Checks: C-65820r1000965_chk
As the system administrator, run the following to ensure FIPS is enabled: $ cat /proc/sys/crypto/fips_enabled If fips_enabled is not "1", this is a finding.
Fix: F-65728r1000902_fix
Configure OpenSSL to be FIPS compliant. PostgreSQL uses OpenSSL for cryptographic modules. To configure OpenSSL to be FIPS 140-2 compliant, refer to the official RHEL Documentation: https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/security_hardening/using-the-system-wide-cryptographic-policies_security-hardening#switching-the-system-to-fips-mode_using-the-system-wide-cryptographic-policies. For more information on configuring PostgreSQL to use SSL, refer to supplementary content APPENDIX-G.
- RMF Control
- AU-4
- Severity
- M
- CCI
- CCI-001851
- Version
- CD16-00-012400
- Vuln IDs
-
- V-261967
- Rule IDs
-
- SV-261967r1000906_rule
Checks: C-65821r1000904_chk
As the database administrator (shown here as "postgres"), ensure PostgreSQL uses syslog by running the following SQL: $ sudo su - postgres $ psql -c "SHOW log_destination" If log_destination is not syslog, this is a finding. As the database administrator, check which log facility is configured by running the following SQL: $ psql -c "SHOW syslog_facility" Check with the organization to refer to how syslog facilities are defined in their organization. If the wrong facility is configured, this is a finding. If PostgreSQL does not have a continuous network connection to the centralized log management system, and PostgreSQL audit records are not transferred to the centralized log management system weekly or more often, this is a finding.
Fix: F-65729r1000905_fix
Note: The following instructions use the PGDATA and PGVER environment variables. Refer to APPENDIX-F for instructions on configuring PGDATA and APPENDIX-H for PGVER. Configure PostgreSQL or deploy and configure software tools to transfer audit records to a centralized log management system, continuously and in near real time where a continuous network connection to the log management system exists, or at least weekly in the absence of such a connection. To ensure logging is enabled, review supplementary content APPENDIX-C for instructions on enabling logging. With logging enabled, as the database administrator (shown here as "postgres"), configure the following parameters in postgresql.conf (the example uses the default values - tailor for environment): Note: Consult the organization on how syslog facilities are defined in the syslog daemon configuration. $ sudo su - postgres $ vi ${PGDATA?}/postgresql.conf log_destination = 'syslog' syslog_facility = 'LOCAL0' syslog_ident = 'postgres' As the system administrator, reload the server with the new configuration: $ sudo systemctl reload postgresql-${PGVER?}
- RMF Control
- SA-22
- Severity
- H
- CCI
- CCI-003376
- Version
- CD16-00-009300
- Vuln IDs
-
- V-283674
- Rule IDs
-
- SV-283674r1193281_rule
Checks: C-88239r1193279_chk
If new packages are available for PostgreSQL, they can be reviewed in the package manager appropriate for the server operating system: To list the version of installed PostgreSQL using psql: $ sudo su - postgres $ psql --version To list the current version of software for RPM: $ rpm -qa | grep postgres To list the current version of software for APT: $ apt-cache policy postgres All versions of PostgreSQL are listed here: http://www.postgresql.org/support/versioning/ All security-relevant software updates for PostgreSQL are listed here: http://www.postgresql.org/support/security/ If PostgreSQL is not at the latest version, this is a finding.
Fix: F-88144r1193280_fix
Upgrade or install a version of the product supported by the vendor.