pg.ddx.io pgsql-committers@postgresql.org mailing list archive
help / color / mirror / Atom feedpgsql: Further harden PL/Perl against tied-scalar mischief.
4+ messages / 1 participants
[nested] [flat]
* pgsql: Further harden PL/Perl against tied-scalar mischief.
@ 2026-11-09 14:21 Noah Misch <noah@leadboat.com>
0 siblings, 0 replies; 4+ messages in thread
From: Noah Misch @ 2026-11-09 14:21 UTC (permalink / raw)
To: pgsql-committers@lists.postgresql.org
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
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/41a3a980ee30b37127edce6b68dd9791bf0e7b4b
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(-)
^ permalink raw reply [nested|flat] 4+ messages in thread
* pgsql: Further harden PL/Perl against tied-scalar mischief.
@ 2026-11-09 14:21 Noah Misch <noah@leadboat.com>
0 siblings, 0 replies; 4+ messages in thread
From: Noah Misch @ 2026-11-09 14:21 UTC (permalink / raw)
To: pgsql-committers@lists.postgresql.org
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(-)
^ permalink raw reply [nested|flat] 4+ messages in thread
* pgsql: Further harden PL/Perl against tied-scalar mischief.
@ 2026-11-09 14:21 Noah Misch <noah@leadboat.com>
0 siblings, 0 replies; 4+ messages in thread
From: Noah Misch @ 2026-11-09 14:21 UTC (permalink / raw)
To: pgsql-committers@lists.postgresql.org
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_18_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/3ce3d94c0da1a9ad512b743f85228e69883940ec
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(-)
^ permalink raw reply [nested|flat] 4+ messages in thread
* pgsql: Further harden PL/Perl against tied-scalar mischief.
@ 2026-11-09 14:22 Noah Misch <noah@leadboat.com>
0 siblings, 0 replies; 4+ messages in thread
From: Noah Misch @ 2026-11-09 14:22 UTC (permalink / raw)
To: pgsql-committers@lists.postgresql.org
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_17_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/6e5524cdad1064d660a9d349649dcb4f6c9d3cc4
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(-)
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2026-11-09 14:22 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-11-09 14:21 pgsql: Further harden PL/Perl against tied-scalar mischief. Noah Misch <noah@leadboat.com>
2026-11-09 14:21 pgsql: Further harden PL/Perl against tied-scalar mischief. Noah Misch <noah@leadboat.com>
2026-11-09 14:21 pgsql: Further harden PL/Perl against tied-scalar mischief. Noah Misch <noah@leadboat.com>
2026-11-09 14:22 pgsql: Further harden PL/Perl against tied-scalar mischief. Noah Misch <noah@leadboat.com>
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