STIGQter STIGQter: STIG Summary: PostgreSQL 9.x Security Technical Implementation Guide Version: 2 Release: 1 Benchmark Date: 23 Oct 2020:

PostgreSQL must automatically terminate a user session after organization-defined conditions or trigger events requiring session disconnect.

DISA Rule

SV-214147r508027_rule

Vulnerability Number

V-214147

Group Title

SRG-APP-000295-DB-000305

Rule Version

PGS9-00-011600

Severity

CAT II

CCI(s)

Weight

10

Fix Recommendation

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 
See 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

Check Contents

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.

Vulnerability Number

V-214147

Documentable

False

Rule Version

PGS9-00-011600

Severity Override Guidance

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.

Check Content Reference

M

Target Key

3994

Comments