mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +03:00
Obstruct shell, SQL, and conninfo injection via database and role names.
Due to simplistic quoting and confusion of database names with conninfo strings, roles with the CREATEDB or CREATEROLE option could escalate to superuser privileges when a superuser next ran certain maintenance commands. The new coding rule for PQconnectdbParams() calls, documented at conninfo_array_parse(), is to pass expand_dbname=true and wrap literal database names in a trivial connection string. Escape zero-length values in appendConnStrVal(). Back-patch to 9.1 (all supported versions). Nathan Bossart, Michael Paquier, and Noah Misch. Reviewed by Peter Eisentraut. Reported by Nathan Bossart. Security: CVE-2016-5424
This commit is contained in:
@ -155,6 +155,20 @@ set -x
|
||||
|
||||
standard_initdb "$oldbindir"/initdb
|
||||
$oldbindir/pg_ctl start -l "$logdir/postmaster1.log" -o "$POSTMASTER_OPTS" -w
|
||||
|
||||
# Create databases with names covering the ASCII bytes other than NUL, BEL,
|
||||
# LF, or CR. BEL would ring the terminal bell in the course of this test, and
|
||||
# it is not otherwise a special case. PostgreSQL doesn't support the rest.
|
||||
dbname1=`awk 'BEGIN { for (i= 1; i < 46; i++)
|
||||
if (i != 7 && i != 10 && i != 13) printf "%c", i }' </dev/null`
|
||||
# Exercise backslashes adjacent to double quotes, a Windows special case.
|
||||
dbname1='\"\'$dbname1'\\"\\\'
|
||||
dbname2=`awk 'BEGIN { for (i = 46; i < 91; i++) printf "%c", i }' </dev/null`
|
||||
dbname3=`awk 'BEGIN { for (i = 91; i < 128; i++) printf "%c", i }' </dev/null`
|
||||
createdb "$dbname1" || createdb_status=$?
|
||||
createdb "$dbname2" || createdb_status=$?
|
||||
createdb "$dbname3" || createdb_status=$?
|
||||
|
||||
if "$MAKE" -C "$oldsrc" installcheck; then
|
||||
pg_dumpall -f "$temp_root"/dump1.sql || pg_dumpall1_status=$?
|
||||
if [ "$newsrc" != "$oldsrc" ]; then
|
||||
@ -180,6 +194,9 @@ else
|
||||
make_installcheck_status=$?
|
||||
fi
|
||||
$oldbindir/pg_ctl -m fast stop
|
||||
if [ -n "$createdb_status" ]; then
|
||||
exit 1
|
||||
fi
|
||||
if [ -n "$make_installcheck_status" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
Reference in New Issue
Block a user