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 1lA1yo-0006Mu-Uk for pgsql-general@arkaria.postgresql.org; Thu, 11 Feb 2021 02:45:19 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lA1yE-0005gM-Lz for pgsql-general@arkaria.postgresql.org; Thu, 11 Feb 2021 02:44: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 1lA1yD-0005gF-Ez for pgsql-general@lists.postgresql.org; Thu, 11 Feb 2021 02:44:41 +0000 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1lA1yA-0006jZ-Ll for pgsql-general@lists.postgresql.org; Thu, 11 Feb 2021 02:44:40 +0000 Received: by mail-pl1-x631.google.com with SMTP id a16so2456080plh.8 for ; Wed, 10 Feb 2021 18:44:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:message-id:mime-version:subject:date:in-reply-to:cc:to :references; bh=+qROBEFycrFFg2bumCLXG4vuXiNZTnIwmDCUuTm3vT4=; b=HDTxWNKIhhi8bZyP2kfW18XDd4mfDi7hGojGVWbYFCAcVVWk07pv8+aqchqQeDt6py gpqLilpOfHzMsoZSLWkMH1h4Mc8ZB6fupku1v7HTgTYWB8RifmtmBMyMaMM/eMGOTpnG KmDdDZoyyvqIbrfxEXd7CeAwRFRWyHIqLQPMZI277Mu9MuaRt0JfCgTrNDZkoPeZ464W Cjzl6hFHsCa7/6dbIYGbIHg9VRPVdbzkC0hkVm+enkbNNy++ozYPpp+VOfHLkQ9ACfCs 5OpSVxruEoKPH01jj2sJfxwR9Gv4eWxm5qcPoQNO3e6s8XDxEMOOJ2RGMgadtcl8Iz5E UF0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:message-id:mime-version:subject:date :in-reply-to:cc:to:references; bh=+qROBEFycrFFg2bumCLXG4vuXiNZTnIwmDCUuTm3vT4=; b=UpJ8oAw0PFb8ID+HYkrv+StOIScXiiOEJcjZiVvbVtemVqylUk/kqSv2VRpgoEGMb9 xE5ClH8SFqWDp4c/4JSrNO/V4enqDMUBfubbe9XvQYNR2omMneTguK3bxA7Kpnog8N3y ib43jnaQm8uYiqdIymu8bk5R4wnZPdLEx7HYnkgdQwNoM77HtYC4qkOnkMDFO+hlnHWh nIm9R10nKVj6BGE64UebZwIG7dFSh3nNxWdT0qR5FrJn2skUWJdeODwUjqhZR/GHieXJ 1plQJlXYdwebQGOJPLKUI42Y0j8RAxhlu2HM0s0vzH1MiOSP+SBJqKnOFBGe+2SA4X96 ltsA== X-Gm-Message-State: AOAM530sY9Gcwh1IS0d8yA1xxFePD3cG9M0GYE2ztp1OFfzlGKIJ63Vl 6Z5i/oCcotepE1CS5PSqjo4= X-Google-Smtp-Source: ABdhPJwxEQnp7DhiHqZOgtCwKGBF2ZZeiBUk2D7Ajp8Ipa6VfJpthm2f8eGhN+zLTgEcJIpKslMlVg== X-Received: by 2002:a17:90b:3886:: with SMTP id mu6mr1820573pjb.153.1613011477121; Wed, 10 Feb 2021 18:44:37 -0800 (PST) Received: from risk-166795.ad.utah.edu ([155.98.131.4]) by smtp.gmail.com with ESMTPSA id g8sm3472251pfv.140.2021.02.10.18.44.36 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Feb 2021 18:44:36 -0800 (PST) From: Rob Sargent Message-Id: <9204FB15-3295-490E-90D4-01717B53D49B@gmail.com> Content-Type: multipart/alternative; boundary="Apple-Mail=_A450451B-B0C4-4905-BA8D-3C27C907DB0E" Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.4\)) Subject: Re: Encryption of Data Specific to a Tenant in PostgreSQL database | General Idea Date: Wed, 10 Feb 2021 19:44:35 -0700 In-Reply-To: <87r1lne4qk.fsf@gmail.com> Cc: pgsql-general@lists.postgresql.org To: Tim Cross References: <87r1lne4qk.fsf@gmail.com> X-Mailer: Apple Mail (2.3608.120.23.2.4) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --Apple-Mail=_A450451B-B0C4-4905-BA8D-3C27C907DB0E Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On Feb 10, 2021, at 6:45 PM, Tim Cross wrote: >=20 >=20 > Jagmohan Kaintura > writes: >=20 >> HI All, >>=20 >> For POstgreSQL database to store data for multiple tenants, the = approach >> decided was to have >> Shared Database (Holding data for all tenants) >> =3D> Data would be segregated on basis of some additional column >> (tennatid,different tenants having different tenantId) >> =3D> Data would be accessed through Views on the basis of = tenantId >> value. >>=20 >> This is the basic process of most of the customers who are trying to >> implement multiple tenants in PostgreSQL, rather than choosing >> separate databases for each tenant. >>=20 >> Now we need to encrypt the data related to a tenantId, so that now = one >> knows this data belongs to which tenant even from Operations group. >> Is there a method in POstgreSQL for encrypting data with different = keys >> with respect to different values in a single column. Moreover = pg_crypto >> will impose a single key on the column. >>=20 >> Please share your thoughts in which direction i can start analysing = this >> area for encryption of data specific to a tenant. >>=20 >=20 > The decision to have all tenants in a single database seems rather > unusual to me. Isolating one tenant from adversely impacting another > would seem complicated and I'm not sure how you would implement a = clear > security model. Your model has effectively bypassed all the provided = PG > facilities for isolation of data. Disaster recovery and business > continuity planning under this model must be a nightmare! >=20 > I doubt you can adopt a solution which is solely within the database. > How would the database know which key to use for which rows of data? = How > would you select the data for your tenant views if all that data is > encrypted with different keys? How would you manage these keys in a > secure manner? >=20 > With the model you have adopted, I would be looking at performing > encryption/decryption at the client level. However, depending on your > data types, this could be challenging. this is really a requirement > which should have been factored into the initial architecture design. > Anything you try to bolt on now is likely to be complex and have > significant performance impact and that is assuming you can = re-interpret > the requirement to make the objective feasible. >=20 Yeah, I lost that same arguement in ~2007, where the forces against my = push for separation was shouted down with rants on scheme maintenance = (divergence) and multiple rollouts per update. I hadn=E2=80=99t had any = coffee before the 9:00am meeting so the hotshot from Amazon got his way. = Then we tried =E2=80=9Cveils=E2=80=9D (a concoction of view and rule = re-writing) and we all know how that went. The company folded before = our =E2=80=9Cnext gen=E2=80=9D software saw the light of day. I get the feeling multi-tenancy is, if not the rule these days, at least = quite common (on the last of =E2=80=9Cbig iron=E2=80=9D?) but it still = doesn=E2=80=99t sit well with me. =20 --Apple-Mail=_A450451B-B0C4-4905-BA8D-3C27C907DB0E Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8

On Feb 10, 2021, at 6:45 PM, Tim Cross <theophilusx@gmail.com> wrote:


Jagmohan = Kaintura <jagmohan@tecorelabs.com> writes:

HI All,

For POstgreSQL database to store data for multiple tenants, = the approach
decided was to have
Shared = Database (Holding data for all tenants)
     =3D> Data would be = segregated on basis of some additional column
(tennatid,different tenants having different tenantId)
          =3D= > Data would be accessed through Views on the basis of tenantId
value.

This is the basic process = of most of the customers who are trying to
implement = multiple tenants in PostgreSQL, rather than choosing
separate databases for each tenant.

Now we need to encrypt the data related to a tenantId, so = that now one
knows this data belongs to which tenant even = from Operations group.
Is there a method in POstgreSQL for = encrypting data with different keys
with respect to = different values in a single column.  Moreover pg_crypto
will impose a single key on the column.

Please share your thoughts in which direction i can start = analysing this
area for encryption of data specific to a = tenant.


The decision = to have all tenants in a single database seems rather
unusual to = me. Isolating one tenant from adversely impacting another
would seem = complicated and I'm not sure how you would implement a clear
security = model. Your model has effectively bypassed all the provided PG
facilities = for isolation of data. Disaster recovery and business
continuity = planning under this model must be a nightmare!

I doubt you = can adopt a solution which is solely within the database.
How would the = database know which key to use for which rows of data? How
would you = select the data for your tenant views if all that data is
encrypted = with different keys? How would you manage these keys in a
secure = manner?

With the = model you have adopted, I would be looking at performing
encryption/decryption at the client level. However, depending = on your
data types, = this could be challenging. this is really a requirement
which should = have been factored into the initial architecture design.
Anything you = try to bolt on now is likely to be complex and have
significant = performance impact and that is assuming you can re-interpret
the = requirement to make the objective feasible.

Yeah, I lost that same = arguement in ~2007, where the forces against my push for separation was = shouted down with rants on scheme maintenance (divergence) and multiple = rollouts per update.  I hadn=E2=80=99t had any coffee before the = 9:00am meeting so the hotshot from Amazon got his way.  Then we = tried =E2=80=9Cveils=E2=80=9D (a concoction of view and rule re-writing) = and we all know how that went.  The company folded before our = =E2=80=9Cnext gen=E2=80=9D software saw the light of day.

I get the feeling = multi-tenancy is, if not the rule these days, at least quite common (on = the last of =E2=80=9Cbig iron=E2=80=9D?) but it still doesn=E2=80=99t = sit well with me.
 

= --Apple-Mail=_A450451B-B0C4-4905-BA8D-3C27C907DB0E--