Description
This PostgreSQL extension allows switching users and optional privilege escala-
tion with enhanced logging and control. It provides an additional layer of logging
and control when unprivileged users must escalate themselves to superuser or
object owner roles in order to perform needed maintenance tasks. Specifically,
when an allowed user executes
set_user(text)
or
set_user_u(text)
, several
actions occur:
• The current effective user becomes rolename.
•
The role transition is logged, with a specific notation if
rolename
is a
superuser.
• log_statement
setting is set to “all”, meaning every SQL statement
executed while in this state will also get logged.
•
If
set_user.block_alter_system
is set to “on”,
ALTER SYSTEM
com-
mands will be blocked.
•
If
set_user.block_copy_program
is set to “on”,
COPY PROGRAM
com-
mands will be blocked.
•
If
set_user.block_log_statement
is set to “on”,
SET log_statement
and variations will be blocked.
•
If
set_user.block_log_statement
is set to “on” and
rolename
is a
database superuser, the current
log_statement
setting is changed to
“all”, meaning every SQL statement executed
•
If
set_user.superuser_audit_tag
is set, the string value will
be appended to
log_line_prefix
upon superuser escalation. All
logs after superuser escalation will be tagged with the value of
set_user.superuser_audit_tag. This value defaults to ’AUDIT’.
•
If
set_user.exit_on_error
is set to “on”, the backend process will exit
on ERROR during calls to set_session_auth().
• Post-execution hook for set_user is called if it is set.
Only users with
EXECUTE
permission on
set_user_u(text)
may esca-
late to superuser. Additionally, all rules in Superuser Allowlist apply to
set_user.superuser_allowlist and set_user_u(text).
Postgres roles calling
set_user(text)
can only transition to roles listed or
included in
set_user.nosuperuser_target_allowlist
(defaults to all roles).
Additionally the logic in Nosuperuser Allowlist applies to
current_user
when
set_user() is invoked.
Additionally, with
set_user(’rolename’,’token’)
the
token
is stored for the
lifetime of the session.
When finished with required actions as
rolename
, the
reset_user()
function
is executed to restore the original user. At that point, these actions occur:
2
评论