pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Joe Conway <mail@joeconway.com>
To: David Wheeler <dwheeler@dgitsystems.com>
To: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
Cc: Cameron Redpath <credpath@dgitsystems.com>
Subject: Re: Permission inconsistency with views that call functions
Date: Tue, 23 Feb 2021 10:41:22 -0500
Message-ID: <1ee7853f-806f-438f-25d5-16bc7eeeba11@joeconway.com> (raw)
In-Reply-To: <PS2PR06MB2551F46C4FE553D1C2053741DD809@PS2PR06MB2551.apcprd06.prod.outlook.com>
References: <PS2PR06MB2551F46C4FE553D1C2053741DD809@PS2PR06MB2551.apcprd06.prod.outlook.com>

On 2/22/21 10:32 PM, David Wheeler wrote:
> I’m seeing some inconsistency with how permissions are enforced within views. In
> particular, if the view accesses a table directly, then the table is accessible,
> however if the view uses a function to access the table then permission is denied.

Without looking too closely at the details, I can almost guarantee that the
issue is that FUNCTIONs default to "SECURITY INVOKER" whereas VIEWs operate as
if they were "SECURITY DEFINER". See slide 33 here:

http://joeconway.com/presentations/security-pgcon2020.pdf

The solution to your issue is possibly to make the function "SECURITY DEFINER".

I have mused previously (not sure if I ever did on the lists, but in any case)
that it would be cool if VIEWs could have the option to be either DEFINER or
INVOKER so that VIEWs and FUNCTIONs could be treated the same, but no efforts
have been made in that direction as far as I am aware.

HTH,

Joe

-- 
Crunchy Data - http://crunchydata.com
PostgreSQL Support for Secure Enterprises
Consulting, Training, & Open Source Development

Attachments:

  signature.asc (application/pgp-signature, 832B) download

view thread (3+ messages)  latest in thread

Message-ID: <1ee7853f-806f-438f-25d5-16bc7eeeba11@joeconway.com>
Permalink:  ../1ee7853f-806f-438f-25d5-16bc7eeeba11@joeconway.com/
Also on:    postgresql.org/message-id/1ee7853f-806f-438f-25d5-16bc7eeeba11@joeconway.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: mail@joeconway.com, dwheeler@dgitsystems.com, credpath@dgitsystems.com
  Subject: Re: Permission inconsistency with views that call functions
  In-Reply-To: <1ee7853f-806f-438f-25d5-16bc7eeeba11@joeconway.com>
  References: <PS2PR06MB2551F46C4FE553D1C2053741DD809@PS2PR06MB2551.apcprd06.prod.outlook.com> <1ee7853f-806f-438f-25d5-16bc7eeeba11@joeconway.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox