litestream icon indicating copy to clipboard operation
litestream copied to clipboard

Encryption

Open benbjohnson opened this issue 3 years ago • 2 comments

Currently, Litestream sends cleartext bytes to a replica such as S3. This works well enough for many use cases as S3 buckets are generally secured through IAM. However, other use cases require additional security measures to prevent attackers from obtaining raw data if a bucket is compromised.

Litestream could implement either encryption to prevent data theft and/or signatures to prevent data alteration.

benbjohnson avatar Feb 26 '21 15:02 benbjohnson

Does this need to be implemented inside litestream, or could it be supported by an external "encryption proxy"? (like https://github.com/abustany/s3proxy - does not seem to be maintained anymore, but the idea seems nice)

oliverpool avatar May 04 '21 09:05 oliverpool

For basic replication, you could use a proxy and that'd probably work pretty well.

However, I'm planning on adding hot backups soon so you can have an external server that always has a live copy of your database ready to go instead of having to perform a full snapshot/replay to restore. For that use case, encryption would need to be in Litestream as it needs to encrypt the WAL page data but not the WAL headers. The nice thing about that setup is you could stream your data to an untrusted third-party service and still have everything encrypted.

benbjohnson avatar May 04 '21 14:05 benbjohnson

We added age encryption support downstream for data storage at rest that fully supports normal replication and restore. A replicating Litestream only needs the public keys (recipients) for encryption. The age CLI tool can also be used to manually decrypt snapshots (and WALs) on a pinch.

I'm more than happy to upstream it as it is fairly trivial but it's based on v0.3.9. We've had it running for a while now without any issues replicating or restoring databases.

https://github.com/beeper/litestream/commit/ac9ad40d7154a6d282efc5ca8f26788daa871434

I suppose the hot backup feature was scrapped with LiteFS?

hifi avatar Nov 28 '22 07:11 hifi

Hey @hifi could you please push this code somewhere, would be super useful!

cal97g avatar Apr 08 '23 01:04 cal97g

@cal97g I linked it in the previous comment.

hifi avatar Apr 08 '23 09:04 hifi