lastval exposes information that currval does not

Поиск
Список
Период
Сортировка
От Phil Frost
Тема lastval exposes information that currval does not
Дата
Msg-id 20060705185109.GA29665@unununium.org
обсуждение исходный текст
Ответы Re: lastval exposes information that currval does not  (Chris Campbell <chris@bignerdranch.com>)
Список pgsql-hackers
test=# create schema private;
CREATE SCHEMA
test=# create sequence private.seq;
CREATE SEQUENCE
test=# create function bump() returns bigint language sql security definer as $$ select nextval('private.seq'); $$;
CREATE FUNCTION
test=# revoke usage on schema private from pfrost;
REVOKE
test=# grant select, update on private.seq to  pfrost;
GRANT
test=# set role pfrost;
SET
test=> select bump();bump 
------   1
(1 row)
test=> select nextval('private.seq');
ERROR:  permission denied for schema private
test=> select currval('private.seq');
ERROR:  permission denied for schema private
test=> select lastval();lastval 
---------      1
(1 row)


Aparrently, lastval remembers the last sequence by OID, and the check
for usage on a schema is made when resolving a name to an OID. Thus, the
schema usage check is never made for lastval.

Firstly there is the problem that this potentially reveals information
that was not visible prior to 8.1. Granted, I don't think this is a
serious security issue for most applications, but it does suprise me.

There is also the larger problem of the implementation of schema usage
checks. More serious functions might be added in the future that suffer
from the same vulnerability. For all I know, there might be some now. I
should think that a much better place for this check would be in the
same place that checks the ACL for the object itself.


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Andrew Dunstan
Дата:
Сообщение: Re: binds only for s,u,i,d?
Следующее
От: Chris Mair
Дата:
Сообщение: Re: buildfarm stats