postgresql/src/bin
Michael Paquier 8f881e188b Prevent path traversal in pg_basebackup and pg_rewind
pg_rewind and pg_basebackup could be fed paths from rogue endpoints that
could overwrite the contents of the client when received, achieving path
traversal.

There were two areas in the tree that were sensitive to this problem:
- pg_basebackup, through the astreamer code, where no validation was
performed before building an output path when streaming tar data.  This
is an issue in v15 and newer versions.
- pg_rewind file operations for paths received through libpq, for all
the stable branches supported.

In order to address this problem, this commit adds a helper function in
path.c, that reuses path_is_relative_and_below_cwd() after applying
canonicalize_path().  This can be used to validate the paths received
from a connection point.  A path is considered invalid if any of the two
following conditions is satisfied:
- The path is absolute.
- The path includes a direct parent-directory reference.

Reported-by: XlabAI Team of Tencent Xuanwu Lab
Reported-by: Valery Gubanov <valerygubanov95@gmail.com>
Author: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>
Backpatch-through: 14
Security: CVE-2026-6475
2026-05-11 05:13:49 -07:00
..
initdb Check for unterminated strings when calling uloc_getLanguage(). 2026-04-14 14:45:58 -07:00
pg_amcheck Translation updates 2026-02-08 15:10:56 +01:00
pg_archivecleanup Translation updates 2026-02-08 15:10:56 +01:00
pg_basebackup Prevent path traversal in pg_basebackup and pg_rewind 2026-05-11 05:13:49 -07:00
pg_checksums Translation updates 2026-02-08 15:10:56 +01:00
pg_combinebackup Translation updates 2026-05-11 13:05:05 +02:00
pg_config Translation updates 2026-02-08 15:10:56 +01:00
pg_controldata Translation updates 2026-02-08 15:10:56 +01:00
pg_ctl Translation updates 2026-02-08 15:10:56 +01:00
pg_dump Translation updates 2026-05-11 13:05:05 +02:00
pg_resetwal Translation updates 2026-02-23 13:56:36 +01:00
pg_rewind Prevent path traversal in pg_basebackup and pg_rewind 2026-05-11 05:13:49 -07:00
pg_test_fsync Translation updates 2026-05-11 13:05:05 +02:00
pg_test_timing Translation updates 2026-05-11 13:05:05 +02:00
pg_upgrade Translation updates 2026-05-11 13:05:05 +02:00
pg_verifybackup Translation updates 2026-05-11 13:05:05 +02:00
pg_waldump Fix some cases of indirectly casting away const. 2026-02-25 11:19:50 -05:00
pg_walsummary Translation updates 2026-02-08 15:10:56 +01:00
pgbench Fix some cases of indirectly casting away const. 2026-02-25 11:19:50 -05:00
pgevent meson: Build pgevent as shared_module rather than shared_library 2024-11-26 18:09:14 +01:00
psql Translation updates 2026-02-23 13:56:36 +01:00
scripts Translation updates 2026-02-08 15:10:56 +01:00
Makefile Add new pg_walsummary tool. 2024-01-11 12:48:27 -05:00
meson.build Add new pg_walsummary tool. 2024-01-11 12:48:27 -05:00