From: Noah Misch <noah@leadboat.com>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Further harden PL/Perl against tied-scalar mischief.
Date: Mon, 09 Nov 2026 14:21:52 +0000
Message-ID: <E1xQQFs-000000003QK-3Amq@gemulon.postgresql.org> (raw)
Further harden PL/Perl against tied-scalar mischief.
PL/Perl decides whether Perl threw an error by testing SvTRUE(ERRSV).
If the thrown value is an object whose class overloads "bool", that
runs user-supplied Perl code. There is no eval{} in scope at some of
these tests, so if that code throws in turn, Perl writes the message
to stderr and exits the backend, not the behavior we want.
To fix, don't ask Perl at all in the case that matters. Any reference
is true regardless of what its class claims, so a thrown object is an
error by definition, while overloading cannot apply to a non-reference.
Add errsv_is_true() to encapsulate that and replace tests of ERRSV
with that.
Also, consider the possibility that trying to stringify ERRSV throws
an error, which can also be arranged with a hostile object definition.
That risks an infinite loop in PG_PERL_TRY, so install code to prevent
repeating such a loop.
Lastly, stringify ERRSV outside our ereport() calls not inside. If we
do it inside then a thrown Perl error temporarily leaks an errordata[]
slot for the unfinished ereport. While it's not clear that this makes
it possible to overrun ERRORDATA_STACK_SIZE, it seems best to avoid
the leak.
Reported-by: Dwij Mehta <dwijimehta@gmail.com>
Author: Andrew Dunstan <andrew@dunslane.net>
Co-authored-by: Tom Lane <tgl@sss.pgh.pa.us>
Backpatch-through: 14
Security: CVE-2026-116326
Branch
------
REL_19_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/80e73b3ce5d4ad68406d87480fd227cb6a5994a8
Author: Andrew Dunstan <andrew@dunslane.net>
Modified Files
--------------
src/pl/plperl/plperl.c | 81 +++++++++++++++++++++++++++++++++++++-------------
src/pl/plperl/plperl.h | 65 +++++++++++++++++++++++++++++++++-------
2 files changed, 116 insertions(+), 30 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: Further harden PL/Perl against tied-scalar mischief.
In-Reply-To: <E1xQQFs-000000003QK-3Amq@gemulon.postgresql.org>
References: <E1xQQFs-000000003QK-3Amq@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