pgsql: Obstruct shell, SQL, and conninfo injection via database and rol

From: Noah Misch <noah(at)leadboat(dot)com>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Obstruct shell, SQL, and conninfo injection via database and rol
Date: 2016-08-08 14:10:48
Message-ID: [email protected]
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/fcd15f13581f6d75c63d213220d5a94889206c1b

Modified Files
--------------
src/bin/pg_basebackup/streamutil.c | 12 +++++--
src/bin/pg_dump/pg_backup.h | 4 +--
src/bin/pg_dump/pg_backup_archiver.c | 34 +++++++++++++-----
src/bin/pg_dump/pg_backup_db.c | 10 +++++-
src/bin/pg_dump/pg_dumpall.c | 18 +++++++---
src/bin/pg_upgrade/Makefile | 3 +-
src/bin/pg_upgrade/check.c | 19 ++++++----
src/bin/pg_upgrade/dump.c | 16 +++++++--
src/bin/pg_upgrade/pg_upgrade.c | 16 +++++++--
src/bin/pg_upgrade/server.c | 51 +++++++++++++++++----------
src/bin/pg_upgrade/test.sh | 17 +++++++++
src/bin/pg_upgrade/version.c | 11 ++++--
src/bin/psql/command.c | 15 +++++++-
src/bin/scripts/clusterdb.c | 10 +++++-
src/bin/scripts/reindexdb.c | 14 ++++++--
src/bin/scripts/vacuumdb.c | 17 +++++----
src/fe_utils/string_utils.c | 67 ++++++++++++++++++++++++++++++++++--
src/include/fe_utils/string_utils.h | 1 +
src/interfaces/libpq/fe-connect.c | 6 +++-
src/tools/msvc/vcregress.pl | 41 ++++++++++++++++++++++
20 files changed, 315 insertions(+), 67 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2016-08-08 14:34:05 pgsql: Fix two errors with nested CASE/WHEN constructs.
Previous Message Peter Eisentraut 2016-08-08 13:28:05 pgsql: doc: Update benchmark results