pgsql: Fix insecure parsing of server command-line switches. - Mailing list pgsql-committers

From Tom Lane
Subject pgsql: Fix insecure parsing of server command-line switches.
Date
Msg-id E1UMj3k-0000ae-6s@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Fix insecure parsing of server command-line switches.

An oversight in commit e710b65c1c56ca7b91f662c63d37ff2e72862a94 allowed
database names beginning with "-" to be treated as though they were secure
command-line switches; and this switch processing occurs before client
authentication, so that even an unprivileged remote attacker could exploit
the bug, needing only connectivity to the postmaster's port.  Assorted
exploits for this are possible, some requiring a valid database login,
some not.  The worst known problem is that the "-r" switch can be invoked
to redirect the process's stderr output, so that subsequent error messages
will be appended to any file the server can write.  This can for example be
used to corrupt the server's configuration files, so that it will fail when
next restarted.  Complete destruction of database tables is also possible.

Fix by keeping the database name extracted from a startup packet fully
separate from command-line switches, as had already been done with the
user name field.

The Postgres project thanks Mitsumasa Kondo for discovering this bug,
Kyotaro Horiguchi for drafting the fix, and Noah Misch for recognizing
the full extent of the danger.

Security: CVE-2013-1899

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/17fe2793ea7fe269ed616cb305150b6cf38dbaa8

Modified Files
--------------
src/backend/main/main.c             |    4 ++-
src/backend/postmaster/postmaster.c |    9 +------
src/backend/tcop/postgres.c         |   41 ++++++++++++++++++-----------------
src/backend/utils/init/postinit.c   |    2 +-
src/include/tcop/tcopprot.h         |    8 ++++--
5 files changed, 32 insertions(+), 32 deletions(-)


pgsql-committers by date:

Previous
From: Tom Lane
Date:
Subject: pgsql: Fix insecure parsing of server command-line switches.
Next
From: Tom Lane
Date:
Subject: pgsql: Fix insecure parsing of server command-line switches.