Skip to content

Commit b152bb7

Browse files
committed
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.
1 parent 9a40a03 commit b152bb7

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/backend/postmaster/postmaster.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2075,6 +2075,13 @@ ProcessStartupPacket(Port *port, bool ssl_done, bool gss_done)
20752075

20762076
if (proto == CANCEL_REQUEST_CODE)
20772077
{
2078+
if (len != sizeof(CancelRequestPacket))
2079+
{
2080+
ereport(COMMERROR,
2081+
(errcode(ERRCODE_PROTOCOL_VIOLATION),
2082+
errmsg("invalid length of startup packet")));
2083+
return STATUS_ERROR;
2084+
}
20782085
processCancelRequest(port, buf);
20792086
/* Not really an error, but we don't want to proceed further */
20802087
return STATUS_ERROR;

0 commit comments

Comments
 (0)