From: Noah Misch <noah@leadboat.com>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Block environment variable mutations from trusted PL/Perl.
Date: Mon, 11 Nov 2024 14:26:09 +0000
Message-ID: <E1tAVMn-001JOX-8g@gemulon.postgresql.org> (raw)
Block environment variable mutations from trusted PL/Perl.
Many process environment variables (e.g. PATH), bypass the containment
expected of a trusted PL. Hence, trusted PLs must not offer features
that achieve setenv(). Otherwise, an attacker having USAGE privilege on
the language often can achieve arbitrary code execution, even if the
attacker lacks a database server operating system user.
To fix PL/Perl, replace trusted PL/Perl %ENV with a tied hash that just
replaces each modification attempt with a warning. Sites that reach
these warnings should evaluate the application-specific implications of
proceeding without the environment modification:
Can the application reasonably proceed without the modification?
If no, switch to plperlu or another approach.
If yes, the application should change the code to stop attempting
environment modifications. If that's too difficult, add "untie
%main::ENV" in any code executed before the warning. For example,
one might add it to the start of the affected function or even to
the plperl.on_plperl_init setting.
In passing, link to Perl's guidance about the Perl features behind the
security posture of PL/Perl.
Back-patch to v12 (all supported versions).
Andrew Dunstan and Noah Misch
Security: CVE-2024-10979
Branch
------
REL_14_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/d15ec27c977100037ae513ab7fe1a214bfc2507b
Modified Files
--------------
doc/src/sgml/plperl.sgml | 13 +++++++++
src/pl/plperl/GNUmakefile | 4 +--
src/pl/plperl/input/plperl_env.source | 52 ++++++++++++++++++++++++++++++++++
src/pl/plperl/output/plperl_env.source | 49 ++++++++++++++++++++++++++++++++
src/pl/plperl/plc_trusted.pl | 24 ++++++++++++++++
src/test/regress/regress.c | 24 ++++++++++++++++
6 files changed, 164 insertions(+), 2 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 using the --to and --cc options:
reply via email
To: pgsql-committers@postgresql.org
Cc: noah@leadboat.com, pgsql-committers@lists.postgresql.org
Subject: Re: pgsql: Block environment variable mutations from trusted PL/Perl.
In-Reply-To: <E1tAVMn-001JOX-8g@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