1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-27 12:41:57 +03:00

Re-validate connection string in libpqrcv_connect().

A superuser may create a subscription with password_required=true, but
which uses a connection string without a password.

Previously, if the owner of such a subscription was changed to a
non-superuser, the non-superuser was able to utilize a password from
another source (like a password file or the PGPASSWORD environment
variable), which should not have been allowed.

This commit adds a step to re-validate the connection string before
connecting.

Reported-by: Jeff Davis
Author: Vignesh C
Reviewed-by: Peter Smith, Robert Haas, Amit Kapila
Discussion: https://www.postgresql.org/message-id/flat/e5892973ae2a80a1a3e0266806640dae3c428100.camel%40j-davis.com
Backpatch-through: 16
This commit is contained in:
Jeff Davis
2024-01-12 13:41:36 -08:00
parent a1604237a6
commit 5c31669058
3 changed files with 95 additions and 5 deletions

View File

@ -137,6 +137,15 @@ libpqrcv_connect(const char *conninfo, bool logical, bool must_use_password,
const char *vals[6];
int i = 0;
/*
* Re-validate connection string. The validation already happened at DDL
* time, but the subscription owner may have changed. If we don't recheck
* with the correct must_use_password, it's possible that the connection
* will obtain the password from a different source, such as PGPASSFILE or
* PGPASSWORD.
*/
libpqrcv_check_conninfo(conninfo, must_use_password);
/*
* We use the expand_dbname parameter to process the connection string (or
* URI), and pass some extra options.