mirror of
https://github.com/postgres/postgres.git
synced 2025-11-26 23:43:30 +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:
@@ -14,6 +14,7 @@
|
||||
#include <sys/time.h>
|
||||
|
||||
#include "libpq-fe.h"
|
||||
#include "pqexpbuffer.h"
|
||||
|
||||
/* Allocate for null byte */
|
||||
#define USER_NAME_SIZE 128
|
||||
@@ -236,6 +237,7 @@ typedef struct
|
||||
const char *progname; /* complete pathname for this program */
|
||||
char *exec_path; /* full path to my executable */
|
||||
char *user; /* username for clusters */
|
||||
char *user_shell_arg; /* the same, with shell quoting */
|
||||
char cwd[MAXPGPATH]; /* current working directory, used for output */
|
||||
char **tablespaces; /* tablespaces */
|
||||
int num_tablespaces;
|
||||
@@ -381,6 +383,9 @@ void check_pghost_envvar(void);
|
||||
/* util.c */
|
||||
|
||||
char *quote_identifier(const char *s);
|
||||
extern void appendShellString(PQExpBuffer buf, const char *str);
|
||||
extern void appendConnStrVal(PQExpBuffer buf, const char *str);
|
||||
extern void appendPsqlMetaConnect(PQExpBuffer buf, const char *dbname);
|
||||
int get_user_info(char **user_name);
|
||||
void check_ok(void);
|
||||
void report_status(eLogType type, const char *fmt,...);
|
||||
|
||||
Reference in New Issue
Block a user