From: Noah Misch <noah@leadboat.com>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix type confusion with materialized set-returning functions
Date: Mon, 09 Nov 2026 14:21:55 +0000
Message-ID: <E1xQQFv-000000003XO-3twj@gemulon.postgresql.org> (raw)
Fix type confusion with materialized set-returning functions
Set-returning functions in the target list with indeterminate RECORD
return types incorrectly used the same tuple descriptor to read and
return tuples from the tuplestore across invocations.
These types of SRFs resolve their rowtype from the passed in record
argument and it can differ from invocation to invocation. Reading tuples
with the wrong shape of tuple descriptor can lead to incorrect results,
crashes, and security issues. It was reported as a way to read arbitrary
out-of-line values via json_populate_recordset().
To fix this, drop and recreate the slot and its tuple descriptor per SRF
invocation for materialized SRFs in the target list with dynamic RECORD
return types.
Only the target-list path is affected: table functions in FROM validate
every result against the query-supplied descriptor, and value-per-call
SRFs never retain a slot.
Co-authored-by: Melanie Plageman <melanieplageman@gmail.com>
Co-authored-by: Robert Haas <rhaas@postgresql.org>
Security: CVE-2026-120141
Backpatch-through: 14
Branch
------
REL_19_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/c5dc8b0a0214fbb6d3ac71f811cb6f58e36baaa2
Author: Robert Haas <rhaas@postgresql.org>
Modified Files
--------------
src/backend/executor/execSRF.c | 59 ++++++++++++++++++++++++++++++++------
src/test/regress/expected/json.out | 11 +++++++
src/test/regress/sql/json.sql | 5 ++++
3 files changed, 67 insertions(+), 8 deletions(-)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: noah@leadboat.com
Subject: Re: pgsql: Fix type confusion with materialized set-returning functions
In-Reply-To: <E1xQQFv-000000003XO-3twj@gemulon.postgresql.org>
References: <E1xQQFv-000000003XO-3twj@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox