pgsql: Fix unbounded recursive handling of SSL/GSS in ProcessStartupPac

From: Noah Misch <noah(at)leadboat(dot)com>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix unbounded recursive handling of SSL/GSS in ProcessStartupPac
Date: 2026-05-11 12:19:37
Message-ID: E1wMPbl-0002U8-1D@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix unbounded recursive handling of SSL/GSS in ProcessStartupPacket()

The handling of SSL and GSS negotiation messages in
ProcessStartupPacket() could cause a recursion of the backend,
ultimately crashing the server as the negotiation attempts were not
tracked across multiple calls processing startup packets.

A malicious client could therefore alternate rejected SSL and GSS
requests indefinitely, each adding a stack frame, until the backend
crashed with a stack overflow, taking down a server.

This commit addresses this issue by modifying ProcessStartupPacket() so
as processed negotiation attempts are tracked, preventing infinite
recursive attempts. A TAP test is added to check this problem, where
multiple SSL and GSS negotiated attempts are stacked.

Reported-by: Calif.io in collaboration with Claude and Anthropic
Research
Author: Michael Paquier <michael(at)paquier(dot)xyz>
Reviewed-by: Daniel Gustafsson <daniel(at)yesql(dot)se>
Security: CVE-2026-6479
Backpatch-through: 14

Branch
------
REL_18_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/f7a191f5377dacd05d22dd40c1d1e38b393ea9b4
Author: Michael Paquier <michael(at)paquier(dot)xyz>

Modified Files
--------------
src/backend/tcop/backend_startup.c | 23 +++++++++-
src/test/postmaster/meson.build | 1 +
src/test/postmaster/t/004_negotiate.pl | 82 ++++++++++++++++++++++++++++++++++
3 files changed, 104 insertions(+), 2 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Noah Misch 2026-05-11 12:19:38 pgsql: Harden our regex engine against integer overflow in size calcula
Previous Message Noah Misch 2026-05-11 12:19:36 pgsql: Apply timingsafe_bcmp() in authentication paths