Repository navigation
Managing a shared set of secrets with a compromised identity #2014
Replies: 2 comments 3 replies
Yes, that's something I would definitely avoid (except maybe for things that aren't that important / sensitive; though I wouldn't do that either). If you want to avoid git (like when sharing secrets with not that git-adept friends / family), you can also use other file sharing / synchronization tools, like Syncthing. |
|
You're right. Rotating keys only protects the ciphertexts you write from now on; every value that was ever encrypted to the stolen key has to be treated as disclosed, so the real fix is changing the secret values at their source (DB passwords, API tokens). @felixfontein's advice (private repo, or Syncthing) limits who gets the history, but it can't undo a leak that already happened. The docs now have a section on the order of operations: Rotating secrets after a key in a key group has been compromised (added in getsops/docs#34). Three things I'd add: 1. # key already removed from .sops.yaml
sops updatekeys -y secret.sops.yaml
sops rotate -i secret.sops.yaml
git commit -am "remove compromised key" && git push
# only now change the real passwords/tokens2. The recipient type decides whether old commits stay readable. With age or PGP, the private key unwraps the data key locally (age/keysource.go#L243-L258), so a stolen key reads every old commit offline, forever. With a KMS recipient, the file only holds the KMS-wrapped data key in
If you want per-person age keys without offline access to history, put KMS in a second key group with 3. Set things up so removing someone is surgical: creation_rules:
- path_regex: ^prod/
shamir_threshold: 2
key_groups:
- age: [age1alice..., age1bob...] # one recipient per person
- kms:
- arn: arn:aws:kms:eu-west-1:111122223333:key/...
context: {env: prod} # shows up in CloudTrail Decrypt entries
- path_regex: ^dev/
age: [age1alice..., age1bob..., age1carol...]Use one file (or directory) per environment so a leak stays scoped, keep the repo private, and use short-lived credentials plus MFA for KMS access. Incident checklist
|
Uh oh!
There was an error while loading. Please reload this page.
I'm curious what folks are doing to share their secrets with friends/family or a small team?
Clearly you set up multiple recipients using their public identity.
Specifically I'm curious what people do to share the encrypted files. I would assume most people would say to use git. You commit your change and push it to a remote repository and share it that way.
What I'm specifically thinking through (and I have not yet seen documentation discuss this finer point) is the case where someones identity is compromised. Lets say my private identity file gets stolen (passphrase aside).
Great! I quickly go rotate my keys and push back to git. All is well everything is encrypted with all new identities that are no longer compromised. BUT if this was in a public git repo then now all they have to do is just check out an older commit and they can decrypt whatever was in there at that time.
So I'm guessing the only protection here is to NEVER commit your encrypted files to a public git repo! You should have at least another layer of credentials that protects the git repo as well so it is not public.
Basically, just because it is encrypted and you have rotated keys does not make it 'safe'. You must also ensure that the bad actor does not have access to any historical versions of the encrypted files. This can be difficult given certain situations. It can be managed but I never see this nuance discussed in any documentation. I feel like there might be a lot of folks thinking things are just great because its 'encrypted' and they may not realize the risk that exists in certain situations. I'm ultimately trying to design my workflow around sharing that mitigates these types of scenarios.
Thoughts?
All reactions