pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Stephen Frost <sfrost@snowman.net>
Cc: pgsql-hackers@postgreSQL.org
Subject: Re: [COMMITTERS] pgsql: Fix column-privilege leak in error-message paths
Date: Thu, 29 Jan 2015 17:06:18 -0500
Message-ID: <30446.1422569178@sss.pgh.pa.us> (raw)
In-Reply-To: <E1YGWUl-0004N2-O4@gemulon.postgresql.org>
References: <E1YGWUl-0004N2-O4@gemulon.postgresql.org>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>

Stephen Frost <sfrost@snowman.net> writes:
> Fix column-privilege leak in error-message paths

This patch is at least one brick shy of a load:

regression=# create table t1 (f1 int);
CREATE TABLE
regression=# create unique index on t1 (abs(f1));
CREATE INDEX
regression=# create user joe; 
CREATE ROLE
regression=# grant insert on t1 to joe;
GRANT
regression=# \c - joe
You are now connected to database "regression" as user "joe".
regression=> insert into t1 values (1);
INSERT 0 1
regression=> insert into t1 values (1);
ERROR:  attribute 0 of relation with OID 45155 does not exist

The cause of that is the logic added to BuildIndexValueDescription, which
ignores the possibility that some of the index columns are expressions
(which will have a zero in indkey[]).

I'm not sure that it's worth trying to drill down and determine exactly
which column(s) are referenced by an expression.  I'd be content if we
just decided that any index expression is off-limits to someone without
full SELECT access, which could be achieved with something like

       {
           AttrNumber  attnum = idxrec->indkey.values[keyno];

-           aclresult = pg_attribute_aclcheck(indrelid, attnum, GetUserId(),
-                                             ACL_SELECT);
-
-           if (aclresult != ACLCHECK_OK)
+           if (attnum == InvalidAttrNumber ||
+	        pg_attribute_aclcheck(indrelid, attnum, GetUserId(),
+                                     ACL_SELECT) != ACLCHECK_OK)
           {
               /* No access, so clean up and return */
               ReleaseSysCache(ht_idx);

(though a comment about it wouldn't be a bad thing either)

			regards, tom lane


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



view thread (9+ messages)  latest in thread

Message-ID: <30446.1422569178@sss.pgh.pa.us>
Permalink:  ../30446.1422569178@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/30446.1422569178@sss.pgh.pa.us

 · 

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-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, sfrost@snowman.net, pgsql-hackers@postgreSQL.org
  Subject: Re: [COMMITTERS] pgsql: Fix column-privilege leak in error-message paths
  In-Reply-To: <30446.1422569178@sss.pgh.pa.us>
  References: <E1YGWUl-0004N2-O4@gemulon.postgresql.org> <30446.1422569178@sss.pgh.pa.us>

* 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