Restrict accesses to non-system views and foreign tables during pg_dump.
authorMasahiko Sawada <msawada@postgresql.org>
Mon, 5 Aug 2024 13:05:25 +0000 (06:05 -0700)
committerMasahiko Sawada <msawada@postgresql.org>
Mon, 5 Aug 2024 13:05:25 +0000 (06:05 -0700)
commite81e53a0c1faf2b8f5fe8822d7218c91aeebea52
tree4ae24029cec9f60ff6b5081c6ef02ba1dd161479
parent8b57eb67e8428d93f42f603a917e610477a08821
Restrict accesses to non-system views and foreign tables during pg_dump.

When pg_dump retrieves the list of database objects and performs the
data dump, there was possibility that objects are replaced with others
of the same name, such as views, and access them. This vulnerability
could result in code execution with superuser privileges during the
pg_dump process.

This issue can arise when dumping data of sequences, foreign
tables (only 13 or later), or tables registered with a WHERE clause in
the extension configuration table.

To address this, pg_dump now utilizes the newly introduced
restrict_nonsystem_relation_kind GUC parameter to restrict the
accesses to non-system views and foreign tables during the dump
process. This new GUC parameter is added to back branches too, but
these changes do not require cluster recreation.

Back-patch to all supported branches.

Reviewed-by: Noah Misch
Security: CVE-2024-7348
Backpatch-through: 12
14 files changed:
contrib/postgres_fdw/expected/postgres_fdw.out
contrib/postgres_fdw/sql/postgres_fdw.sql
doc/src/sgml/config.sgml
doc/src/sgml/ref/pg_dump.sgml
src/backend/foreign/foreign.c
src/backend/optimizer/plan/createplan.c
src/backend/optimizer/util/plancat.c
src/backend/rewrite/rewriteHandler.c
src/backend/tcop/postgres.c
src/backend/utils/misc/guc.c
src/bin/pg_dump/pg_dump.c
src/include/tcop/tcopprot.h
src/test/regress/expected/create_view.out
src/test/regress/sql/create_view.sql