| From: | Noah Misch <noah(at)leadboat(dot)com> |
|---|---|
| To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
| Subject: | pgsql: pg_restore: Fix out-of-bounds accesses and path traversal. |
| Date: | 2026-11-09 14:21:49 |
| Message-ID: | E1xQQFp-000000003He-0SQ2@gemulon.postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-committers |
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 <dilipbalaut(at)gmail(dot)com>
Reported-by: Yonghwa Lee <underdog(at)theori(dot)io>
Reported-by: OpenSec <security(at)opensec(dot)in>
Reported-by: Ben Dixon <uk(dot)bendixon(at)gmail(dot)com>
Author: Dilip Kumar <dilipbalaut(at)gmail(dot)com>
Author: Yonghwa Lee <underdog(at)theori(dot)io>
Co-authored-by: Nathan Bossart <nathandbossart(at)gmail(dot)com>
Reviewed-by: Noah Misch <noah(at)leadboat(dot)com>
Reviewed-by: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>
Security: CVE-2026-116314
Backpatch-through: 14
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/4056493220e78027ecba88761c1d80947cd494d5
Author: Nathan Bossart <nathan(at)postgresql(dot)org>
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(-)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Noah Misch | 2026-11-09 14:21:50 | pgsql: Teach equalRowTypes() to safely handle dropped columns. |
| Previous Message | Noah Misch | 2026-11-09 14:21:48 | pgsql: Fix potential buffer overrun in ts_rank_cd(). |