Re: BUG #15708: RLS 'using' running as wrong user when called from aview - Mailing list pgsql-bugs

From Stephen Frost
Subject Re: BUG #15708: RLS 'using' running as wrong user when called from aview
Date
Msg-id 20190325202723.GC6197@tamriel.snowman.net
Whole thread Raw
In response to Re: BUG #15708: RLS 'using' running as wrong user when called from a view  (Dean Rasheed <dean.a.rasheed@gmail.com>)
Responses Re: BUG #15708: RLS 'using' running as wrong user when called from a view  (Dean Rasheed <dean.a.rasheed@gmail.com>)
Re: BUG #15708: RLS 'using' running as wrong user when called from a view  (Dean Rasheed <dean.a.rasheed@gmail.com>)
List pgsql-bugs
Greetings,

* Dean Rasheed (dean.a.rasheed@gmail.com) wrote:
> On Thu, 21 Mar 2019 at 00:39, PG Bug reporting form
> <noreply@postgresql.org> wrote:
> >
> > This fails, seemingly because the RLS on 'bar' is being checked by alice,
> > instead of the view owner bob:
>
> Yes I agree, that appears to be a bug. The subquery in the RLS policy
> should be checked as the view owner -- i.e., we need to propagate the
> checkAsUser for the RTE with RLS to any subqueries in its RLS
> policies.

Agreed.

> It looks like the best place to fix it is in
> get_policies_for_relation(), since that's where all the policies to be
> applied for a given RTE are pulled together. Patch attached.

Yes, on a quick review, that looks like a good solution to me as well.

Thanks!

Stephen

Attachment

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #15703: Segfault in cancelled CALL-Statements
Next
From: Thomas Munro
Date:
Subject: Re: parallel query hangs - impossible to cancel