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 1lA1Ow-00055L-Iq for pgsql-general@arkaria.postgresql.org; Thu, 11 Feb 2021 02:08:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lA1Ov-0007an-Ce for pgsql-general@arkaria.postgresql.org; Thu, 11 Feb 2021 02:08:13 +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 1lA1Ov-0007ag-4y for pgsql-general@lists.postgresql.org; Thu, 11 Feb 2021 02:08:13 +0000 Received: from mail-pf1-x42b.google.com ([2607:f8b0:4864:20::42b]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1lA1Os-0005HP-UQ for pgsql-general@lists.postgresql.org; Thu, 11 Feb 2021 02:08:12 +0000 Received: by mail-pf1-x42b.google.com with SMTP id t29so2654996pfg.11 for ; Wed, 10 Feb 2021 18:08:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=references:user-agent:from:to:subject:date:in-reply-to:message-id :mime-version; bh=uXYSpV+DdgdO54pY6kzXXZrmzydGt63Syss3ahkpijk=; b=dk2m5/eti15M81V7m6/zRVK/iWsYLLSTQD4rpi9hPjB7K8Y/pFDDZITkeM0c8r9SOi bKAJmcjQRow++/Wzeipyr5cGPovjXD/Vi5DBmlcXiOsaKOI57LwpDGQOZDVvUT8IzhLe f/piWgP/5gDC2K4LATT30foIoU6pP5nPuCuQ4Wst4+P1Kzu3d8aUVDJAjFZdyNLktY5u o0KQwI2OdrEi4qg0moby+gGf0pHSKG/UYFlILZu9lS6AP0BbkS0IUefDNWjobtcxbd9o c9O5DJp4IWf9xC5+DCezSoSIoVQlvAHBOnOz7L/+/ikuyq7JcEHQfQ9Hzaz8VcwRea6X yLmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:references:user-agent:from:to:subject:date :in-reply-to:message-id:mime-version; bh=uXYSpV+DdgdO54pY6kzXXZrmzydGt63Syss3ahkpijk=; b=uYbzM5v2OVqpVDFD9uN1YpdNHQwMuTNRQjVJaiWxUGRKY1yJpiQVfoz9GTdfRrAm6u qOMh6HpvL7ygqxL7HMq7KSUda9Nv+xLOzJOk29arA/jbRzA5GHhYCfb/tnJO9P0Mqxp+ n8pPnEnUJwr0ylumXKJmB4EpivTzdttEkwltZKAnvEoeZgH0wv+JrzBSIWWvIosz2FNx DFPI0m/PnV84+skb73btBJom55prutAHjQNQlBLbdiDzzJBcCil4Q8Euua8clMHkeYZM ur5zqYanBoBm9fPSbnyGCpM3OV6Nn+IH+K/xY18uP62qT2uNlx3xXOuZ1YENUw5VF1++ s8WA== X-Gm-Message-State: AOAM530Lbj9gXELiWnExhrNTuqGYhTvRP8b2WjP9Zi/ZZ1TLe3+qmz2B lKVLPtByt8Q9dOs/ZwYkLpJuZcardKc= X-Google-Smtp-Source: ABdhPJxRsHU54dkjoz0QlWNTZbYt8QqJth626ZrwGiPBNMXKv1NzIttreLuHdQEBG5GnwlQlCg9cRA== X-Received: by 2002:a63:70f:: with SMTP id 15mr5751287pgh.250.1613009288441; Wed, 10 Feb 2021 18:08:08 -0800 (PST) Received: from tim-desktop (220-235-10-230.dyn.iinet.net.au. [220.235.10.230]) by smtp.gmail.com with ESMTPSA id t21sm3484565pfe.174.2021.02.10.18.08.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Feb 2021 18:08:08 -0800 (PST) References: User-agent: mu4e 1.5.8; emacs 27.1.91 From: Tim Cross To: pgsql-general@lists.postgresql.org Subject: Re: Encryption of Data Specific to a Tenant in PostgreSQL database | General Idea Date: Thu, 11 Feb 2021 12:45:39 +1100 In-reply-to: Message-ID: <87r1lne4qk.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Jagmohan Kaintura 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) > => Data would be segregated on basis of some additional column > (tennatid,different tenants having different tenantId) > => 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. -- Tim Cross