pg.ddx.io pgsql-committers@postgresql.org mailing list archive
help / color / mirror / Atom feedpgsql: Fix type confusion in PL/Perl's get_perl_array_ref().
4+ messages / 1 participants
[nested] [flat]
* pgsql: Fix type confusion in PL/Perl's get_perl_array_ref().
@ 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
Fix type confusion in PL/Perl's get_perl_array_ref().
get_perl_array_ref() used sv_isa(sv, "PostgreSQL::InServer::ARRAY") to
recognize PL/Perl's own array wrapper objects, then cast SvRV(sv) to
HV * and looked up the "array" key. But sv_isa() only reports which
package a reference was blessed into, and blessing is an unprivileged
Perl operation that constrains nothing about what is blessed. A
function in trusted plperl could therefore return
my $x = "hi"; return bless \$x, 'PostgreSQL::InServer::ARRAY';
whereupon hv_fetch_string() would read a hash bucket array out of the
body of a plain scalar and dereference it. Since plperl is trusted,
any role with CREATE on a database can reach this.
Fix, per a suggestion from Tom Lane, by requiring SvTYPE(SvRV(sv)) to
be SVt_PVHV before consulting sv_isa(). A reference blessed into that
package but pointing at anything else now falls through to the caller's
existing handling for other references, which looks through the
reference; the example above fails with "malformed array literal". Add
a regression test next to the existing forged-object case.
It's not clear if this is exploitable, but out of an abundance of
caution we treat it as if it is.
Reported-by: Zheng Yu <zheng@depthfirst.com>
Backpatch-through: 14
Security: CVE-2026-116309
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/832857532f4678341e9da60e33397b8977547aab
Author: Andrew Dunstan <andrew@dunslane.net>
Modified Files
--------------
src/pl/plperl/expected/plperl_array.out | 9 +++++++++
src/pl/plperl/plperl.c | 8 +++++++-
src/pl/plperl/sql/plperl_array.sql | 8 ++++++++
3 files changed, 24 insertions(+), 1 deletion(-)
^ permalink raw reply [nested|flat] 4+ messages in thread
* pgsql: Fix type confusion in PL/Perl's get_perl_array_ref().
@ 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
Fix type confusion in PL/Perl's get_perl_array_ref().
get_perl_array_ref() used sv_isa(sv, "PostgreSQL::InServer::ARRAY") to
recognize PL/Perl's own array wrapper objects, then cast SvRV(sv) to
HV * and looked up the "array" key. But sv_isa() only reports which
package a reference was blessed into, and blessing is an unprivileged
Perl operation that constrains nothing about what is blessed. A
function in trusted plperl could therefore return
my $x = "hi"; return bless \$x, 'PostgreSQL::InServer::ARRAY';
whereupon hv_fetch_string() would read a hash bucket array out of the
body of a plain scalar and dereference it. Since plperl is trusted,
any role with CREATE on a database can reach this.
Fix, per a suggestion from Tom Lane, by requiring SvTYPE(SvRV(sv)) to
be SVt_PVHV before consulting sv_isa(). A reference blessed into that
package but pointing at anything else now falls through to the caller's
existing handling for other references, which looks through the
reference; the example above fails with "malformed array literal". Add
a regression test next to the existing forged-object case.
It's not clear if this is exploitable, but out of an abundance of
caution we treat it as if it is.
Reported-by: Zheng Yu <zheng@depthfirst.com>
Backpatch-through: 14
Security: CVE-2026-116309
Branch
------
REL_19_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/0bf1ac6bef44bc2ec4bf66e481c172139265f476
Author: Andrew Dunstan <andrew@dunslane.net>
Modified Files
--------------
src/pl/plperl/expected/plperl_array.out | 9 +++++++++
src/pl/plperl/plperl.c | 8 +++++++-
src/pl/plperl/sql/plperl_array.sql | 8 ++++++++
3 files changed, 24 insertions(+), 1 deletion(-)
^ permalink raw reply [nested|flat] 4+ messages in thread
* pgsql: Fix type confusion in PL/Perl's get_perl_array_ref().
@ 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
Fix type confusion in PL/Perl's get_perl_array_ref().
get_perl_array_ref() used sv_isa(sv, "PostgreSQL::InServer::ARRAY") to
recognize PL/Perl's own array wrapper objects, then cast SvRV(sv) to
HV * and looked up the "array" key. But sv_isa() only reports which
package a reference was blessed into, and blessing is an unprivileged
Perl operation that constrains nothing about what is blessed. A
function in trusted plperl could therefore return
my $x = "hi"; return bless \$x, 'PostgreSQL::InServer::ARRAY';
whereupon hv_fetch_string() would read a hash bucket array out of the
body of a plain scalar and dereference it. Since plperl is trusted,
any role with CREATE on a database can reach this.
Fix, per a suggestion from Tom Lane, by requiring SvTYPE(SvRV(sv)) to
be SVt_PVHV before consulting sv_isa(). A reference blessed into that
package but pointing at anything else now falls through to the caller's
existing handling for other references, which looks through the
reference; the example above fails with "malformed array literal". Add
a regression test next to the existing forged-object case.
It's not clear if this is exploitable, but out of an abundance of
caution we treat it as if it is.
Reported-by: Zheng Yu <zheng@depthfirst.com>
Backpatch-through: 14
Security: CVE-2026-116309
Branch
------
REL_18_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/030b28a8d1de21501fdad1e1ff2337a7ddc28a54
Author: Andrew Dunstan <andrew@dunslane.net>
Modified Files
--------------
src/pl/plperl/expected/plperl_array.out | 9 +++++++++
src/pl/plperl/plperl.c | 8 +++++++-
src/pl/plperl/sql/plperl_array.sql | 8 ++++++++
3 files changed, 24 insertions(+), 1 deletion(-)
^ permalink raw reply [nested|flat] 4+ messages in thread
* pgsql: Fix type confusion in PL/Perl's get_perl_array_ref().
@ 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
Fix type confusion in PL/Perl's get_perl_array_ref().
get_perl_array_ref() used sv_isa(sv, "PostgreSQL::InServer::ARRAY") to
recognize PL/Perl's own array wrapper objects, then cast SvRV(sv) to
HV * and looked up the "array" key. But sv_isa() only reports which
package a reference was blessed into, and blessing is an unprivileged
Perl operation that constrains nothing about what is blessed. A
function in trusted plperl could therefore return
my $x = "hi"; return bless \$x, 'PostgreSQL::InServer::ARRAY';
whereupon hv_fetch_string() would read a hash bucket array out of the
body of a plain scalar and dereference it. Since plperl is trusted,
any role with CREATE on a database can reach this.
Fix, per a suggestion from Tom Lane, by requiring SvTYPE(SvRV(sv)) to
be SVt_PVHV before consulting sv_isa(). A reference blessed into that
package but pointing at anything else now falls through to the caller's
existing handling for other references, which looks through the
reference; the example above fails with "malformed array literal". Add
a regression test next to the existing forged-object case.
It's not clear if this is exploitable, but out of an abundance of
caution we treat it as if it is.
Reported-by: Zheng Yu <zheng@depthfirst.com>
Backpatch-through: 14
Security: CVE-2026-116309
Branch
------
REL_17_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/dcc32e7d92b7558f2c4e2dfaffbed5ec8ceb51c4
Author: Andrew Dunstan <andrew@dunslane.net>
Modified Files
--------------
src/pl/plperl/expected/plperl_array.out | 9 +++++++++
src/pl/plperl/plperl.c | 8 +++++++-
src/pl/plperl/sql/plperl_array.sql | 8 ++++++++
3 files changed, 24 insertions(+), 1 deletion(-)
^ 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: Fix type confusion in PL/Perl's get_perl_array_ref(). Noah Misch <noah@leadboat.com>
2026-11-09 14:21 pgsql: Fix type confusion in PL/Perl's get_perl_array_ref(). Noah Misch <noah@leadboat.com>
2026-11-09 14:21 pgsql: Fix type confusion in PL/Perl's get_perl_array_ref(). Noah Misch <noah@leadboat.com>
2026-11-09 14:22 pgsql: Fix type confusion in PL/Perl's get_perl_array_ref(). 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