V-72867

Severity: Medium

Generated

2019-05-20 15:48:11.984914

Status

Passed

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

NIST 800-53

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

Guidance

Non-organizational users include all information system users other than organizational users, which includes organizational employees or individuals the organization deems to have equivalent status of employees (e.g., contractors, guest researchers, individuals from allied nations). Non-organizational users must be uniquely identified and authenticated for all accesses other than those accesses explicitly identified and documented by the organization when related to the use of anonymous access, such as accessing a web server. Accordingly, a risk assessment is used in determining the authentication needs of the organization. Scalability, practicality, and security are simultaneously considered in balancing the need to ensure ease of use for access to federal information and information systems with the need to protect and adequately mitigate risk to organizational operations, organizational assets, individuals, other organizations, and the Nation.

Check

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 as per organizational documentation, this is a finding.

Fix

To drop a role, as the database administrator (shown here as “postgres”), run the following SQL: $ sudo su - postgres $ psql -c “DROP ROLE “ To create a role, as the database administrator, run the following SQL: $ sudo su - postgres $ psql -c “CREATE ROLE LOGIN” For the complete list of permissions allowed by roles, see the official documentation: https://www.postgresql.org/docs/current/static/sql-createrole.html

Test Results

  Result
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

Code

control "V-72867" do
  title "PostgreSQL must uniquely identify and authenticate non-organizational
  users (or processes acting on behalf of non-organizational users)."
  desc  "Non-organizational users include all information system users other
  than organizational users, which includes organizational employees or
  individuals the organization deems to have equivalent status of employees
  (e.g., contractors, guest researchers, individuals from allied nations).
  Non-organizational users must be uniquely identified and authenticated for all
  accesses other than those accesses explicitly identified and documented by the
  organization when related to the use of anonymous access, such as accessing a
  web server.
  Accordingly, a risk assessment is used in determining the authentication needs
  of the organization.
  Scalability, practicality, and security are simultaneously considered in
  balancing the need to ensure ease of use for access to federal information and
  information systems with the need to protect and adequately mitigate risk to
  organizational operations, organizational assets, individuals, other
  organizations, and the Nation."
  impact 0.5
  tag "severity": "medium"
  tag "gtitle": "SRG-APP-000180-DB-000115"
  tag "gid": "V-72867"
  tag "rid": "SV-87519r1_rule"
  tag "stig_id": "PGS9-00-001400"
  tag "cci": "CCI-000804"
  tag "nist": ["IA-8", "Rev_4"]
  tag "check": "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 as per organizational documentation, this
  is a finding."
  tag "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, see the official
  documentation: https://www.postgresql.org/docs/current/static/sql-createrole.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
end