mirror of
https://github.com/postgres/postgres.git
synced 2025-06-29 10:41:53 +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:
@ -4423,7 +4423,11 @@ conninfo_parse(const char *conninfo, PQExpBuffer errorMessage,
|
||||
* of "dbname" keyword is a connection string (as indicated by
|
||||
* recognized_connection_string) then parse and process it, overriding any
|
||||
* previously processed conflicting keywords. Subsequent keywords will take
|
||||
* precedence, however.
|
||||
* precedence, however. In-tree programs generally specify expand_dbname=true,
|
||||
* so command-line arguments naming a database can use a connection string.
|
||||
* Some code acquires arbitrary database names from known-literal sources like
|
||||
* PQdb(), PQconninfoParse() and pg_database.datname. When connecting to such
|
||||
* a database, in-tree code first wraps the name in a connection string.
|
||||
*/
|
||||
static PQconninfoOption *
|
||||
conninfo_array_parse(const char *const * keywords, const char *const * values,
|
||||
|
Reference in New Issue
Block a user