Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YGxRq-0003Z4-Ib for pgsql-hackers@arkaria.postgresql.org; Thu, 29 Jan 2015 22:20:26 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YGxRq-0004yS-2K for pgsql-hackers@arkaria.postgresql.org; Thu, 29 Jan 2015 22:20:26 +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 1YGxRo-0004yM-Kz for pgsql-hackers@postgreSQL.org; Thu, 29 Jan 2015 22:20:24 +0000 Received: from tamriel.snowman.net ([2001:4830:167b::11]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YGxRg-0005nq-Mn for pgsql-hackers@postgreSQL.org; Thu, 29 Jan 2015 22:20:23 +0000 Received: by tamriel.snowman.net (Postfix, from userid 1000) id B68C35F79E; Thu, 29 Jan 2015 17:20:14 -0500 (EST) Date: Thu, 29 Jan 2015 17:20:14 -0500 From: Stephen Frost To: Tom Lane Cc: pgsql-hackers@postgreSQL.org Subject: Re: [COMMITTERS] pgsql: Fix column-privilege leak in error-message paths Message-ID: <20150129222014.GQ3854@tamriel.snowman.net> References: <30446.1422569178@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="UYE1pkz89qwWeywf" Content-Disposition: inline In-Reply-To: <30446.1422569178@sss.pgh.pa.us> X-Editor: Vim http://www.vim.org/ X-Info: http://www.snowman.net X-Operating-System: Linux/3.13.0-45-generic (x86_64) X-Uptime: 17:17:23 up 7 days, 22:06, 3 users, load average: 0.17, 0.13, 0.08 User-Agent: Mutt/1.5.21 (2010-09-15) 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 --UYE1pkz89qwWeywf Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable * Tom Lane (tgl@sss.pgh.pa.us) wrote: > Stephen Frost writes: > > Fix column-privilege leak in error-message paths >=20 > This patch is at least one brick shy of a load: >=20 > regression=3D# create table t1 (f1 int); > CREATE TABLE > regression=3D# create unique index on t1 (abs(f1)); > CREATE INDEX > regression=3D# create user joe;=20 > CREATE ROLE > regression=3D# grant insert on t1 to joe; > GRANT > regression=3D# \c - joe > You are now connected to database "regression" as user "joe". > regression=3D> insert into t1 values (1); > INSERT 0 1 > regression=3D> insert into t1 values (1); > ERROR: attribute 0 of relation with OID 45155 does not exist Urgh. > 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[]). Ah, yes, I didn't expect that, clearly. > 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 Sounds perfectly reasonable to me. > { > AttrNumber attnum =3D idxrec->indkey.values[keyno]; >=20 > - aclresult =3D pg_attribute_aclcheck(indrelid, attnum, GetUser= Id(), > - ACL_SELECT); > - > - if (aclresult !=3D ACLCHECK_OK) > + if (attnum =3D=3D InvalidAttrNumber || > + pg_attribute_aclcheck(indrelid, attnum, GetUserId(), > + ACL_SELECT) !=3D ACLCHECK_OK) > { > /* No access, so clean up and return */ > ReleaseSysCache(ht_idx); Yup, that looks good to me. > (though a comment about it wouldn't be a bad thing either) Agreed. Will handle shortly. Thanks! Stephen --UYE1pkz89qwWeywf Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBCgAGBQJUyrIeAAoJEO1sijiDR2RVO9gQAKcdFrhXiOVbCNwEl1Fzwslx mNuJEdXVFYhKWIpOGmFybawsWBVMqLlMfTko5qelhsxtBLUsDRLfMqA+vhTcfn68 yt0iAqg5W1MRL/uxDjRKunvtLVjtK9byJBczS0iPOfsM8wvXdF9PGqR6Rtbt/z13 5PJ8uOpR5o5H1kQQgfjEPook2Kc8bGerOjL4zAcqO5LaExGYJ/u3roy8MkXWHy/k PK5H5zJw7lv2PO/RPXqZrgGl0k1TxURCGcgPwNG9V2+MfvQ5O55g7Rg0OmNbHSwO B5hm8KH6V0fE8GMAO24rkC5xBoU4GaO8CiYmupCh+aJSpC8/zaANAA1GD6d+O5hJ oqSIAtnw4ye5j2OvmOqE5T+xvVhh0QO+yBKjpRfLktFnHOypvvoCwDnNVrp+V58B pcmF20hE37xVabAmh4IpKLUNBeuZTAgHEGvUAiZBYzwUNfxwRkYCdDeFb7UBEDFz lzOznakmLcPpowEv/w5DqaRQ8xJapfYOmrmLWtqfDvYkWlwcN6wGY8kQTYDGsr3E P4wC+4ZBl8W+F5aTmNpevqkaS7zdlG8uzGZ8TEvuYDi4Af5XQoYiuVYrO67ZQMR3 eA/t72cUdJuUG1qdurWbCX8e/KpqzEj4Nc5Js/gud+Czr2TXgU3BWyzL2RWlFgA0 kQq69SjyoGPHpSiWpmEU =2nk0 -----END PGP SIGNATURE----- --UYE1pkz89qwWeywf--