aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoah Misch <noah@leadboat.com>2023-01-21 06:08:00 -0800
committerNoah Misch <noah@leadboat.com>2023-01-21 06:08:04 -0800
commita9bccffe5a39dab64ca597476563f8d965b46428 (patch)
treed49e57bf47199583f893692af4cebdf710996926
parentc78f109b87d8a64b0f785bf6fa30d4bd29742638 (diff)
downloadpostgresql-a9bccffe5a39dab64ca597476563f8d965b46428.tar.gz
postgresql-a9bccffe5a39dab64ca597476563f8d965b46428.zip
Reject CancelRequestPacket having unexpected length.
When the length was too short, the server read outside the allocation. That yielded the same log noise as sending the correct length with (backendPID,cancelAuthCode) matching nothing. Change to a message about the unexpected length. Given the attacker's lack of control over the memory layout and the general lack of diversity in memory layouts at the code in question, we doubt a would-be attacker could cause a segfault. Hence, while the report arrived via security@postgresql.org, this is not a vulnerability. Back-patch to v11 (all supported versions). Andrey Borodin, reviewed by Tom Lane. Reported by Andrey Borodin.
-rw-r--r--src/backend/postmaster/postmaster.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c
index 70c7cc70bef..18c19eea80c 100644
--- a/src/backend/postmaster/postmaster.c
+++ b/src/backend/postmaster/postmaster.c
@@ -2014,6 +2014,13 @@ ProcessStartupPacket(Port *port, bool ssl_done, bool gss_done)
if (proto == CANCEL_REQUEST_CODE)
{
+ if (len != sizeof(CancelRequestPacket))
+ {
+ ereport(COMMERROR,
+ (errcode(ERRCODE_PROTOCOL_VIOLATION),
+ errmsg("invalid length of startup packet")));
+ return STATUS_ERROR;
+ }
processCancelRequest(port, buf);
/* Not really an error, but we don't want to proceed further */
return STATUS_ERROR;