Make \restrict keys protective in pg_dump --format=tar restore.sql.

pg_dump tar format contains an undocumented restore.sql archive member
that the user can edit according to its embedded comments and then run
with psql.  Commit 71ea0d6795438f95f4ee6e35867058c44b270d51 added
\restrict and \unrestrict to fix CVE-2025-8714.  That restore.sql always
used "(null)" as the restriction key, so the key did not provide its
intended protection.  Also, there was an initial \unrestrict before any
restrict, yielding a spurious error.  Given the lack of reports about
that spurious error in over a year, restore.sql may see negligible use.

This defers fixing restore.sql from "pg_dump --format=tar --inserts",
because that relies on "\i" commands.  That case is not subject to
attack, but it fails to restore table data.  We should eventually fix
"pg_dump --format=tar --inserts" restore.sql or remove restore.sql.
Given this combination with --inserts has been broken to that degree,
again for over a year, the combination must see little use indeed.

Back-patch to v14 (all supported versions).

Reported-by: Pavel Kopylov <[email protected]>
Reviewed-by: Nathan Bossart <[email protected]> (non-test)
Reviewed-by: Jacob Champion <[email protected]> (test)
Reviewed-by: Andres Freund <[email protected]> (test)
Bug: #19718
Discussion: https://postgr.es/m/[email protected]
Backpatch-through: 14
Security: CVE-2026-116330

Branch
------
REL_15_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/7d1f31c7354f760f2dfa73800ceebc4a3fbed75f

Modified Files
--------------
doc/src/sgml/ref/pg_dump.sgml    |   6 +-
src/bin/pg_dump/Makefile         |   1 +
src/bin/pg_dump/pg_dump.c        |   9 +-
src/bin/pg_dump/t/011_restore.pl | 269 +++++++++++++++++++++++++++++++++++++++
4 files changed, 278 insertions(+), 7 deletions(-)

Reply via email to