Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb403f41

Browse files
committed
Make REPLICATION privilege checks test current user not authenticated user.
The pg_start_backup() and pg_stop_backup() functions checked the privilegesof the initially-authenticated user rather than the current user, which iswrong. For example, a user-defined index function could successfully callthese functions when executed by ANALYZE within autovacuum. This couldallow an attacker with valid but low-privilege database access to interferewith creation of routine backups. Reported and fixed by Noah Misch.Security:CVE-2013-1901
1 parent54d4a8f commitb403f41

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

‎src/backend/access/transam/xlog.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8982,7 +8982,7 @@ do_pg_start_backup(const char *backupidstr, bool fast, char **labelfile)
89828982
FILE*fp;
89838983
StringInfoDatalabelfbuf;
89848984

8985-
if (!superuser()&& !is_authenticated_user_replication_role())
8985+
if (!superuser()&& !has_rolreplication(GetUserId()))
89868986
ereport(ERROR,
89878987
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
89888988
errmsg("must be superuser or replication role to run a backup")));
@@ -9261,7 +9261,7 @@ do_pg_stop_backup(char *labelfile, bool waitforarchive)
92619261
boolreported_waiting= false;
92629262
char*remaining;
92639263

9264-
if (!superuser()&& !is_authenticated_user_replication_role())
9264+
if (!superuser()&& !has_rolreplication(GetUserId()))
92659265
ereport(ERROR,
92669266
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
92679267
(errmsg("must be superuser or replication role to run a backup"))));

‎src/backend/utils/init/miscinit.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -389,15 +389,15 @@ SetUserIdAndContext(Oid userid, bool sec_def_context)
389389

390390

391391
/*
392-
* Checkif the authenticated user is a replication role
392+
* Checkwhether specified role has explicit REPLICATION privilege
393393
*/
394394
bool
395-
is_authenticated_user_replication_role(void)
395+
has_rolreplication(Oidroleid)
396396
{
397397
boolresult= false;
398398
HeapTupleutup;
399399

400-
utup=SearchSysCache1(AUTHOID,ObjectIdGetDatum(AuthenticatedUserId));
400+
utup=SearchSysCache1(AUTHOID,ObjectIdGetDatum(roleid));
401401
if (HeapTupleIsValid(utup))
402402
{
403403
result= ((Form_pg_authid)GETSTRUCT(utup))->rolreplication;

‎src/backend/utils/init/postinit.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ InitPostgres(const char *in_dbname, Oid dboid, const char *username,
669669
Assert(!bootstrap);
670670

671671
/* must have authenticated as a replication role */
672-
if (!is_authenticated_user_replication_role())
672+
if (!has_rolreplication(GetUserId()))
673673
ereport(FATAL,
674674
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
675675
errmsg("must be replication role to start walsender")));

‎src/include/miscadmin.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ extern void ValidatePgVersion(const char *path);
395395
externvoidprocess_shared_preload_libraries(void);
396396
externvoidprocess_local_preload_libraries(void);
397397
externvoidpg_bindtextdomain(constchar*domain);
398-
externboolis_authenticated_user_replication_role(void);
398+
externboolhas_rolreplication(Oidroleid);
399399

400400
/* in access/transam/xlog.c */
401401
externboolBackupInProgress(void);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp