pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Validate all connection options before using libpqsrv_connect*
3+ messages / 1 participants
[nested] [flat]

* pgsql: Validate all connection options before using libpqsrv_connect*
@ 2026-11-09 14:21  Noah Misch <noah@leadboat.com>
  0 siblings, 0 replies; 3+ messages in thread

From: Noah Misch @ 2026-11-09 14:21 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/08010fa4f43dc06b701592e605b548eaf07fd5f7
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            |  46 ++++-
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, 503 insertions(+), 9 deletions(-)



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* pgsql: Validate all connection options before using libpqsrv_connect*
@ 2026-11-09 14:21  Noah Misch <noah@leadboat.com>
  0 siblings, 0 replies; 3+ messages in thread

From: Noah Misch @ 2026-11-09 14:21 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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(-)



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* pgsql: Validate all connection options before using libpqsrv_connect*
@ 2026-11-09 14:22  Noah Misch <noah@leadboat.com>
  0 siblings, 0 replies; 3+ messages in thread

From: Noah Misch @ 2026-11-09 14:22 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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_18_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/780809ba636cb1b83c39c9d6265ffec72c5653b3
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                        |   5 +-
src/bin/pg_upgrade/t/002_pg_upgrade.pl             |  22 +++
src/include/libpq/libpq-be-fe-helpers.h            |  71 ++++++++
.../recovery/t/040_standby_failover_slots_sync.pl  |  10 +-
src/test/regress/expected/subscription.out         |  34 ++++
src/test/regress/sql/subscription.sql              |  28 +++
src/test/subscription/t/027_nosuperuser.pl         |  21 +++
17 files changed, 507 insertions(+), 10 deletions(-)



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2026-11-09 14:22 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-11-09 14:21 pgsql: Validate all connection options before using libpqsrv_connect* Noah Misch <noah@leadboat.com>
2026-11-09 14:21 pgsql: Validate all connection options before using libpqsrv_connect* Noah Misch <noah@leadboat.com>
2026-11-09 14:22 pgsql: Validate all connection options before using libpqsrv_connect* 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