mirror of
https://github.com/postgres/postgres.git
synced 2025-07-21 16:02:15 +03:00
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
This commit is contained in:
@ -13,7 +13,7 @@
|
||||
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/include/miscadmin.h,v 1.214 2009/09/01 00:09:42 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/include/miscadmin.h,v 1.215 2009/12/09 21:57:51 tgl Exp $
|
||||
*
|
||||
* NOTES
|
||||
* some of the information in this file should be moved to other files.
|
||||
@ -242,6 +242,10 @@ extern void check_stack_depth(void);
|
||||
* POSTGRES directory path definitions. *
|
||||
*****************************************************************************/
|
||||
|
||||
/* flags to be OR'd to form sec_context */
|
||||
#define SECURITY_LOCAL_USERID_CHANGE 0x0001
|
||||
#define SECURITY_RESTRICTED_OPERATION 0x0002
|
||||
|
||||
extern char *DatabasePath;
|
||||
|
||||
/* now in utils/init/miscinit.c */
|
||||
@ -251,9 +255,12 @@ extern char *GetUserNameFromId(Oid roleid);
|
||||
extern Oid GetUserId(void);
|
||||
extern Oid GetOuterUserId(void);
|
||||
extern Oid GetSessionUserId(void);
|
||||
extern void GetUserIdAndSecContext(Oid *userid, int *sec_context);
|
||||
extern void SetUserIdAndSecContext(Oid userid, int sec_context);
|
||||
extern bool InLocalUserIdChange(void);
|
||||
extern bool InSecurityRestrictedOperation(void);
|
||||
extern void GetUserIdAndContext(Oid *userid, bool *sec_def_context);
|
||||
extern void SetUserIdAndContext(Oid userid, bool sec_def_context);
|
||||
extern bool InSecurityDefinerContext(void);
|
||||
extern void InitializeSessionUserId(const char *rolename);
|
||||
extern void InitializeSessionUserIdStandalone(void);
|
||||
extern void SetSessionAuthorization(Oid userid, bool is_superuser);
|
||||
|
Reference in New Issue
Block a user