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 1lA2cE-0007xM-B7 for pgsql-general@arkaria.postgresql.org; Thu, 11 Feb 2021 03:26:02 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lA2cC-0003ly-00 for pgsql-general@arkaria.postgresql.org; Thu, 11 Feb 2021 03:26:00 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lA2cB-0003lq-JT for pgsql-general@lists.postgresql.org; Thu, 11 Feb 2021 03:25:59 +0000 Received: from mail-pg1-x52e.google.com ([2607:f8b0:4864:20::52e]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1lA2c6-0005p6-Iw for pgsql-general@lists.postgresql.org; Thu, 11 Feb 2021 03:25:58 +0000 Received: by mail-pg1-x52e.google.com with SMTP id b21so2823492pgk.7 for ; Wed, 10 Feb 2021 19:25:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:message-id:in-reply-to:references:subject :mime-version; bh=RcjjUKZnOBA5MXmbQp+LsThLSdpgaFSqX7esVQkYcmw=; b=M0Fvz5n8SmqemQSO7yuaJ1TSLIU4ZgB/t80+7CdXJOrA9Cat74RBsKPxCbWWJKHyrw oa8HdUpRVxAr2EYX3rgfRQz21LTBuORvhwgqlZIWuexiUkCr9u7SLA46EFnYnBnEhPqb yYMZ9O6eqwl3/PH84lx9r52EiwQGgJLXzjzOtCFOXRE2PsfC6Ddtmm2NNQG4T7+CdPAY 644bjIUz9aiKUGI5Wa4j4OdgyHMguNKoL+DcadjYpzTR7G9ABDjnmxiHAjG3Q0QWy0ka eja7IH9WOenDR6EvYGCsndHdbL+H7Gj9aQW5t2SbYJ+2MAWCIlUJSKn8rE6fviq2kcKO XW+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:message-id:in-reply-to :references:subject:mime-version; bh=RcjjUKZnOBA5MXmbQp+LsThLSdpgaFSqX7esVQkYcmw=; b=n8hykzSEFZXZKYrAskrK2kWeqRZa+Ovq1WE34EgQbSmWC98NlZGgOhtvGFrpsdXL1Q 0urnQO0D6C5D3QFUzSq6hf5xGWCFvzixE+uqWzpXE3Wwl9qJVuyChsO9XHDomPjUbJSV zacp3zIPZdzxvhEM9oj7c30XAQzMUCGzV5R69BhIpIaTkeTbJqHPlU0uM4yPmuhACa4z PXr2NAqZ1WVAJV7MtoNsUCZXTJpW++VExXtt4YHMGDsJis7sUrr3AncX0higOG/ss57l ZcYGRO4Fhh7aJo/rHa2UHTt0S7NgTcoFnHx/9+Z3UnhePo3jWq7s7kZkniYID/S7A2MO r5EQ== X-Gm-Message-State: AOAM531w/wD3+u46Mk4Tp+mAutIDG87D0VeZLLNr8z64emf/qY2dk5cE 3eL63mQJwwpJIa/MjcqmKQ0= X-Google-Smtp-Source: ABdhPJyrGDkQpEkFKzqn2y0/gGQD+ejTi89/aNG/t7JIYCTuc7q8diPTmBm/g4eNIspBXKiQhp4h2g== X-Received: by 2002:a63:1845:: with SMTP id 5mr3258114pgy.244.1613013951508; Wed, 10 Feb 2021 19:25:51 -0800 (PST) Received: from [2600:8801:8800:11:d0e5:b485:200:0] ([2600:8801:8800:11::12]) by smtp.gmail.com with ESMTPSA id p12sm1289250pjz.34.2021.02.10.19.25.50 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Feb 2021 19:25:50 -0800 (PST) Date: Wed, 10 Feb 2021 19:25:40 -0800 From: Guyren Howe To: Tim Cross , Rob Sargent Cc: pgsql-general@lists.postgresql.org Message-ID: <91f67cae-1648-44fc-bfe2-3e01086555dd@Spark> In-Reply-To: <9204FB15-3295-490E-90D4-01717B53D49B@gmail.com> References: <87r1lne4qk.fsf@gmail.com> <9204FB15-3295-490E-90D4-01717B53D49B@gmail.com> Subject: Re: Encryption of Data Specific to a Tenant in PostgreSQL database | General Idea X-Readdle-Message-ID: 91f67cae-1648-44fc-bfe2-3e01086555dd@Spark MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="6024a3bc_2eb141f2_1f75" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --6024a3bc_2eb141f2_1f75 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline An interesting option is to make your tenants work through views, and hav= e the views work through a variable that contains the tenant=E2=80=99s id= . There would be a bit of coding, but it would be the same for every tabl= e, so you could automate it easy enough. When you=E2=80=99re done, client software just sets the id at the beginni= ng of the session and the database looks like it only contains the tenant= =E2=80=99s data. This is a particularly nice security guarantee: if you make the id a UUID= (ie unguessable) then someone can entirely compromise the client applica= tion, and can still only get at the data for one tenant, and then only gi= ven their ID. On =46eb 10, 2021, 18:44 -0800, Rob Sargent , wr= ote: > > > > On =46eb 10, 2021, at 6:45 PM, Tim Cross wr= ote: > > > > > > Jagmohan Kaintura writes: > > > > > HI All, > > > > > > =46or POstgreSQL database to store data for multiple tenants, the a= pproach > > > decided was to have > > > Shared Database (Holding data for all tenants) > > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=3D> Data would be segregated on basi= s of some additional column > > > (tennatid,different tenants having different tenantId) > > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=3D> Da= ta would be accessed through Views on the basis of tenantId > > > value. > > > > > > This is the basic process of most of the customers who are trying t= o > > > 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. =C2=A0Moreover= pg=5Fcrypto > > > 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 cle= ar > > 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=21 > > > > 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=3F= How > > would you select the data for your tenant views if all that data is > > encrypted with different keys=3F How would you manage these keys in a= > > secure manner=3F > > > > 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-interp= ret > > the requirement to make the objective feasible. > > > Yeah, I lost that same arguement in =7E2007, where the forces against m= y push for separation was shouted down with rants on scheme maintenance (= divergence) and multiple rollouts per update. =C2=A0I hadn=E2=80=99t had = any coffee before the 9:00am meeting so the hotshot from Amazon got his w= ay. =C2=A0Then we tried =E2=80=9Cveils=E2=80=9D (a concoction of view and= rule re-writing) and we all know=C2=A0how that went. =C2=A0The company f= olded 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 leas= t quite common (on the last of =E2=80=9Cbig iron=E2=80=9D=3F) but it stil= l doesn=E2=80=99t sit well with me. > > --6024a3bc_2eb141f2_1f75 Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline
An interesting option is to make your tenants work = through views, and have the views work through a variable that contains t= he tenant=E2=80=99s id. There would be a bit of coding, but it would be t= he same for every table, so you could automate it easy enough.

When you=E2=80=99re done, client software just sets the id at the beginni= ng of the session and the database looks like it only contains the tenant= =E2=80=99s data.

This is a particularly nice security guarantee: if you make the id a UUID= (ie unguessable) then someone can entirely compromise the client applica= tion, and can still only get at the data for one tenant, and then only gi= ven their ID.
On =46eb 10, 2021, 18:44 -0800, Rob= Sargent <robjsargent=40gmail.com>, wrote:


On =46eb 10, 2021, at 6:45 PM, Tim Cross <theophilusx=40gmail.c= om> wrote:


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

HI All,

=46or POstgreSQL database to store data for multiple tenants, the approac= h
decided was to have
Shared Database (Holding data for all tenants)
&=23160;&=23160;&=23160;&=23160;&=23160;=3D> Data would be segregated = on basis of some additional column
(tennatid,different tenants having different tenantId)
&=23160;&=23160;&=23160;&=23160;&=23160;&=23160;&=23160;&=23160;&=23160;&= =23160;=3D> Data would be accessed through Views on the basis of tenan= tId
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. &=23160;Moreover pg=5F= crypto
will impose a single key on the column.

Please share your thoughts in which direction i can start analysing this<= br class=3D=22=22 /> area for encryption of data specific to a tenant.


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

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=3F How
would you select the data for your tenant= views if all that data is
encrypted with different keys=3F How woul= d you manage these keys in a
secure manner=3F

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. th= is 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 i= s assuming you can re-interpret
the requirement to make the objective fea= sible.

Yeah, I lost that same arguement in =7E2007, where the forces against my = push for separation was shouted down with rants on scheme maintenance (di= vergence) and multiple rollouts per update. &=23160;I hadn=E2=80=99t had = any coffee before the 9:00am meeting so the hotshot from Amazon got his w= ay. &=23160;Then we tried =E2=80=9Cveils=E2=80=9D (a concoction of view a= nd rule re-writing) and we all know&=23160;how that went. &=23160;The com= pany 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 t= hese days, at least quite common (on the last of =E2=80=9Cbig iron=E2=80=9D= =3F) but it still doesn=E2=80=99t sit well with me.
&=23160;

--6024a3bc_2eb141f2_1f75--