From: Noah Misch <noah@leadboat.com>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Validate all connection options before using libpqsrv_connect*
Date: Mon, 09 Nov 2026 14:21:55 +0000
Message-ID: <E1xQQFv-000000003WF-1yST@gemulon.postgresql.org> (raw)
Validate all connection options before using libpqsrv_connect*
Connection options passed to dblink(), dblink_connect[_u](), and
dblink_exec() didn't flow through the same validation path as options
which were set via foreign server definitions. Additionally, connection
options added to subscriptions didn't go through any validation except
for the password check. This allowed the sslkeylogfile parameter and
all oauth_* parameters, both introduced in PG18, to be set by relatively
unprivileged users.
Add libpqsrv sanitization functions which block unsafe and unknown
connection options. These are called before libpqsrv_connect() and its
variants. (Extensions which use those functions are encouraged to do the
same.) walrcv_connect() makes an exception to this rule for
primary_conninfo, which is still allowed to contain any parameters.
To reduce the size of the patchset, the implementation has the following
drawbacks, which we hope to improve after release:
- The superuser is also restricted.
- The sanitization functions are not invoked when administering foreign
server options, or when modifying subscriptions without connecting, to
avoid interfering with pg_upgrade and dump/restore. The restrictions
will be applied later, at connection time, which may be a surprise.
Backpatch all the way down. Though the new options aren't present in
older libpqs, running an older server with a newer libpq is common. The
tests for the newer options unfortunately cannot be easily backpatched
past PG18.
Reported-by: Andrey Krasichkov <buglloc@yandex-team.ru>
Reported-by: b.altawil <b.altawil@proton.me>
Reported-by: Zsolt Parragi <zsolt.parragi@percona.com>
Suggested-by: Noah Misch <noah@leadboat.com> (sslkeylogfile part)
Reviewed-by: Noah Misch <noah@leadboat.com> (sslkeylogfile part)
Reviewed-by: Andres Freund <andres@anarazel.de> (PG14/15 backpatch)
Backpatch-through: 14
Security: CVE-2026-14661
Branch
------
REL_19_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/0adbf6bb1f4b5d7455ba84bec7bf5d4538487bf9
Author: Jacob Champion <jchampion@postgresql.org>
Modified Files
--------------
contrib/dblink/dblink.c | 18 ++
contrib/dblink/expected/dblink.out | 22 ++-
contrib/dblink/sql/dblink.sql | 19 +-
contrib/postgres_fdw/connection.c | 13 ++
contrib/postgres_fdw/expected/postgres_fdw.out | 6 +
contrib/postgres_fdw/sql/postgres_fdw.sql | 5 +
src/backend/libpq/Makefile | 1 +
src/backend/libpq/be-fe-helpers.c | 198 +++++++++++++++++++++
src/backend/libpq/meson.build | 1 +
.../libpqwalreceiver/libpqwalreceiver.c | 43 ++++-
src/bin/pg_upgrade/Makefile | 6 +-
src/bin/pg_upgrade/t/002_pg_upgrade.pl | 22 +++
src/include/libpq/libpq-be-fe-helpers.h | 72 ++++++++
.../recovery/t/040_standby_failover_slots_sync.pl | 10 +-
src/test/regress/expected/subscription.out | 30 ++++
src/test/regress/sql/subscription.sql | 22 +++
src/test/subscription/t/027_nosuperuser.pl | 21 +++
17 files changed, 500 insertions(+), 9 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: Validate all connection options before using libpqsrv_connect*
In-Reply-To: <E1xQQFv-000000003WF-1yST@gemulon.postgresql.org>
References: <E1xQQFv-000000003WF-1yST@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