pgsql: Prevent indirect security attacks via changing session-local - Mailing list pgsql-committers

From tgl@postgresql.org (Tom Lane)
Subject pgsql: Prevent indirect security attacks via changing session-local
Date
Msg-id 20091209215830.1BC10753FB7@cvs.postgresql.org
Whole thread Raw
List 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_2_STABLE

Modified Files:
--------------
    pgsql/src/backend/access/transam:
        xact.c (r1.229.2.5 -> r1.229.2.6)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/access/transam/xact.c?r1=1.229.2.5&r2=1.229.2.6)
    pgsql/src/backend/catalog:
        index.c (r1.274.2.3 -> r1.274.2.4)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/catalog/index.c?r1=1.274.2.3&r2=1.274.2.4)
    pgsql/src/backend/commands:
        analyze.c (r1.101.2.2 -> r1.101.2.3)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/commands/analyze.c?r1=1.101.2.2&r2=1.101.2.3)
        schemacmds.c (r1.41.2.1 -> r1.41.2.2)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/commands/schemacmds.c?r1=1.41.2.1&r2=1.41.2.2)
        tablecmds.c (r1.206.2.7 -> r1.206.2.8)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/commands/tablecmds.c?r1=1.206.2.7&r2=1.206.2.8)
        vacuum.c (r1.342.2.7 -> r1.342.2.8)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/commands/vacuum.c?r1=1.342.2.7&r2=1.342.2.8)
    pgsql/src/backend/executor:
        execMain.c (r1.280.2.3 -> r1.280.2.4)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/executor/execMain.c?r1=1.280.2.3&r2=1.280.2.4)
    pgsql/src/backend/tcop:
        utility.c (r1.269 -> r1.269.2.1)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/tcop/utility.c?r1=1.269&r2=1.269.2.1)
    pgsql/src/backend/utils/adt:
        ri_triggers.c (r1.89.2.2 -> r1.89.2.3)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/utils/adt/ri_triggers.c?r1=1.89.2.2&r2=1.89.2.3)
    pgsql/src/backend/utils/fmgr:
        fmgr.c (r1.102.2.3 -> r1.102.2.4)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/utils/fmgr/fmgr.c?r1=1.102.2.3&r2=1.102.2.4)
    pgsql/src/backend/utils/init:
        miscinit.c (r1.159.2.1 -> r1.159.2.2)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/utils/init/miscinit.c?r1=1.159.2.1&r2=1.159.2.2)
    pgsql/src/backend/utils/misc:
        guc.c (r1.360.2.4 -> r1.360.2.5)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/utils/misc/guc.c?r1=1.360.2.4&r2=1.360.2.5)
    pgsql/src/include:
        miscadmin.h (r1.190.2.1 -> r1.190.2.2)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/include/miscadmin.h?r1=1.190.2.1&r2=1.190.2.2)
    pgsql/src/include/utils:
        guc.h (r1.76 -> r1.76.2.1)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/include/utils/guc.h?r1=1.76&r2=1.76.2.1)
        guc_tables.h (r1.29.2.1 -> r1.29.2.2)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/include/utils/guc_tables.h?r1=1.29.2.1&r2=1.29.2.2)

pgsql-committers by date:

Previous
From: mha@postgresql.org (Magnus Hagander)
Date:
Subject: pgsql: Reject certificates with embedded NULLs in the commonName field.
Next
From: tgl@postgresql.org (Tom Lane)
Date:
Subject: pgsql: Prevent indirect security attacks via changing session-local