aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils
diff options
context:
space:
mode:
authorNoah Misch <noah@leadboat.com>2023-11-06 06:14:13 -0800
committerNoah Misch <noah@leadboat.com>2023-11-06 06:14:18 -0800
commite082734c8e78e6622a0422e612a870278721e83f (patch)
tree107d372f6b3b1710bf32a0dda4bedab9b3622533 /src/backend/utils
parentb29af71cd9a32b11e9e41f66c3068070a01e544d (diff)
downloadpostgresql-e082734c8e78e6622a0422e612a870278721e83f.tar.gz
postgresql-e082734c8e78e6622a0422e612a870278721e83f.zip
Ban role pg_signal_backend from more superuser backend types.
Documentation says it cannot signal "a backend owned by a superuser". On the contrary, it could signal background workers, including the logical replication launcher. It could signal autovacuum workers and the autovacuum launcher. Block all that. Signaling autovacuum workers and those two launchers doesn't stall progress beyond what one could achieve other ways. If a cluster uses a non-core extension with a background worker that does not auto-restart, this could create a denial of service with respect to that background worker. A background worker with bugs in its code for responding to terminations or cancellations could experience those bugs at a time the pg_signal_backend member chooses. Back-patch to v11 (all supported versions). Reviewed by Jelte Fennema-Nio. Reported by Hemanth Sandrana and Mahendrakar Srinivasarao. Security: CVE-2023-5870
Diffstat (limited to 'src/backend/utils')
-rw-r--r--src/backend/utils/adt/misc.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/backend/utils/adt/misc.c b/src/backend/utils/adt/misc.c
index 8915e23089e..f0a39b0c9df 100644
--- a/src/backend/utils/adt/misc.c
+++ b/src/backend/utils/adt/misc.c
@@ -242,8 +242,13 @@ pg_signal_backend(int pid, int sig)
return SIGNAL_BACKEND_ERROR;
}
- /* Only allow superusers to signal superuser-owned backends. */
- if (superuser_arg(proc->roleId) && !superuser())
+ /*
+ * Only allow superusers to signal superuser-owned backends. Any process
+ * not advertising a role might have the importance of a superuser-owned
+ * backend, so treat it that way.
+ */
+ if ((!OidIsValid(proc->roleId) || superuser_arg(proc->roleId)) &&
+ !superuser())
return SIGNAL_BACKEND_NOSUPERUSER;
/* Users can signal backends they have role membership in. */