pgsql: Cross-check the type of a portal running EXECUTE or FETCH.

From: Noah Misch <noah(at)leadboat(dot)com>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Cross-check the type of a portal running EXECUTE or FETCH.
Date: 2026-08-10 13:41:22
Message-ID: E1wtQFm-00000000y5I-41La@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Cross-check the type of a portal running EXECUTE or FETCH.

When an EXECUTE or FETCH statement is executed, there are two portals:
an outer portal that is created for the EXECUTE or FETCH statement itself,
and an inner portal for the statement being executed on its behalf.
Before this commit, nothing checked that these two portals agreed on
the tuple descriptor of the rows being returned. This can be leveraged
to disclose server memory contents and achieve arbitrary code execution.

To prevent that, we can make use of an existing safety mechanism,
added by Tom Lane in commit 2f48ede080f42b97b594fb14102c82ca1001b80c,
which allows a tuplestore DestReceiver to be informed of the tupleDesc
required by the caller, and which will cause an ERROR to occur if
that doesn't match the tupleDesc of what emerges from the executor
(modulo dropped columns, which aren't an issue in the case at hand).

Reported-by: Ben Morris in collaboration with Claude and Anthropic Research
Reported-by: Peter Geoghegan <pg(at)bowt(dot)ie>
Reviewed-by: Michael Paquier <michael(at)paquier(dot)xyz>
Security: CVE-2026-16239

Branch
------
REL_19_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/64a65ead1235f50816a46d4eb66a8ffcba7d5cde
Author: Robert Haas <rhaas(at)postgresql(dot)org>

Modified Files
--------------
src/backend/tcop/pquery.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Noah Misch 2026-08-10 13:41:23 pgsql: Check for USAGE privilege on the subtype in CREATE TYPE AS RANGE
Previous Message Noah Misch 2026-08-10 13:41:21 pgsql: Guard against overlength time zone abbreviations in to_char().