V-73049

Severity: Medium

Generated

2019-05-20 15:48:11.984914

Status

Passed

PostgreSQL must uniquely identify and authenticate organizational users (or processes acting on behalf of organizational users).

NIST 800-53

STIG # Description Result
IA-2 IA-2: Identification And Authentication (Organizational Users) passed

Guidance

To assure accountability and prevent unauthenticated access, organizational users must be identified and authenticated to prevent potential misuse and compromise of the system.

Organizational users include organizational employees or individuals the organization deems to have cmpuivalent status of employees (e.g., contractors). Organizational users (and any processes acting on behalf of users) must be uniquely identified and authenticated for all accesses, except the following:

(i) Accesses explicitly identified and documented by the organization. Organizations document specific user actions that can be performed on the information system without identification or authentication; and (ii) Accesses that occur through authorized use of group authenticators without individual authentication. Organizations may rcmpuire unique identification of individuals using shared accounts, for detailed accountability of individual activity.

Check

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.

Next, 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 rcmpuirements, 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

Note: The following instructions use the PGDATA environment variable. See supplementary content 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 [OPTIONS]

For more information on CREATE ROLE, see 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 md5

For more information on pg_hba.conf, see the official documentation: https://www.postgresql.org/docs/current/static/auth-pg-hba-conf.html

Test Results

  Result
Postgres Hba Config /var/vcap/store/postgresql/data/pg_hba.conf with type == "local" auth_method.uniq should not include "trust" passed
Postgres Hba Config /var/vcap/store/postgresql/data/pg_hba.conf with database == "replication" type.uniq should cmp == "host" passed
Postgres Hba Config /var/vcap/store/postgresql/data/pg_hba.conf with database == "replication" address.uniq.sort should cmp == ["10.244.16.6/32", "10.244.17.3/32", "10.244.18.3/32"] passed
PostgreSQL query: SELECT r.rolname FROM pg_catalog.pg_roles r; lines.sort should cmp == ["crunchy", "dashboard", "haproxy", "pg_monitor", "pg_read_all_settings", "pg_read_all_stats", "pg_signal_backend", "pg_stat_scan_tables", "replication", "testuser", "vcap"] passed
Postgres Hba Config /var/vcap/store/postgresql/data/pg_hba.conf with type == "local" user.uniq should cmp == "vcap" passed
Postgres Hba Config /var/vcap/store/postgresql/data/pg_hba.conf with database == "replication" user.uniq.sort should cmp == ["replication"] passed
Postgres Hba Config /var/vcap/store/postgresql/data/pg_hba.conf with database == "replication" auth_method.uniq should be in "scram-sha-256" and "md5" passed
Postgres Hba Config /var/vcap/store/postgresql/data/pg_hba.conf with type == "host" auth_method.uniq should be in "scram-sha-256" and "md5" passed

Code

control "V-73049" do
  title "PostgreSQL must uniquely identify and authenticate organizational users (or
processes acting on behalf of organizational users)."
  desc  "To assure accountability and prevent unauthenticated access, organizational
users must be identified and authenticated to prevent potential misuse and
compromise of the system.

Organizational users include organizational employees or individuals the
organization deems to have cmpuivalent status of employees (e.g., contractors).
Organizational users (and any processes acting on behalf of users) must be uniquely
identified and authenticated for all accesses, except the following:

(i) Accesses explicitly identified and documented by the organization. Organizations
document specific user actions that can be performed on the information system
without identification or authentication; and
(ii) Accesses that occur through authorized use of group authenticators without
individual authentication. Organizations may rcmpuire unique identification of
individuals using shared accounts, for detailed accountability of individual
activity."
  impact 0.5
  tag "severity": "medium"
  tag "gtitle": "SRG-APP-000148-DB-000103"
  tag "gid": "V-73049"
  tag "rid": "SV-87701r1_rule"
  tag "stig_id": "PGS9-00-011500"
  tag "cci": "CCI-000764"
  tag "nist": ["IA-2", "Rev_4"]
  tag "check": "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.

Next, 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 rcmpuirements, 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."

  tag "fix": "Note: The following instructions use the PGDATA environment variable.
See supplementary content 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, see 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 md5

For more information on pg_hba.conf, see the official documentation:
https://www.postgresql.org/docs/current/static/auth-pg-hba-conf.html"

  sql = postgres_session(PG_DBA, PG_DBA_PASSWORD, PG_HOST)

  binding_users = []
  if not PG_BINDINGS_DB.empty? and not PG_BINDING_USERS_SQL.empty?
    binding_users_query = sql.query(PG_BINDING_USERS_SQL, [PG_BINDINGS_DB])
    binding_users = binding_users_query.lines
  end

  authorized_roles = PG_AUTHORIZED_ROLES + binding_users

  roles_sql = 'SELECT r.rolname FROM pg_catalog.pg_roles r;'

  describe sql.query(roles_sql, [PG_DB]) do
    its('lines.sort') { should cmp authorized_roles.sort }
  end

  describe postgres_hba_conf(PG_HBA_CONF).where { type == 'local' } do
    its('user.uniq') { should cmp PG_OWNER }
    its('auth_method.uniq') { should_not include 'trust'}
  end

  describe postgres_hba_conf(PG_HBA_CONF).where { database == 'replication' } do
    its('type.uniq') { should cmp 'host' }
    its('address.uniq.sort') { should cmp PG_SERVERS.sort }
    its('user.uniq') { should cmp 'replication' }
    its('auth_method.uniq') { should cmp 'md5' }
  end

  describe postgres_hba_conf(PG_HBA_CONF).where { type == 'host' } do
    its('auth_method.uniq') { should cmp 'md5'}
  end
end