Re: [Proposal] Table-level Transparent Data Encryption (TDE) and Key Management Service (KMS)

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Stephen Frost <sfrost(at)snowman(dot)net>
Cc: Joe Conway <mail(at)joeconway(dot)com>, Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>, Tomas Vondra <tomas(dot)vondra(at)2ndquadrant(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Antonin Houska <ah(at)cybertec(dot)at>, Haribabu Kommi <kommi(dot)haribabu(at)gmail(dot)com>, "Moon, Insung" <Moon_Insung_i3(at)lab(dot)ntt(dot)co(dot)jp>, Ibrar Ahmed <ibrar(dot)ahmad(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [Proposal] Table-level Transparent Data Encryption (TDE) and Key Management Service (KMS)
Date: 2019-07-08 22:23:13
Message-ID: 20190708222313.qbya7khfu2xslrgb@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Jul 8, 2019 at 06:04:46PM -0400, Stephen Frost wrote:
> Greetings,
>
> * Bruce Momjian (bruce(at)momjian(dot)us) wrote:
> > On Mon, Jul 8, 2019 at 05:41:51PM -0400, Stephen Frost wrote:
> > > * Bruce Momjian (bruce(at)momjian(dot)us) wrote:
> > > > Well, if it was a necessary features, I assume TLS 1.3 would have found
> > > > a way to make it secure, no? Certainly they are not shipping TLS 1.3
> > > > with a known weakness.
> > >
> > > As discussed below- this is about moving goalposts, and that's, in part
> > > at least, why re-keying isn't a *necessary* feature of TLS. As the
> >
> > I agree we have to allow rekeying and allow multiple unlocked keys in
> > the server at the same time. The open question is whether encrypting
> > different data with different keys and different unlock controls is
> > possible or useful.
>
> I'm not sure if there's really a question about if it's *possible*? As
> for if it's useful, I agree there's some debate.

Right, it is easily possible to keep all keys unlocked, but the value is
minimal, and the complexity will have a cost, which is my point.

> > > amount of data you transmit over a given TLS connection increases
> > > though, the risk increases and it would be better to re-key. How much
> > > better? That depends a great deal on if someone is trying to mount an
> > > attack or not.
> >
> > Yep, we need to allow rekey.
>
> Supporting a way to rekey is definitely a good idea.

It is a requirement, I think. We might have problem tracking exactly
what key _version_ each table (or 8k block), or WAL file are. :-(
Ideally we would allow only two active keys, and somehow mark each page
as using the odd or even key at a given time, or something strange.
(Yeah, hand waving here.)

> > Uh, well, renaming the user was a big problem, but that is the only case
> > I can think of. I don't see that as an issue for block or WAL sequence
> > numbers. If we want to use a different nonce, we have to find a way to
> > store it or look it up efficiently. Considering the nonce size, I don't
> > see how that is possible.
>
> No, this also meant that, as an attacker, I *knew* the salt ahead of
> time and therefore could build rainbow tables specifically for that
> salt. I could also use those *same* tables for any system where that
> user had an account, even if they used different passwords on different
> systems...

Yes, 'postgres' can be used to create a nice md5 rainbow table that
works on many servers --- good point. Are rainbow tables possible with
something like AES?

> I appreciate that *some* of this might not be completely relevant for
> the way a nonce is used in cryptography, but I'd be very surprised to
> have a cryptographer tell me that a deterministic nonce didn't have
> similar issues or didn't reduce the value of the nonce significantly.

This post:

https://stackoverflow.com/questions/36760973/why-is-random-iv-fine-for-aes-cbc-but-not-for-aes-gcm

says:

GCM is a variation on Counter Mode (CTR). As you say, with any variant
of Counter Mode, it is essential that the Nonce is not repeated with
the same key. Hence CTR mode Nonces often include either a counter or
a timer element: something that is guaranteed not to repeat over the
lifetime of the key.

CTR is what we use for WAL. 8k pages, we would use CBC, which says we
need a random nonce. I need to dig deeper into ECB mode attack.

> > Uh, well, you are much less likely to get duplicate nonce values by
> > using block number or WAL sequence number. If you look at the
> > implementations, few compute random nonce values.
>
> Which implementations..? Where do their nonce values come from? I can
> see how a nonce might have to be naturally and deterministically random,
> if the source for it is sufficiently varied across the key space, but
> starting at '1' and going up with the same key seems like it's just
> giving a potential attacker more information about what the encrypted
> data contains...

Well, in many modes the nonce is just a counter, but as stated above,
not all modes. I need to pull out my security books to remember for
which ones it is safe. (Frankly, it is a lot easier to use a random
nonce for WAL than 8k pages.)

> > And you base the random goal on what? Nonce is number used only once,
> > and randomness is not a requirement. You can say you prefer it, but
> > why, because most implementations don't use random nonce.
>
> The encryption schemes I've worked with in the past have used a random
> nonce, so I'm wondering where the disconnect is between us on that.

OK.

> > > > > When it comes to concerns about autovacuum or other system processes,
> > > > > those don't have any direct user connections or interactions, so having
> > > > > them be more privileged and having access to more is reasonable.
> > > >
> > > > Well, I am trying to understand the value of having some keys accessible
> > > > by some parts of the system, and some not. I am unclear what security
> > > > value that has.
> > >
> > > A very real risk is a low-privilege process gaining access to the entire
> > > backend process, and therefore being able to access anything that
> > > backend is able to.
> >
> > Well, if they get to one key, they will get to them all, right?
>
> That's only the case if all the keys are accessible to a backend process
> which is under a user's control. That would certainly be a bad
> situation and one which I'd hope we would avoid. If the backend that
> the user has access to only has access to a subset of the keys, then
> while they might be able to access the other encrypted data, they
> wouldn't be able to decrypt it.

Uh, we already have Postgres security for the data, so what attack
vector has the user reading the RAM, but not seeing all the keys? Isn't
client-supplied secrets a much better option for this?

> > > > > Ideally, all of this would leverage a vaulting system or other mechanism
> > > > > which manages access to the keys and allows their usage to be limited.
> > > > > That's been generally accepted as a good way to bridge the gap between
> > > > > having to ask users every time for a key and having keys stored
> > > > > long-term in memory. Having *only* the keys for the data which the
> > > > > currently connected user is allowed to access would certainly be a great
> > > > > initial capability, even if system processes (including potentially WAL
> > > > > replay) have to have access to all of the keys. And yes, shared buffers
> > > > > being unencrypted and accessible by every backend continues to be an
> > > > > issue- it'd be great to improve on that situation too. I don't think
> > > > > having everything encrypted in shared buffers is likely the solution,
> > > > > rather, segregating it up might make more sense, again, along similar
> > > > > lines to keys and using metadata that's outside of the catalogs, which
> > > > > has been discussed previously, though I don't think anyone's actively
> > > > > working on it.
> > > >
> > > > What is this trying to protect against? Without a clear case, I don't
> > > > see what that complexity is buying us.
> > >
> > > This is trying to protect against cross-domain leakage due to specific
> > > security vulnerabilities, similar to those just recently fixed, where a
> > > given backend is able to be comrpomised and is able to be used to run
> > > any code the attacker wishes inside of that backend's process.
> >
> > I am not sure TLS is a good solution to that.
>
> ... TLS? Or do you mean TDE here..?

Sorry, yes, TDE.
>
> I don't mean to throw this up as a requirement on day one of this
> feature, rather I'm trying to show where we could potentially go and why
> *this* flexibility (supporting a key per tablespace, specifically)
> would make sense and how it could help us build a more secure system in
> the future.

Understood.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ As you are, so once was I. As I am, so you will be. +
+ Ancient Roman grave inscription +

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Joe Conway 2019-07-08 22:24:40 Re: [Proposal] Table-level Transparent Data Encryption (TDE) and Key Management Service (KMS)
Previous Message Morris de Oryx 2019-07-08 22:22:14 Detailed questions about pg_xact_commit_timestamp