]> granicus.if.org Git - postgresql/commit
Ensure that all temp files made during pg_upgrade are non-world-readable.
authorTom Lane <tgl@sss.pgh.pa.us>
Mon, 5 Feb 2018 15:58:27 +0000 (10:58 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Mon, 5 Feb 2018 15:58:27 +0000 (10:58 -0500)
commit6ba52aeb24e62586b51e77723d87627c18a844ca
tree53c421c93c66ea7ad91a0228489585ca86fce144
parentfe921a360a4858f537c99d1872d3c3a5a09d6df0
Ensure that all temp files made during pg_upgrade are non-world-readable.

pg_upgrade has always attempted to ensure that the transient dump files
it creates are inaccessible except to the owner.  However, refactoring
in commit 76a7650c4 broke that for the file containing "pg_dumpall -g"
output; since then, that file was protected according to the process's
default umask.  Since that file may contain role passwords (hopefully
encrypted, but passwords nonetheless), this is a particularly unfortunate
oversight.  Prudent users of pg_upgrade on multiuser systems would
probably run it under a umask tight enough that the issue is moot, but
perhaps some users are depending only on pg_upgrade's umask changes to
protect their data.

To fix this in a future-proof way, let's just tighten the umask at
process start.  There are no files pg_upgrade needs to write at a
weaker security level; and if there were, transiently relaxing the
umask around where they're created would be a safer approach.

Report and patch by Tom Lane; the idea for the fix is due to Noah Misch.
Back-patch to all supported branches.

Security: CVE-2018-1053
src/bin/pg_upgrade/dump.c
src/bin/pg_upgrade/file.c
src/bin/pg_upgrade/pg_upgrade.c
src/bin/pg_upgrade/pg_upgrade.h