Re: set role command - Mailing list pgsql-general

From Calvin Guo
Subject Re: set role command
Date
Msg-id CA+bysH8yz-iB0Th5wsTUvzM-6Ap-y-kt6si9c_DF9zH_MrODRg@mail.gmail.com
Whole thread Raw
In response to Re: set role command  (rob stone <floriparob@tpg.com.au>)
List pgsql-general
No, that's not the case. right now: usera can totally do: reset role, and then behave like userb.
this behavior should not be allowed. 
userb can impernate usera, once the impersonation is done, it becomes usera, and it should NOT be able to impersonate userb. but right now, reset role will allow it.

On Mon, Nov 24, 2025 at 8:06 PM rob stone <floriparob@tpg.com.au> wrote:
On Mon, 2025-11-24 at 16:15 +0800, Calvin Guo wrote:
> I feel that set role logic is kindof misleading.
>
> I am a superuser, admin,
> I do:
> set role usera
> Now I am under the security context of usera, so I think running any
> sql is safe as long as it's allowed by usera.
>
> Which is not the case!
> as usera can do:
> set role userb; other sql,
> or 
> reset role; orther sql,
> it turns out it's not safe at all, the sql can easily get access
> right of the super user. it can impernate userb though they do not
> have any relationship whatso ever.
>
> I really feel, once you "set role usera", you should behave like
> usera, you should NOT have the power say: hi, I can assume my super
> user power whenever I want. As this make the "set role usera" pretty
> much useless.
>
> It's unsafe!


Hello,

firstly you have to create a role usera and in doing so give it the
privileges you want usera to have. You can also restrict its privileges
by specifying the NO* range of options.

So, if you are logged in as userb, say, doing "set role usera" simply
switches you out of userb into usera, and you behave as usera in that
session.

HTH,
Rob



pgsql-general by date:

Previous
From: rob stone
Date:
Subject: Re: set role command
Next
From: Laurenz Albe
Date:
Subject: Re: set role command