pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
permissions denial to superuser with foreign keys
2+ messages / 2 participants
[nested] [flat]

* permissions denial to superuser with foreign keys
@ 2017-11-03 19:42 Jeff Janes <jeff.janes@gmail.com>
  2017-11-03 19:47 ` Re: permissions denial to superuser with foreign keys Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 2+ messages in thread

From: Jeff Janes @ 2017-11-03 19:42 UTC (permalink / raw)
  To: pgsql-bugs

I thought superusers bypassed permissions checks, but was surprised where
in this case they do not:


create user test;
create schema test;
grant all on SCHEMA test to test;
\c postgres test
create table a (x serial primary key);
create table b (x int references a(x) );
insert into a values (1);
\c postgres postgres
revoke all on SCHEMA test from test;
delete from test.a;

ERROR:  permission denied for schema test
LINE 1: SELECT 1 FROM ONLY "test"."a" x WHERE "x" OPERATOR(pg_catalo...
                           ^
QUERY:  SELECT 1 FROM ONLY "test"."a" x WHERE "x" OPERATOR(pg_catalog.=) $1
FOR KEY SHARE OF x


So apparently this is because the bypass is based on the euid, not ruid, at
least in that part of the code.

Is this the way it is supposed to be?  It seems like a bad idea to make the
superuser jump through a bunch of hoops to do what he wants, it is just
more places where a mistake might be made.

This does not seem to be version-specific.

Cheers,

Jeff

^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: permissions denial to superuser with foreign keys
  2017-11-03 19:42 permissions denial to superuser with foreign keys Jeff Janes <jeff.janes@gmail.com>
@ 2017-11-03 19:47 ` Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2017-11-03 19:47 UTC (permalink / raw)
  To: Jeff Janes <jeff.janes@gmail.com>; +Cc: pgsql-bugs

Jeff Janes <jeff.janes@gmail.com> writes:
> I thought superusers bypassed permissions checks, but was surprised where
> in this case they do not:

This amounts to asking for superuser permissions to propagate into
SECURITY DEFINER functions called by the superuser, which strikes me
as an utterly horrid idea.

(RI triggers aren't actually implemented with the SECURITY DEFINER
mechanism, but they act like they are.)

			regards, tom lane


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2017-11-03 19:47 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2017-11-03 19:42 permissions denial to superuser with foreign keys Jeff Janes <jeff.janes@gmail.com>
2017-11-03 19:47 ` Tom Lane <tgl@sss.pgh.pa.us>

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