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

Commite5fdb8f

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 parentfe6b242 commite5fdb8f

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
@@ -9413,7 +9413,7 @@ do_pg_start_backup(const char *backupidstr, bool fast, char **labelfile)
94139413

94149414
backup_started_in_recovery=RecoveryInProgress();
94159415

9416-
if (!superuser()&& !is_authenticated_user_replication_role())
9416+
if (!superuser()&& !has_rolreplication(GetUserId()))
94179417
ereport(ERROR,
94189418
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
94199419
errmsg("must be superuser or replication role to run a backup")));
@@ -9743,7 +9743,7 @@ do_pg_stop_backup(char *labelfile, bool waitforarchive)
97439743

97449744
backup_started_in_recovery=RecoveryInProgress();
97459745

9746-
if (!superuser()&& !is_authenticated_user_replication_role())
9746+
if (!superuser()&& !has_rolreplication(GetUserId()))
97479747
ereport(ERROR,
97489748
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
97499749
(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
@@ -668,7 +668,7 @@ InitPostgres(const char *in_dbname, Oid dboid, const char *username,
668668
{
669669
Assert(!bootstrap);
670670

671-
if (!superuser()&& !is_authenticated_user_replication_role())
671+
if (!superuser()&& !has_rolreplication(GetUserId()))
672672
ereport(FATAL,
673673
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
674674
errmsg("must be superuser or replication role to start walsender")));

‎src/include/miscadmin.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ extern void ValidatePgVersion(const char *path);
436436
externvoidprocess_shared_preload_libraries(void);
437437
externvoidprocess_local_preload_libraries(void);
438438
externvoidpg_bindtextdomain(constchar*domain);
439-
externboolis_authenticated_user_replication_role(void);
439+
externboolhas_rolreplication(Oidroleid);
440440

441441
/* in access/transam/xlog.c */
442442
externboolBackupInProgress(void);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp