pgsql: Empty search_path in Autovacuum and non-psql/pgbench clients. - Mailing list pgsql-committers

From Noah Misch
Subject pgsql: Empty search_path in Autovacuum and non-psql/pgbench clients.
Date
Msg-id E1eqKv9-00069D-0n@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Empty search_path in Autovacuum and non-psql/pgbench clients.

This makes the client programs behave as documented regardless of the
connect-time search_path and regardless of user-created objects.  Today,
a malicious user with CREATE permission on a search_path schema can take
control of certain of these clients' queries and invoke arbitrary SQL
functions under the client identity, often a superuser.  This is
exploitable in the default configuration, where all users have CREATE
privilege on schema "public".

This changes behavior of user-defined code stored in the database, like
pg_index.indexprs and pg_extension_config_dump().  If they reach code
bearing unqualified names, "does not exist" or "no schema has been
selected to create in" errors might appear.  Users may fix such errors
by schema-qualifying affected names.  After upgrading, consider watching
server logs for these errors.

The --table arguments of src/bin/scripts clients have been lax; for
example, "vacuumdb -Zt pg_am\;CHECKPOINT" performed a checkpoint.  That
now fails, but for now, "vacuumdb -Zt 'pg_am(amname);CHECKPOINT'" still
performs a checkpoint.

Back-patch to 9.3 (all supported versions).

Reviewed by Tom Lane, though this fix strategy was not his first choice.
Reported by Arseniy Sharoglazov.

Security: CVE-2018-1058

Branch
------
REL9_6_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/e170b8c8c62064a16837c9838ef7a168fa9c9506

Modified Files
--------------
contrib/oid2name/oid2name.c           |  13 ++++
contrib/vacuumlo/vacuumlo.c           |   8 +-
src/backend/postmaster/autovacuum.c   |  14 ++++
src/bin/pg_basebackup/streamutil.c    |  18 +++++
src/bin/pg_dump/pg_backup_db.c        |  11 +++
src/bin/pg_dump/pg_dump.c             |  18 ++++-
src/bin/pg_dump/pg_dumpall.c          |   7 +-
src/bin/pg_rewind/libpq_fetch.c       |   7 ++
src/bin/pg_upgrade/server.c           |   3 +
src/bin/scripts/clusterdb.c           |  12 ++-
src/bin/scripts/common.c              | 137 +++++++++++++++++++++++++++++++---
src/bin/scripts/common.h              |  10 ++-
src/bin/scripts/createdb.c            |   2 +-
src/bin/scripts/createlang.c          |   4 +-
src/bin/scripts/createuser.c          |   2 +-
src/bin/scripts/dropdb.c              |   3 +-
src/bin/scripts/droplang.c            |  10 +--
src/bin/scripts/dropuser.c            |   2 +-
src/bin/scripts/reindexdb.c           |  23 +++---
src/bin/scripts/t/010_clusterdb.pl    |   2 +-
src/bin/scripts/t/090_reindexdb.pl    |   6 +-
src/bin/scripts/t/100_vacuumdb.pl     |  30 +++++++-
src/bin/scripts/vacuumdb.c            |  29 ++++---
src/fe_utils/string_utils.c           |  16 ++--
src/include/fe_utils/connect.h        |  28 +++++++
src/tools/findoidjoins/findoidjoins.c |   9 +++
26 files changed, 347 insertions(+), 77 deletions(-)


pgsql-committers by date:

Previous
From: Noah Misch
Date:
Subject: pgsql: Document security implications of search_path and the publicsch
Next
From: Peter Eisentraut
Date:
Subject: pgsql: Fix typo in internal error message