V-72909

Severity: Medium

Generated

2019-05-20 15:48:11.984914

Status

Failed

PostgreSQL must utilize centralized management of the content captured in audit records generated by all components of PostgreSQL.

NIST 800-53

STIG # Description Result
AU-3 AU-3: Content Of Audit Records failed

Guidance

Without the ability to centrally manage the content captured in the audit records, identification, troubleshooting, and correlation of suspicious behavior would be difficult and could lead to a delayed or incomplete analysis of an ongoing attack. The content captured in audit records must be managed from a central location (necessitating automation). Centralized management of audit records and logs provides for efficiency in maintenance and management of records, as well as the backup and archiving of those records. PostgreSQL may write audit records to database tables, to files in the file system, to other kinds of local repository, or directly to a centralized log management system. Whatever the method used, it must be compatible with off-loading the records to the centralized system.

Check

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 which log facility PostgreSQL is configured by running the following SQL: $ sudo su - postgres $ psql -c “SHOW syslog_facility” Check with the organization to see 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

Note: The following instructions use the PGDATA environment variable. See supplementary content APPENDIX-F for instructions on configuring PGDATA. To ensure that 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 follow parameters in postgresql.conf: Note: Consult the organization on how syslog facilities are defined in the syslog daemon configuration. $ sudo su - postgres $ vi ‘log_destination’ ${PGDATA?}/postgresql.conf log_destination = ‘syslog’ syslog_facility = ‘LOCAL0’ syslog_ident = ‘postgres’ Now, as the system administrator, reload the server with the new configuration: # SYSTEMD SERVER ONLY $ sudo systemctl reload postgresql-9.5 # INITD SERVER ONLY $ sudo service postgresql-9.5 reload

Test Results

  Result
PostgreSQL query: SHOW log_destination; output should match /syslog/i failed
PostgreSQL query: SHOW syslog_facility; output should match /local[0-7]/i passed

Code

control "V-72909" do
  title "PostgreSQL must utilize centralized management of the content captured
  in audit records generated by all components of PostgreSQL."
  desc  "Without the ability to centrally manage the content captured in the
  audit records, identification, troubleshooting, and correlation of suspicious
  behavior would be difficult and could lead to a delayed or incomplete analysis
  of an ongoing attack.
  The content captured in audit records must be managed from a central location
  (necessitating automation). Centralized management of audit records and logs
  provides for efficiency in maintenance and management of records, as well as
  the backup and archiving of those records.
  PostgreSQL may write audit records to database tables, to files in the file
  system, to other kinds of local repository, or directly to a centralized log
  management system. Whatever the method used, it must be compatible with
  off-loading the records to the centralized system."
  impact 0.5
  tag "severity": "medium"
  tag "gtitle": "SRG-APP-000356-DB-000314"
  tag "gid": "V-72909"
  tag "rid": "SV-87561r1_rule"
  tag "stig_id": "PGS9-00-003800"
  tag "cci": "CCI-001844"
  tag "nist": ["AU-3 (2)", "Rev_4"]
  tag "check": "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 which log facility
  PostgreSQL is configured by running the following SQL:
  $ sudo su - postgres
  $ psql -c \"SHOW syslog_facility\"
  Check with the organization to see 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."
  tag "fix": "Note: The following instructions use the PGDATA environment
  variable. See supplementary content APPENDIX-F for instructions on configuring
  PGDATA.
  To ensure that 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 follow parameters in postgresql.conf:
  Note: Consult the organization on how syslog facilities are defined in the
  syslog daemon configuration.
  $ sudo su - postgres
  $ vi 'log_destination' ${PGDATA?}/postgresql.conf
  log_destination = 'syslog'
  syslog_facility = 'LOCAL0'
  syslog_ident = 'postgres'
  Now, as the system administrator, reload the server with the new
  configuration:
  # SYSTEMD SERVER ONLY
  $ sudo systemctl reload postgresql-9.5
  # INITD SERVER ONLY
  $ sudo service postgresql-9.5 reload"

  sql = postgres_session(PG_DBA, PG_DBA_PASSWORD, PG_HOST)

  describe sql.query('SHOW log_destination;', [PG_DB]) do
    its('output') { should match /syslog/i }
  end

  describe sql.query('SHOW syslog_facility;', [PG_DB]) do
    its('output') { should match /local[0-7]/i }
  end
end