pgsql: Prevent indirect security attacks via changing session-local

From: tgl(at)postgresql(dot)org (Tom Lane)
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Prevent indirect security attacks via changing session-local
Date: 2009-12-09 21:58:44
Message-ID: 20091209215844.74C0C753FB7@cvs.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Log Message:
-----------
Prevent indirect security attacks via changing session-local state within
an allegedly immutable index function. It was previously recognized that
we had to prevent such a function from executing SET/RESET ROLE/SESSION
AUTHORIZATION, or it could trivially obtain the privileges of the session
user. However, since there is in general no privilege checking for changes
of session-local state, it is also possible for such a function to change
settings in a way that might subvert later operations in the same session.
Examples include changing search_path to cause an unexpected function to
be called, or replacing an existing prepared statement with another one
that will execute a function of the attacker's choosing.

The present patch secures VACUUM, ANALYZE, and CREATE INDEX/REINDEX against
these threats, which are the same places previously deemed to need protection
against the SET ROLE issue. GUC changes are still allowed, since there are
many useful cases for that, but we prevent security problems by forcing a
rollback of any GUC change after completing the operation. Other cases are
handled by throwing an error if any change is attempted; these include temp
table creation, closing a cursor, and creating or deleting a prepared
statement. (In 7.4, the infrastructure to roll back GUC changes doesn't
exist, so we settle for rejecting changes of "search_path" in these contexts.)

Original report and patch by Gurjeet Singh, additional analysis by
Tom Lane.

Security: CVE-2009-4136

Tags:
----
REL8_1_STABLE

Modified Files:
--------------
pgsql/src/backend/access/transam:
xact.c (r1.215.2.5 -> r1.215.2.6)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/access/transam/xact.c?r1=1.215.2.5&r2=1.215.2.6)
pgsql/src/backend/catalog:
index.c (r1.261.2.5 -> r1.261.2.6)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/catalog/index.c?r1=1.261.2.5&r2=1.261.2.6)
pgsql/src/backend/commands:
analyze.c (r1.89.2.3 -> r1.89.2.4)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/commands/analyze.c?r1=1.89.2.3&r2=1.89.2.4)
schemacmds.c (r1.35.2.1 -> r1.35.2.2)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/commands/schemacmds.c?r1=1.35.2.1&r2=1.35.2.2)
tablecmds.c (r1.174.2.8 -> r1.174.2.9)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/commands/tablecmds.c?r1=1.174.2.8&r2=1.174.2.9)
vacuum.c (r1.317.2.8 -> r1.317.2.9)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/commands/vacuum.c?r1=1.317.2.8&r2=1.317.2.9)
pgsql/src/backend/executor:
execMain.c (r1.256.2.7 -> r1.256.2.8)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/executor/execMain.c?r1=1.256.2.7&r2=1.256.2.8)
pgsql/src/backend/tcop:
utility.c (r1.245 -> r1.245.2.1)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/tcop/utility.c?r1=1.245&r2=1.245.2.1)
pgsql/src/backend/utils/adt:
ri_triggers.c (r1.82.2.3 -> r1.82.2.4)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/utils/adt/ri_triggers.c?r1=1.82.2.3&r2=1.82.2.4)
pgsql/src/backend/utils/fmgr:
fmgr.c (r1.97.2.3 -> r1.97.2.4)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/utils/fmgr/fmgr.c?r1=1.97.2.3&r2=1.97.2.4)
pgsql/src/backend/utils/init:
miscinit.c (r1.150.2.2 -> r1.150.2.3)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/utils/init/miscinit.c?r1=1.150.2.2&r2=1.150.2.3)
pgsql/src/backend/utils/misc:
guc.c (r1.299.2.5 -> r1.299.2.6)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/utils/misc/guc.c?r1=1.299.2.5&r2=1.299.2.6)
pgsql/src/include:
miscadmin.h (r1.183.2.2 -> r1.183.2.3)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/include/miscadmin.h?r1=1.183.2.2&r2=1.183.2.3)
pgsql/src/include/utils:
guc.h (r1.63.2.1 -> r1.63.2.2)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/include/utils/guc.h?r1=1.63.2.1&r2=1.63.2.2)
guc_tables.h (r1.20.2.2 -> r1.20.2.3)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/include/utils/guc_tables.h?r1=1.20.2.2&r2=1.20.2.3)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2009-12-09 21:58:56 pgsql: Prevent indirect security attacks via changing session-local
Previous Message Tom Lane 2009-12-09 21:58:30 pgsql: Prevent indirect security attacks via changing session-local