Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YGxEH-00035Z-I4 for pgsql-hackers@arkaria.postgresql.org; Thu, 29 Jan 2015 22:06:25 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YGxEH-0000Mq-2C for pgsql-hackers@arkaria.postgresql.org; Thu, 29 Jan 2015 22:06:25 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YGxEF-0000Mh-RG for pgsql-hackers@postgreSQL.org; Thu, 29 Jan 2015 22:06:23 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YGxEC-0005Wg-Jh for pgsql-hackers@postgreSQL.org; Thu, 29 Jan 2015 22:06:22 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id t0TM6IVB030447; Thu, 29 Jan 2015 17:06:18 -0500 From: Tom Lane To: Stephen Frost cc: pgsql-hackers@postgreSQL.org Subject: Re: [COMMITTERS] pgsql: Fix column-privilege leak in error-message paths In-reply-to: References: Comments: In-reply-to Stephen Frost message dated "Wed, 28 Jan 2015 17:33:39 +0000" Date: Thu, 29 Jan 2015 17:06:18 -0500 Message-ID: <30446.1422569178@sss.pgh.pa.us> X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org Stephen Frost 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