Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h8WBs-0002wR-Mt for pgsql-bugs@arkaria.postgresql.org; Mon, 25 Mar 2019 20:27:28 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1h8WBr-0008MC-Bg for pgsql-bugs@arkaria.postgresql.org; Mon, 25 Mar 2019 20:27:27 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h8WBr-0008M4-4p for pgsql-bugs@lists.postgresql.org; Mon, 25 Mar 2019 20:27:27 +0000 Received: from tamriel.snowman.net ([2001:470:e38f::11]) by magus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1h8WBo-0000Iw-Jm for pgsql-bugs@lists.postgresql.org; Mon, 25 Mar 2019 20:27:26 +0000 Received: by tamriel.snowman.net (Postfix, from userid 1000) id DD9065F7A7; Mon, 25 Mar 2019 16:27:23 -0400 (EDT) Date: Mon, 25 Mar 2019 16:27:23 -0400 From: Stephen Frost To: Dean Rasheed Cc: quae@daurnimator.com, pgsql-bugs@lists.postgresql.org, PostgreSQL Hackers Subject: Re: BUG #15708: RLS 'using' running as wrong user when called from a view Message-ID: <20190325202723.GC6197@tamriel.snowman.net> References: <15708-d65cab2ce9b1717a@postgresql.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="PoYccR3eS5j8BMvh" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --PoYccR3eS5j8BMvh Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Greetings, * Dean Rasheed (dean.a.rasheed@gmail.com) wrote: > On Thu, 21 Mar 2019 at 00:39, PG Bug reporting form > wrote: > > > > This fails, seemingly because the RLS on 'bar' is being checked by alic= e, > > instead of the view owner bob: >=20 > Yes I agree, that appears to be a bug. The subquery in the RLS policy > should be checked as the view owner -- i.e., we need to propagate the > checkAsUser for the RTE with RLS to any subqueries in its RLS > policies. Agreed. > It looks like the best place to fix it is in > get_policies_for_relation(), since that's where all the policies to be > applied for a given RTE are pulled together. Patch attached. Yes, on a quick review, that looks like a good solution to me as well. Thanks! Stephen --PoYccR3eS5j8BMvh Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBCgAGBQJcmTmrAAoJEO1sijiDR2RVsFIP/0eBzoxak/c/564/H/RGFbHU fwAjmbs54Vs4Y9VF8kp77/IhUKITQyVU78Z7rDzxnwZNppmp2H48JIwYMaov4D0D Bw//f8t9ihmJsZtDuT/TSNX3PmwXJBYvSg+ZM/KsdxNUKWF/S73Y6NywjU58yZi9 cG7pUuTPjJGefva1Xe0OYIv3KL5ccUCljkEHWGLEXkyUSWd5PMlneAwDCNSlk062 wTPHM9OOwHu1XvZ55I0J3wjwNy7jzB+WvipVxw2sQIgqwceAfOMmGy98swnOfCSA U22fbvfFvC5B9FFTrVpoqIVRlG96H4LjSVmhntB6ed7xiMT4wfLWqrBIJKlPssji b2tPVdmXuXjx5vashHlRPgc2tFBJPSt1EvRV0hcJ5k2QEVq/YH4q5/qT3Zb0G1Ru HJqchXizM8jAdsz264rbLNaasbK3DRHykk6MMQyrsyJVQhAfDxdplLhwhTb94qkO JpMOLethKKIktxEe8sorNi8kXcuB/xAXiMD0vAJgkFk2eqIdJpo8j4+xMv7RImq9 9BCFFmYo10W4+IxAxPG0kE/MKdyQzXzkpBp4IFIJa/sqXjyCl1uBT4kXXOyfeWTx GB6JAAgUqpi9XfpTVj/9JiSdo393yltdy2Hlp8gOIL8m643FvtS3AlN9KEEg1tAg GDfhCp956fjTh0INgmAH =1ofm -----END PGP SIGNATURE----- --PoYccR3eS5j8BMvh--