| From: | Noah Misch <noah(at)leadboat(dot)com> |
|---|---|
| To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
| Subject: | pgsql: Further harden PL/Perl against tied-scalar mischief. |
| Date: | 2026-11-09 14:22:02 |
| Message-ID: | E1xQQG2-000000003l8-1kJk@gemulon.postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-committers |
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(at)gmail(dot)com>
Author: Andrew Dunstan <andrew(at)dunslane(dot)net>
Co-authored-by: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Backpatch-through: 14
Security: CVE-2026-116326
Branch
------
REL_17_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/6e5524cdad1064d660a9d349649dcb4f6c9d3cc4
Author: Andrew Dunstan <andrew(at)dunslane(dot)net>
Modified Files
--------------
src/pl/plperl/plperl.c | 81 +++++++++++++++++++++++++++++++++++++-------------
src/pl/plperl/plperl.h | 65 +++++++++++++++++++++++++++++++++-------
2 files changed, 116 insertions(+), 30 deletions(-)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Noah Misch | 2026-11-09 14:22:03 | pgsql: Reject extnamespace if it's temporary or it's '$user'::regnamesp |
| Previous Message | Noah Misch | 2026-11-09 14:22:01 | pgsql: Introduce attribute versioning to prevent unsafe deforming |