From: Noah Misch <noah@leadboat.com>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: pg_restore: Fix out-of-bounds accesses and path traversal.
Date: Mon, 09 Nov 2026 14:21:49 +0000
Message-ID: <E1xQQFp-000000003He-0SQ2@gemulon.postgresql.org> (raw)
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@gmail.com>
Reported-by: Yonghwa Lee <underdog@theori.io>
Reported-by: OpenSec <security@opensec.in>
Reported-by: Ben Dixon <uk.bendixon@gmail.com>
Author: Dilip Kumar <dilipbalaut@gmail.com>
Author: Yonghwa Lee <underdog@theori.io>
Co-authored-by: Nathan Bossart <nathandbossart@gmail.com>
Reviewed-by: Noah Misch <noah@leadboat.com>
Reviewed-by: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Security: CVE-2026-116314
Backpatch-through: 14
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/4056493220e78027ecba88761c1d80947cd494d5
Author: Nathan Bossart <nathan@postgresql.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(-)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: noah@leadboat.com
Subject: Re: pgsql: pg_restore: Fix out-of-bounds accesses and path traversal.
In-Reply-To: <E1xQQFp-000000003He-0SQ2@gemulon.postgresql.org>
References: <E1xQQFp-000000003He-0SQ2@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox