summaryrefslogtreecommitdiff
path: root/src/bin/pg_dump/dumputils.h
diff options
context:
space:
mode:
authorNathan Bossart <nathan@postgresql.org>2025-08-11 09:00:00 -0500
committerNathan Bossart <nathan@postgresql.org>2025-08-11 09:00:00 -0500
commit575f54d4cee8b141a91b3e5c3d7d65372c0f5219 (patch)
treea5e02b4b0abe1b9e5caf734d9b00515df8adea77 /src/bin/pg_dump/dumputils.h
parent9b92f115bdf9f21e9a8c4dcd80207c0723e81c3b (diff)
Restrict psql meta-commands in plain-text dumps.
A malicious server could inject psql meta-commands into plain-text dump output (i.e., scripts created with pg_dump --format=plain, pg_dumpall, or pg_restore --file) that are run at restore time on the machine running psql. To fix, introduce a new "restricted" mode in psql that blocks all meta-commands (except for \unrestrict to exit the mode), and teach pg_dump, pg_dumpall, and pg_restore to use this mode in plain-text dumps. While at it, encourage users to only restore dumps generated from trusted servers or to inspect it beforehand, since restoring causes the destination to execute arbitrary code of the source superusers' choice. However, the client running the dump and restore needn't trust the source or destination superusers. Reported-by: Martin Rakhmanov Reported-by: Matthieu Denais <litezeraw@gmail.com> Reported-by: RyotaK <ryotak.mail@gmail.com> Suggested-by: Tom Lane <tgl@sss.pgh.pa.us> Reviewed-by: Noah Misch <noah@leadboat.com> Reviewed-by: Michael Paquier <michael@paquier.xyz> Reviewed-by: Peter Eisentraut <peter@eisentraut.org> Security: CVE-2025-8714 Backpatch-through: 13
Diffstat (limited to 'src/bin/pg_dump/dumputils.h')
-rw-r--r--src/bin/pg_dump/dumputils.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/bin/pg_dump/dumputils.h b/src/bin/pg_dump/dumputils.h
index d1248d9061b..f685c616c64 100644
--- a/src/bin/pg_dump/dumputils.h
+++ b/src/bin/pg_dump/dumputils.h
@@ -64,4 +64,7 @@ extern void makeAlterConfigCommand(PGconn *conn, const char *configitem,
const char *type2, const char *name2,
PQExpBuffer buf);
+extern char *generate_restrict_key(void);
+extern bool valid_restrict_key(const char *restrict_key);
+
#endif /* DUMPUTILS_H */