From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Moreno Andreo <moreno.andreo@evolu-s.it>
To: PostgreSQL mailing lists <pgsql-general@postgresql.org>
Subject: Re: Key encryption and relational integrity
Date: Thu, 28 Mar 2019 12:38:05 -0700
Message-ID: <a61210ad-d7c1-a150-d605-348c64939f07@aklaver.com> (raw)
In-Reply-To: <7eb4fb29-73c5-c069-572a-621afe121564@evolu-s.it>
References: <094bf875-5b49-8d3c-1fa3-97c07246b890@evolu-s.it>
<082fdd45-a12b-161b-8386-70ee8528361e@aklaver.com>
<514fb642-bba4-7a14-b412-d953f1b8b7e7@evolu-s.it>
<3f88c83d-23b0-537f-8325-5b1d19ca77f7@aklaver.com>
<7eb4fb29-73c5-c069-572a-621afe121564@evolu-s.it>
On 3/28/19 10:36 AM, Moreno Andreo wrote:
> Il 26/03/2019 18:08, Adrian Klaver ha scritto:
>> On 3/26/19 9:08 AM, Moreno Andreo wrote:
>>> Il 26/03/2019 15:24, Adrian Klaver ha scritto:
>>>> On 3/26/19 7:19 AM, Moreno Andreo wrote:
>>>>> Hello folks :-)
>>>>>
>>>>> Is there any workaround to implement key encryption without
>>>>> breaking relational integrity?
>>>>
>>>> This is going to need more information.
>>> OK, I'll try to be as clearer as I can
>>>> For starters 'key' has separate meanings for encryption and RI. I
>>>> could make some guesses about what you want, but to avoid false
>>>> assumptions a simple example would be helpful.
>>> In a master-detail relation, I need to encrypt one of master table PK
>>> or detail table FK, in order to achieve pseudonimization, required by
>>> GDPR in Europe when managing particular data
>>> Imagine I have
>>> Table users
>>> id surname last name
>>> 1 John Doe
>>> 2 Jane Doe
>>> 3 Foo Bar
>>>
>>> Table medications
>>> id user_id med
>>> 1 1 Medication
>>> 2 1 Ear check
>>> ...
>>> ...
>>> medications.user_id is FK on users.id
>>> we should achieve
>>>
>>> Table medications
>>> id user_id med
>>> 1 sgkighs98 Medication
>>> 2 sghighs98 Ear check
>>>
>>> or the opposite (users.id encryption and medications.user_id kept plain)
>>>
>>> At a first glance, it IS breaking relational integrity, so is there a
>>> way to manage this encryption internally so RI is kept safe?
>>
>> Not that I know of. RI is based on maintaining a link between parent
>> and child. So by definition you would be able to get to the parent
>> record via the child.
> That's what I was afraid of :-(
>>
>> A quick search on pseudonymisation found a boatload of interpretations
>> of how to implement this:
>>
>> "Pseudonymisation' means the processing of personal data in such a
>> manner that the personal data can no longer be attributed to a
>> specific data subject without the use of additional information,
>> provided that such additional information is kept separately and is
>> subject to technical and organisational measures to ensure that the
>> personal data are not attributed to an identified or identifiable
>> natural person."
>>
>>
>> To me it would seem something like:
>>
>> Table medications
>> id user_id med
>> 1 sgkighs98 Medication
>> 2 sghighs98 Ear check
>>
>>
>>
>> Table users
>> id surname last name
>> sgkighs98 John Doe
>> jkopkl1 Jane Doe
>> uepoti21 Foo Bar
>>
>> Where there is no direct link between the two.
>
> Are you sure there isn't?... the key "sgkighs98" is present on both
> tables and I can join tables on that field, so the pseudonimysation does
> not apply, it's just "separation" (that was OK with the last privacy
> act, but not with GDPR
Yes but you can use permissions to make the user table is unreachable by
folks with insufficient permission.
>
> The problem is not on the application side... there you can do almost
> anything you want to do. The prolem is that if someone breaks in the
> server (data breach) it is easy to join patients and their medications.
That really depends on what level of user they break in as. That is a
separate security issue. It also is the difference between
pseudonymisation and anonymization, where the latter makes the data
totally unrelated to an individuals personal information.
>
>> Instead permissions would prevent linking from medications to users
>> even via a SELECT. One could also use pgcrypto:
>>
>> https://www.postgresql.org/docs/10/pgcrypto.html
>>
>> on the users table to further hide the personal info.
> That's what I used to try to encrypt first name, last name, street
> address and some other fields (that would be the best solution because
> RI was not impacted at all), but the customer stated that they have to
> perform real-time search (like when you type in the Google search box),
> and the query that has to decrypt all names and return only the ones
> that begin with a certain set of characters is way too slow (tried on a
> good i7 configuration, that's about 2 seconds for each key pressed on a
> 2500-row table). So I dropped this approach.
>>
>> *NOTE* I am not a lawyer so any advice on my part as to meeting legal
>> requirements are just me thinking out loud. I would suggest, if not
>> already done, getting proper legal advice on what the section quoted
>> above actually means.
> Relax, I'm not here to ask and then sue anyone :-)
Hey, I live in the US its just best policy to make that clear:)
>
>
>
--
Adrian Klaver
adrian.klaver@aklaver.com
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: adrian.klaver@aklaver.com, moreno.andreo@evolu-s.it
Subject: Re: Key encryption and relational integrity
In-Reply-To: <a61210ad-d7c1-a150-d605-348c64939f07@aklaver.com>
References: <094bf875-5b49-8d3c-1fa3-97c07246b890@evolu-s.it> <082fdd45-a12b-161b-8386-70ee8528361e@aklaver.com> <514fb642-bba4-7a14-b412-d953f1b8b7e7@evolu-s.it> <3f88c83d-23b0-537f-8325-5b1d19ca77f7@aklaver.com> <7eb4fb29-73c5-c069-572a-621afe121564@evolu-s.it> <a61210ad-d7c1-a150-d605-348c64939f07@aklaver.com>
* 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