Re: Row security violation error is misleading

From: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
To: Stephen Frost <sfrost(at)snowman(dot)net>
Cc: Craig Ringer <craig(at)2ndquadrant(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Row security violation error is misleading
Date: 2015-04-08 17:30:27
Message-ID: CAEZATCWoKi7R=-5DHt54tJUV6gJ46+jk5Bx1W2TDcrPOoxxd_w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 8 April 2015 at 16:27, Stephen Frost <sfrost(at)snowman(dot)net> wrote:
>> 2). In prepend_row_security_policies(), I think it is better to have
>> any table RLS policies applied before any hook policies, so that a
>> hook cannot be used to bypass built-in RLS.
>
> While I agree that we want to include the RLS policies defined against
> the table prior to any policies which are added by the hook, I don't
> quite follow what you mean by "cannot be used to bypass built-in RLS".
> If we allow, as intended, extensions to define their own policies then
> it's entirely possible for the extension to return a "allow all" policy,
> and I believe that's perfectly fine.
>

That doesn't match what the code currently does:

* Also, allow extensions to add their own policies.
*
* Note that, as with the internal policies, if multiple policies are
* returned then they will be combined into a single expression with
* all of them OR'd together. However, to avoid the situation of an
* extension granting more access to a table than the internal policies
* would allow, the extension's policies are AND'd with the internal
* policies. In other words - extensions can only provide further
* filtering of the result set (or further reduce the set of records
* allowed to be added).

which seems reasonable, and means that if there are both internal and
external policies, an "allow all" external policy would be a no-op.

All the patch does is to ensure that the quals from the external
policies are on the outer security barrier, so that if they contain
leaky functions they cannot leak data that doesn't pass the internal
policies (like a SB view on top of another SB view).

Regards,
Dean

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Greg Stark 2015-04-08 18:19:29 Re: Providing catalog view to pg_hba.conf file - Patch submission
Previous Message Peter Geoghegan 2015-04-08 17:17:05 Re: INSERT ... ON CONFLICT IGNORE (and UPDATE) 3.0