Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lAI7s-0008Bj-G0 for pgsql-general@arkaria.postgresql.org; Thu, 11 Feb 2021 19:59:44 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lAI7q-0007xn-0h for pgsql-general@arkaria.postgresql.org; Thu, 11 Feb 2021 19:59:42 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lAI7p-0007xe-PV for pgsql-general@lists.postgresql.org; Thu, 11 Feb 2021 19:59:41 +0000 Received: from tamriel.snowman.net ([70.109.60.50]) by makus.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lAI7n-0006bs-Dz for pgsql-general@lists.postgresql.org; Thu, 11 Feb 2021 19:59:40 +0000 Received: by tamriel.snowman.net (Postfix, from userid 1000) id 9BE5A5F798; Thu, 11 Feb 2021 14:59:37 -0500 (EST) Date: Thu, 11 Feb 2021 14:59:37 -0500 From: Stephen Frost To: Jagmohan Kaintura Cc: Guyren Howe , Tim Cross , Rob Sargent , "pgsql-generallists.postgresql.org" Subject: Re: Encryption of Data Specific to a Tenant in PostgreSQL database | General Idea Message-ID: <20210211195937.GL27507@tamriel.snowman.net> References: <87r1lne4qk.fsf@gmail.com> <9204FB15-3295-490E-90D4-01717B53D49B@gmail.com> <91f67cae-1648-44fc-bfe2-3e01086555dd@Spark> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="Be/1y/e0tGNU7bzq" 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 --Be/1y/e0tGNU7bzq Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Greetings, * Jagmohan Kaintura (jagmohan@tecorelabs.com) wrote: > Yup right now data is being accessed in this manner only. > application access using tenant user only who have specific tenantId in > that session and can see its own data only. It doesn't know about anyone > else's data and neither can get/fetch. >=20 > So isolation is 100% guaranteed right now. Note that views aren't actually guaranteed to provide the isolation you're looking for unless you mark them as being a security barrier, see: https://www.postgresql.org/docs/current/rules-privileges.html Alternatively, you could use RLS and CREATE POLICY: https://www.postgresql.org/docs/current/ddl-rowsecurity.html > But isolation is not enough from an operations perspective, so I need > encryption too in some way or another way, whatever postgreSQL supports > and encryption key should differ for a tenant . You can have PG do encryption by using the pgcrypto extension, perhaps with some custom GUC and views (which should really also be security barrier..) to have it be transparent. As mentioned elsewhere, you're really better off doing it in the application though, so that the DB server doesn't ever see the plaintext data. You should really be considering what the attack vector you're concerned about is though- SQL injection? Insider threat? Improper media disposal? Application server compromise? DB server compromise? etc. Thanks, Stephen --Be/1y/e0tGNU7bzq Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBCgAGBQJgJYypAAoJEO1sijiDR2RVczQP/3PhKC4y3nT5PND43Xw9bm49 jL/sbXA1JcGeBH1UeLPV5V+2l0/FmBtxM3VPLNpo21wAv8wcHqRncDKZ6Pw6O/U+ PMfx0CH6w76kaKL5jnqOvZq15nnEvcRp3m3N+IkKqFny612GL0QbakAuJoxVf6X2 jRZm6Gb+Ghg+ZXJKPUeTt0GRPmG8+fiLnMe8jXwsFTqFHYNWxELWebtZ9uzatmiX IbZQxsKL5Uw64BTZaBL4epMNLmGnl7Cn0EkG562gi8I4hj7Qx6xZCF+tv7H/o4Ji 8r6N7ES2cdFzU3EemTM0UEgBlefz4I3qeTNO/tKyTm/DpUdes6U9V5TX0inaPQZO SUnDDhnZGXyqiHu0Au2ZaiN+VHJJF8LjWm8g1Q7PN4jPpRt110a1RiK6dTpRz7J7 URkXIaC6GeT1PA5j3twaBAoSnUIRCmc9Qfzw0viJnhoVmdKgJ+DppWtbEIjEAiXV h8ymSpaB2i6YqkF6xbMUsHhrbXjGeR2tJxKOx5ipG4Kb0uO0J4BpwRcq7592t/F3 KWTeHVc+wqJTzqpldzqQra+jc5ygttPAw7wgWY3GtBi4LOgBDZeaF59SfxdKU1d3 d5bCxVu+t6+zk8FjF1qVPOkYNoi0DGDryDBs/3jbVhyfdy5qvv7TWluOQr9Py+gn Xse4GMHI+LkU5xROmrFh =Qxnn -----END PGP SIGNATURE----- --Be/1y/e0tGNU7bzq--