Re: Internal key management system

From: Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Masahiko Sawada <masahiko(dot)sawada(at)2ndquadrant(dot)com>, Cary Huang <cary(dot)huang(at)highgo(dot)ca>, Ahsan Hadi <ahsan(dot)hadi(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, "Moon, Insung" <tsukiwamoon(dot)pgsql(at)gmail(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Sehrope Sarkuni <sehrope(at)jackdb(dot)com>, cary huang <hcary328(at)gmail(dot)com>, Ibrar Ahmed <ibrar(dot)ahmad(at)gmail(dot)com>, Joe Conway <mail(at)joeconway(dot)com>
Subject: Re: Internal key management system
Date: 2020-06-11 07:07:40
Message-ID: alpine.DEB.2.22.394.2006110826310.399811@pseudo
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


Hello Bruce,

Sorry for the length (yet again) of this answer, I'm trying to make my
point as clear as possible.

>> Obviously it requires some more thinking and design, but my point is that
>> postgres should not hold a KEK, ever, nor presume how DEK are to be managed
>> by a DMS, and that is not very difficult to achieve by putting it outside of
>> pg and defining how interactions take place. Providing a reference/example
>> implementation would be nice as well, and Masahiko-san code can be rewrapped
>> quite easily.
>
> Well, the decrypted keys are already stored in backend memory,

The fact that if the pg process is compromised then the DEK and data
encrypted are compromised is more or less unavoidable (maybe only the data
could be compromised though, but not the DEK, depending on how the
encryption/decryption operates).

> so what risk does haveing the KEK in memory for a brief period avoid?

My understanding is that the KEK does not protect one key, but all keys,
thus all data, possibly even past or future, so it loss impacts more than
the here and now local process.

If the KEK is ever present in pg process, it presumes that the threat
model being addressed allows its loss if the process is compromised, i.e.
all (past, present, future) security properties are void once the process
is compromised.

This may be okay for some use cases, but I can easily foresee that it
would not be for all. I can think of use cases where the user/auditor says
that the KEK should be elsewhere, and I would tend to agree.

So my point is that the implementation should allow it, i.e. define a
simple interface, and possibly a reference implementation with good
properties which might fit some/typical security requirements, and the
patch mostly fits that need, but for the possible isolation of the KEK.

ISTM that a reasonable point of comparision is the design of kerberos,
with a central authority/server which authenticate parties and allow them
to authenticate one another and communicate securely.

The design means that any compromised host/service would compromise all
its interaction with other parties, but not communications between third
parties. The compromission stays local, with the exception is the kerberos
server itself, which somehow holds all the keys.

For me the KEK is basically the kerberos server, you should provide means
to allow the user to isolate that where they think it should be, and not
enforce that it is within postgres process.

Another point is that what I suggest does not seem very hard from an
implementation point of view, and allows extensibility, which is also a
win.

Lastly, I still think that all this, whatever the design, should be
packaged as an extension, unless it is really impossible to do so. I would
also try to separate the extension for KMS interaction with the extension
for actually using the keys, so that the user could change the underlying
cryptographic primitives as they see fit.

--
Fabien.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2020-06-11 07:09:41 Re: Add support for INDEX_CLEANUP and TRUNCATE to vacuumdb
Previous Message Andrey V. Lepikhov 2020-06-11 07:03:45 Re: Asynchronous Append on postgres_fdw nodes.