mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-20 19:16:08 +00:00
28f93f2539
The privileged-role check missed three ways a role can reach the database host from SQL. Before PostgreSQL 16 a member of a CREATEROLE role sets its role to it and grants itself pg_execute_server_program, since role attributes are not inherited but the grant checks the role in effect. A role granted EXECUTE on lo_export, lo_import, pg_read_file, pg_ls_dir and their siblings reads or writes server files, and lo_export keeps the file after the transaction rolls back. From PostgreSQL 15 on a role can be granted ALTER SYSTEM on a setting or SET on a superuser-only one. PRIVILEGED_ROLE_SQL now counts all three. The parameter grants are read through query_to_xml inside a CASE taken only on 15 or later, because a statement naming pg_parameter_acl does not parse on 14. A SET grant on a setting every role may change anyway, and pg_monitor, stay ordinary. The lane test creates each kind of role and shows the escalation the check is for on the server it runs against.