pg_restore: Fix out-of-bounds accesses and path traversal. pg_restore trusts the contents of the archives it reads, so a maliciously crafted archive can cause out-of-bounds reads and writes, or make pg_restore read files outside the archive directory. This commit fixes the following issues:
* Dependency IDs read from the table of contents are used as array subscripts without validation. To fix, reject any that is not a positive integer. * _getObjectDescription() and IssueACLPerBlob() can read past the end of a string when an entry's DROP statement or large object ACL has an unexpected form. To fix, check for the expected prefix before moving past it. * A crafted archive can cause the dump ID index to be built before the table of contents has been read, in which case it is too small for every later lookup. To fix, have the tar format reject archives whose table of contents is not the first member. * The directory format opens the files named in the archive without inspecting them. To fix, reject names that contain a directory separator and anything that isn't a regular file. * A tar member length that does not fit in a pgoff_t can cause a buffer overrun on 32-bit systems. To fix, reject such lengths. * In the back-branches, buildTocEntryArrays() sizes the dump ID index arrays with unchecked multiplication, which could overflow size_t on 32-bit systems. To fix, use pg_malloc0_array(). A corrupt archive can still crash pg_restore in other ways, but hardening against that didn't seem appropriate for a security fix, and therefore it is left as a future exercise. Reported-by: Dilip Kumar <[email protected]> Reported-by: Yonghwa Lee <[email protected]> Reported-by: OpenSec <[email protected]> Reported-by: Ben Dixon <[email protected]> Author: Dilip Kumar <[email protected]> Author: Yonghwa Lee <[email protected]> Co-authored-by: Nathan Bossart <[email protected]> Reviewed-by: Noah Misch <[email protected]> Reviewed-by: Bharath Rupireddy <[email protected]> Security: CVE-2026-116314 Backpatch-through: 14 Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/4056493220e78027ecba88761c1d80947cd494d5 Author: Nathan Bossart <[email protected]> Modified Files -------------- src/bin/pg_dump/compress_io.c | 31 +++++++++++++++++++++++++++++++ src/bin/pg_dump/pg_backup_archiver.c | 25 ++++++++++++++++++++++--- src/bin/pg_dump/pg_backup_db.c | 8 +++++++- src/bin/pg_dump/pg_backup_directory.c | 4 ++++ src/bin/pg_dump/pg_backup_tar.c | 20 ++++++++++++++++++++ 5 files changed, 84 insertions(+), 4 deletions(-)
