set and edit don't encrypt new keys when combined with (un)encrypted-regex
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 23.1k
- Forks
- 1.1k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 9
Description
If a .sops.yaml file exists and specifies an encrypted regexp (or unencrypted regexp), and you add a key that should be encrypted to a file using sops or sops --set, the config is ignored and the new key will not be encrypted.
This is a bit dangerous, as a couple of obvious flows to adding a secret to a config file are:
-
Add the key to the sops config file to specify it should be encrypted
-
either:
a. run something like
sops -i --set "['newsecret'] \"$(head -c 32 /dev/urandom | base64)\"" myfile.yamlb. use
sops myfile.yamlto edit interactively
If you don't double-check the file, you will think you have an encrypted secret in there and actually you have a plaintext secret.
The workaround I've found is to use one of the above methods to add the secret, then decrypt and encrypt it in place, i.e. sops -d -i file.yaml && sops -e -i file.yaml
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue with a .sops.yaml encrypted or unencrypted regexp, then compare sops --set and interactive sops editing of a new key. Trace how each flow applies the configuration and verify that newly added keys follow the configured regexp instead of remaining plaintext.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- cli, security
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100