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

Execution of software modules (to include functions and trigger procedures) with elevated privileges must be restricted to necessary cases only.

DISA Rule

SV-214078r508027_rule

Vulnerability Number

V-214078

Group Title

SRG-APP-000342-DB-000302

Rule Version

PGS9-00-003600

Severity

CAT II

CCI(s)

Weight

10

Fix Recommendation

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"

Check Contents

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 database administrator (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 utilized 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.

Vulnerability Number

V-214078

Documentable

False

Rule Version

PGS9-00-003600

Severity Override Guidance

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 database administrator (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 utilized 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.

Check Content Reference

M

Target Key

3994

Comments