sops-nix icon indicating copy to clipboard operation
sops-nix copied to clipboard

Allow age.keyFile to be in Nix store

Open dotdoom opened this issue 6 months ago • 5 comments

Fragment in question:

https://github.com/Mic92/sops-nix/blob/6e5a38e08a2c31ae687504196a230ae00ea95133/modules/sops/default.nix#L322-L330

I understand the reason for pathNotInStore is to prevent people from accidentally leaking a private key key into the (world-readable) Nix store.

However with some age plugins like age-plugin-tpm for example, the contained blob is mostly useless to attacker today, as the data is sealed with a target host TPM key.

Would it make sense to add an extra option, e.g. "allowKeyInPublicReadableNixStore" which would lift the requirement for age.keyFile to be "pathNotInStore"?

dotdoom avatar Oct 05 '25 17:10 dotdoom

Can we easily detect if age-plugin-tpm is used and then lift that requirement instead?

SuperSandro2000 avatar Oct 05 '25 18:10 SuperSandro2000

That should be possible; age-plugin-tpm identities have a unique prefix. We could readFile and parse that:

AGE-PLUGIN-TPM-1QYQQQKQQYVQQKQQZQPEQQQQQZQQPJQQTQQPSQYQQYR92LCDXJ75RJZ9E4T9NUD7[...]

https://github.com/Foxboron/age-plugin-tpm/blob/ff250c13d813b748ad1f88ca5c57ace4858185e8/cmd/age-plugin-tpm/main.go#L36

dotdoom avatar Oct 05 '25 19:10 dotdoom

The public key is also prefixed with age1tpm so that could be an alternative in case e.g. keyFile is not present on the build system. It's a little cumbersome because one would have to get the list of receivers, and that taps into age implementation.

dotdoom avatar Oct 05 '25 19:10 dotdoom

Seems like there was some discussion back in 2024 about it, with a workaround mentioned.

https://github.com/Mic92/sops-nix/pull/534#issuecomment-2079623031

dotdoom avatar Oct 05 '25 20:10 dotdoom

same thing with yubikey plugin - the ID has a format of `AGE-PLUGIN-YUBIKEY-1MZXR5QVZ4S6ZEWS0JA9JA

perhaps a override at your own risk is more generalizable?

xela-zone avatar Oct 09 '25 20:10 xela-zone