pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Stephen Frost <sfrost@snowman.net>
To: Jagmohan Kaintura <jagmohan@tecorelabs.com>
Cc: Guyren Howe <guyren@gmail.com>
Cc: Tim Cross <theophilusx@gmail.com>
Cc: Rob Sargent <robjsargent@gmail.com>
Cc: pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Re: Encryption of Data Specific to a Tenant in PostgreSQL database | General Idea
Date: Thu, 11 Feb 2021 14:59:37 -0500
Message-ID: <20210211195937.GL27507@tamriel.snowman.net> (raw)
In-Reply-To: <CA+cYFtvyptxNRsMm9mMx_Xv2+GeJH_L=Cbanf1WJPcZHr2U0uA@mail.gmail.com>
References: <CA+cYFttZSge7QztGcwgKYF-8ZOWZ-07h1A1qZZkjTUA5=OodxA@mail.gmail.com>
	<87r1lne4qk.fsf@gmail.com>
	<9204FB15-3295-490E-90D4-01717B53D49B@gmail.com>
	<91f67cae-1648-44fc-bfe2-3e01086555dd@Spark>
	<CA+cYFtvyptxNRsMm9mMx_Xv2+GeJH_L=Cbanf1WJPcZHr2U0uA@mail.gmail.com>

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.
> 
> 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

Attachments:

  signature.asc (application/pgp-signature, 818B) download

view thread (10+ messages)  latest in thread

Message-ID: <20210211195937.GL27507@tamriel.snowman.net>
Permalink:  ../20210211195937.GL27507@tamriel.snowman.net/
Also on:    postgresql.org/message-id/20210211195937.GL27507@tamriel.snowman.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: sfrost@snowman.net, jagmohan@tecorelabs.com, guyren@gmail.com, theophilusx@gmail.com, robjsargent@gmail.com
  Subject: Re: Encryption of Data Specific to a Tenant in PostgreSQL database | General Idea
  In-Reply-To: <20210211195937.GL27507@tamriel.snowman.net>
  References: <CA+cYFttZSge7QztGcwgKYF-8ZOWZ-07h1A1qZZkjTUA5=OodxA@mail.gmail.com> <87r1lne4qk.fsf@gmail.com> <9204FB15-3295-490E-90D4-01717B53D49B@gmail.com> <91f67cae-1648-44fc-bfe2-3e01086555dd@Spark> <CA+cYFtvyptxNRsMm9mMx_Xv2+GeJH_L=Cbanf1WJPcZHr2U0uA@mail.gmail.com> <20210211195937.GL27507@tamriel.snowman.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox