r/NixOS • • 4d ago

Exploring post-quantum cryptography support in sops-nix

https://sighery.com/posts/exploring-post-quantum-support-in-sops-nix/

A while after my previous article about sops-nix, about why I'm paranoid and keep secrets in a private repo, someone contacted me and we got to talking about post-quantum cryptography support in sops-nix.

Turns out it's fairly well supported, although undocumented, so I decided to write about it. I plan to contribute this information to the sops-nix documentation once I get some free time.

46 Upvotes

9 comments sorted by

4

u/monr3d 4d ago

I'have always used age pq key for my master key in sops-nix

2

u/Sighery 3d ago

Good! Although like I write in the article, if you use a hybrid setup (PQ master key, classical host keys), it is not post-quantum safe. Any recipient can decrypt the key, so if you have a classic Age/SSH recipient, an attacker can ignore your PQ recipients and crack the classical ones

1

u/monr3d 3d ago

I know, but like everything else, there is always a trade of.

Even with a pq key for each host, the fact that multiple host have access to a key, is a risk regardless of the strength of the key.

That is why I chose a pq key for the master key, because it is the key with most impact on security...

3

u/alien_ideology 4d ago

Do you know if ssh to age can be post quantum resistant?

5

u/Sighery 4d ago

It produces classical Age keys, so no, they are not post-quantum resistant. The common SSH algorithms (RSA, Ed25519, etc) are also not PQ resistant. Potentially ssh-to-age could be adapted to derive Age PQ keys out of an SSH key, but then you're still susceptible to "harvest now, decrypt later" attacks. If future quantum computers were able to crack your SSH private key, they'd be able to recreate the derived Age PQ key and decrypt all your secrets, making the endeavour a bit pointless.

In this scenario there would still be some protection, owing to the fact that your .sops.yaml references a public Age key rather than the public SSH key directly. So the attacker with a quantum computer would first need to get your public SSH key. That being said, I wouldn't rely on this for security. Any computer with OpenSSH will serve its host public key, that's just part of the handshake. If you use GitHub, they will expose your public SSH keys. A long list of services that (rightly) treat SSH public keys, as public information.

3

u/ranjop 4d ago

I once had a look at this and my understanding is that I would have to:

  1. generate PQ Age keys directly, not via ssh-to-age
  2. Roll over all credentials in the repo in one commit to avoid situation where the same secrets are encrypted with PQ and non-PQ keys

Not undoable, but I decided to lower my security requirements instead 😁

3

u/Sighery 4d ago

Pretty much, you got it. It's not enough to migrate all Age/SSH keys to Age PQ keys, but one should also rotate all those credentials too. If the credentials remain the same, an attacker with access to the Git history would be able to pull an earlier commit that uses classical encryption and break that. It's definitely annoying, and if you have many secrets quite a pain, but I think NixOS can help a lot since it's way easier to see where each secret is being referenced and used.

I can't quite visualise the attack vector with multiple commits, but I might very well be missing some obvious vector. Either way, it's easy enough with rebases to control and prune the history locally before it's pushed, that way even if you migrate in steps locally, you can bundle all those steps into a final single commit you push to your repository.

1

u/ranjop 3d ago

But I actually should do this and document how all different secrets are rotated. Each external service has its own spice and unless one interacts with those often, you simply forget how it was done. I remember struggling with Grafana’s different integration options for example.

2

u/___-____--_____-____ 4d ago

Nice, I scratched the surface of this recently for one of my projects. Saving this post to read later