Verdict: use it, with three checks of your own. sops encrypts the values in a YAML, JSON, dotenv or INI file and leaves the keys readable, so you can commit secrets to git and still review a diff. Its tamper detection is the best I’ve tested on this site: I renamed a key, deleted a key, swapped two values, edited a value it never encrypted and forged the timestamp, and every one was refused. The weak spots are around it, not in the crypto. One encrypted_regex line copied from a Kubernetes guide encrypted nothing at all, exited 0, and sops filestatus still reported {"encrypted":true}. Ciphertext keeps each value’s exact length. A crashed sops edit leaves the plaintext in /tmp. And removing someone’s key doesn’t take back the copy they can already read in git history. Everything I ran and the three fixes are below. I have no relationship with the sops project, which is MPL-2.0 licensed (checked against GitHub’s API). Nobody paid me.

Let me threat-model the most reassuring file in your repo: secrets.enc.yaml. It has ENC[ all over it. It has a sops: block at the bottom with a MAC and a timestamp. The security reviewer scrolled past it because it looked encrypted, and that was the whole review. Meanwhile the file was committed by someone who copied a .sops.yaml from a blog post about Kubernetes Secrets, the rule only encrypts keys named data or stringData, and your file has neither. Every password in it is in plain text under a big official-looking sops: footer. Every fork, every CI cache, every laptop that ever ran git clone, and the three-letter agency subscribed to your public mirror now has your production database password. It’s hunter2.

Back to reality: you only hit this if your .sops.yaml uses encrypted_regex and the regex doesn’t match your file. That’s not most setups. But nothing in sops tells you it happened. It only shows up if you read the file, and the file is designed so you don’t have to.

SEVERITY: your entire config. ATTACK VECTOR: a regex you pasted from a tutorial about a different file format.

Everything below ran for real with sops 3.13.3 (the GitHub release binary, sops-v3.13.3.linux.amd64) and age v1.2.1 as the key backend, in a throwaway folder under /tmp/sopslab with SOPS_AGE_KEY_FILE pointing at a key made for this test. The keys and the “secrets” exist only in that sandbox. The exit= lines come from an echo "exit=$?" I ran after each command, not from sops.

What earns the install

Make an age key, encrypt a file. This is the plaintext I started with:

# prod database, rotate quarterly
db:
  host: db.internal.example
  password: hunter2
  port: 5432
  admin_enabled: true
api_token: sk-live-0123456789abcdef0123456789abcdef
tls_unencrypted: this-stays-plain
$ age-keygen -o key.txt
Public key: age1k6sm6ysz42396j0uwhevtx232ezj9w4jwx68ykpcg6kyx7yagqzq5npqzv
$ export SOPS_AGE_KEY_FILE=/tmp/sopslab/key.txt
$ sops encrypt --age "$PUB" secrets.yaml > secrets.enc.yaml
exit=0
$ cat secrets.enc.yaml
#ENC[AES256_GCM,data:ymmxW97KMOdJp2Fcq5nT66cv04cRyUMikyrz7cL/hjI=,iv:RG+Aw3pDsY+c3Fm/DcmjxZQf9J8nC3PiSoLoVuUjrz4=,tag:WtoSWwRlP3L3CAHt3KrS6w==,type:comment]
db:
    host: ENC[AES256_GCM,data:LbffLkX6eTvenU40bYURQcKBnQ==,iv:j4lPmgsDKU8zQKFvL4rzpiqxBtb/AlurISHJcIThDsk=,tag:uB7V5v7/V/9mQrL54qHePg==,type:str]
    password: ENC[AES256_GCM,data:ZAAa6JuUDw==,iv:AwYZqkq24fZUQP6XirvHxWeW7bd/hBSMbPYSn3a+vEY=,tag:tup1dlp85mXdGsLAo4N3yg==,type:str]
    port: ENC[AES256_GCM,data:ReFP8w==,iv:AGDZ+LvPei2X83vTFXN0ahv6aJxvdJPc/BeGiUXbJ0I=,tag:/BHHogBa3D5NLOwl+JHFTw==,type:int]
    admin_enabled: ENC[AES256_GCM,data:zb4qsQ==,iv:NpBnXjrE1Kph5TRw2sZjXvyCotAOid+GL2m/SebOHFU=,tag:f3SYuEgduPxjPB4mu7AKKA==,type:bool]
api_token: ENC[AES256_GCM,data:/TiRghPcekfBKoV2fMQ1j1yDBIXjfA17AdltDLE8DebTq537Yr0PTQ==,iv:rcgP48cSTD9d8nKY1WV3qME+3yrGNNLjNWBK02yZHWw=,tag:36DxzSLtaPvbOsz5Bq1XEw==,type:str]
tls_unencrypted: this-stays-plain
sops:
    age:
        - enc: |
            -----BEGIN AGE ENCRYPTED FILE-----
            [five lines of age armor, trimmed here]
            -----END AGE ENCRYPTED FILE-----
          recipient: age1k6sm6ysz42396j0uwhevtx232ezj9w4jwx68ykpcg6kyx7yagqzq5npqzv
    lastmodified: "2026-12-04T22:53:04Z"
    mac: ENC[AES256_GCM,data:sRqEyEXP12Lnio1cMxZhL1ONxQV+q2iBIRHxb+uPQTPNkzGoyihfuy5tg/vii+HBeOeAoDLYIryqveK8F/TMY0SdzjTx6Su8/sIq2QfJLGrREKTqDq3/iUEDNXIh1FN0Y3Df8Wa5gEulNAfEo3yhyrKNaWNyeN8NprS4tYVCTWA=,iv:BN3pRaJ47Wg3gLW/Vn/ZfgCJO+x+4Tzwp4KrC/PZaM0=,tag:je/1ScY+NvDRodDPlLr66A==,type:str]
    unencrypted_suffix: _unencrypted
    version: 3.13.3

($PUB is the public key from the first line. The only thing I trimmed is the age block; everything else is the file as written.) The comment got encrypted too, which I didn’t expect. Keys stay readable, so a pull request that changes the database password shows up as a one-line diff on password:, not as a new binary blob. The key ending in _unencrypted stayed plain on purpose; that suffix is a documented default.

Then I attacked the file. Each of these started from a fresh copy of secrets.enc.yaml:

$ sed 's/^api_token:/stripe_token:/' secrets.enc.yaml > renamed.enc.yaml; sops decrypt renamed.enc.yaml
Error decrypting tree: Error walking tree: Could not decrypt value: Could not decrypt with AES_GCM: cipher: message authentication failed
exit=25
$ grep -v '^api_token:' secrets.enc.yaml > deleted.enc.yaml; sops decrypt deleted.enc.yaml
MAC mismatch. File has 5ADCA148CEC9BE06710AD1D1CC6ADC34414422EFFB4DC01E43F9BA9E11D545938DAC3CF32165587E978CD204E4B8C14F97CD7AD1FEBEA33AEF524A78D4E12ACF, computed CDC575A37F3332F94B9EF347C3E4A16DBC1E46DC2518D75EF4B20B831816C7AB2FB057DC1D7D135A65995DF2B72EAD9871FAB2FB5D977FBB4E548A9A8FB961E5
exit=51
$ sed 's/this-stays-plain/attacker-was-here/' secrets.enc.yaml > plain.enc.yaml; sops decrypt plain.enc.yaml
MAC mismatch. File has 5ADCA148CEC9BE06710AD1D1CC6ADC34414422EFFB4DC01E43F9BA9E11D545938DAC3CF32165587E978CD204E4B8C14F97CD7AD1FEBEA33AEF524A78D4E12ACF, computed C40FC288009216C01492547DA8ACB4529BEFCBB8B540E5C0F4AB240DD41E58F074A2530215E4E62D5BF9ED35C4DEA3DE0BDA78F4FB0D9B1E60C0ED9AEF0F5AB2
exit=51
$ sed 's/lastmodified: ".*"/lastmodified: "2030-01-01T00:00:00Z"/' secrets.enc.yaml > lm.enc.yaml; sops decrypt lm.enc.yaml >/dev/null
Cannot decrypt MAC: Could not decrypt with AES_GCM: cipher: message authentication failed
exit=51

I also swapped the host and password ciphertexts with each other (a short awk script), which got the same message authentication failed, exit 25. Each value is tied to its own key path, so you can’t move ciphertext around. The MAC covers the whole tree, including the value it deliberately left in plain text. And the timestamp can’t be backdated. That’s five attacks, and I expected at least one of them to land. None did.

A wrong key fails cleanly, and the error is a useful list of every place sops looked for a key:

$ SOPS_AGE_KEY_FILE=/tmp/sopslab/other.txt sops decrypt secrets.enc.yaml
Failed to get the data key required to decrypt the SOPS file.

Group 0: FAILED
  age1k6sm6ysz42396j0uwhevtx232ezj9w4jwx68ykpcg6kyx7yagqzq5npqzv: FAILED
    - | failed to create reader for decrypting sops data key with
      | age: identity did not match any of the recipients: incorrect
      | identity for recipient block. Did not find keys in locations
      | 'SOPS_AGE_SSH_PRIVATE_KEY_FILE',
      | 'SOPS_AGE_SSH_PRIVATE_KEY_CMD',
      | '/home/runner/.ssh/id_ed25519', '/home/runner/.ssh/id_rsa',
      | 'SOPS_AGE_KEY', and 'SOPS_AGE_KEY_CMD'.

Recovery failed because no master key was able to decrypt the file. In
order for SOPS to recover the file, at least one key has to be successful,
but none were.
exit=128

Note ~/.ssh/id_ed25519 on that list. sops will try your SSH key as an age identity. That’s convenient, and every convenience is an attack surface with better marketing, but here it only means “your SSH key can decrypt files encrypted to it”, which is the point.

The part where nothing was encrypted

encrypted_regex tells sops to encrypt only the keys that match. Kubernetes guides use ^(data|stringData)$, because those are the fields in a Secret that hold the secret. I put that rule in a .sops.yaml and encrypted the same ordinary config:

$ cat .sops.yaml
creation_rules:
  - path_regex: .*\.yaml$
    encrypted_regex: ^(data|stringData)$
    age: age1k6sm6ysz42396j0uwhevtx232ezj9w4jwx68ykpcg6kyx7yagqzq5npqzv
$ sops encrypt app.yaml > app.enc.yaml
exit=0
$ sed -n '1,9p' app.enc.yaml
# prod database, rotate quarterly
db:
    host: db.internal.example
    password: hunter2
    port: 5432
    admin_enabled: true
api_token: sk-live-0123456789abcdef0123456789abcdef
tls_unencrypted: this-stays-plain
sops:
$ sops filestatus app.enc.yaml
{"encrypted":true}
exit=0

No warning and exit 0. The output file has a full sops: block with a MAC, and the tool’s own status command says it’s encrypted. For comparison, sops filestatus on the original plaintext secrets.yaml says {"encrypted":false}. So filestatus is answering “does this file have sops metadata?”, not “is anything in it secret?”. The regex did exactly what I told it to. I just told it the wrong thing, and sops had no way to know.

The part where the ciphertext tells you things

Look at password: ENC[AES256_GCM,data:ZAAa6JuUDw==. I base64-decoded the data: field of two values and counted bytes:

$ grep -o 'password: ENC\[AES256_GCM,data:[^,]*' secrets.enc.yaml | sed 's/.*data://' | base64 -d | wc -c
7
$ grep -o 'api_token: ENC\[AES256_GCM,data:[^,]*' secrets.enc.yaml | sed 's/.*data://' | base64 -d | wc -c
40

hunter2 is 7 characters and the token is 40. AES-GCM doesn’t pad, so every value’s ciphertext is exactly as long as its plaintext. The type: field says in plain text which values are an int and a bool. Together with the readable key names, anyone holding the file knows db.port is an integer, db.admin_enabled is a boolean (there are only two of those), and the database password is seven characters long. That’s documented behavior, not a bug: sops encrypts values, not shapes. Just don’t put a short PIN or a yes/no flag in it and call it secret.

The part where the plaintext stays in /tmp

sops edit decrypts to a temp file, opens your editor, and re-encrypts when you save. I pointed EDITOR at a small script that reports the path:

$ EDITOR=/tmp/sopsdl/spy-editor.sh sops edit secrets.enc.yaml
editor got: /tmp/2581433258/secrets.enc.yaml
-rw------- 1 runner runner 236 Dec  4 22:53 /tmp/2581433258/secrets.enc.yaml
# prod database, rotate quarterly
db:
    host: db.internal.example
File has not changed, exiting.
exit=200

Plaintext, on disk, mode 0600 in a 0700 directory, and on a normal exit sops deleted the directory. (Exit 200 is sops saying “you didn’t change anything”.) Then I tried an editor that kills its parent sops with kill -9, standing in for a crash, an OOM kill, or a laptop lid closing on a dying battery:

$ EDITOR=/tmp/sopsdl/crash-editor.sh sops edit secrets.enc.yaml
/bin/bash: line 8:  2777 Killed                     EDITOR=/tmp/sopsdl/crash-editor.sh sops edit secrets.enc.yaml
exit=137
$ grep password /tmp/4119923748/secrets.enc.yaml
    password: correct-horse-battery-staple

The decrypted file outlived the process (I’d changed the password with sops set by then, so that’s the current one), and it’s named secrets.enc.yaml while holding nothing encrypted. Only your user can read it, so the realistic threat is your backup tool, not a stranger. No program can clean up after a kill -9; the fix is to not decrypt to disk when you don’t need to edit.

The part where removing someone doesn’t remove anything

Bob leaves the team. I encrypted the file to two keys, kept a copy as it would sit in git history, then removed Bob’s key with sops rotate, which also makes a new data key:

$ sops encrypt --age "$A,$B" secrets.yaml > team.enc.yaml; cp team.enc.yaml team.before-offboarding.yaml
$ sops rotate -i --rm-age "$B" team.enc.yaml
exit=0
$ SOPS_AGE_KEY_FILE=/tmp/sopslab/bob.txt sops decrypt --extract '["db"]["password"]' team.enc.yaml >/dev/null 2>&1
exit=128
$ SOPS_AGE_KEY_FILE=/tmp/sopslab/bob.txt sops decrypt --extract '["db"]["password"]' team.before-offboarding.yaml
hunter2
exit=0

Bob can’t open the new file. He can open every old version, from git log, from his own clone, or from the copy he never deleted. The same thing allows a rollback: an old version of the file still decrypts and still passes the MAC, because a MAC proves the file wasn’t modified, not that it’s the latest. That’s how encryption works, not a sops flaw, but rotate sounds like it does more than it does.

One last thing, filed under “small but I noticed”: sops --version makes a network call to the GitHub API to check for a newer release. With the network cut off (unshare -n), it printed sops 3.13.3, a warning that api.github.com was unreachable, and exited 0. It prints its own deprecation notice saying this check will become opt-in. It’s harmless, but a version flag shouldn’t need the network.

The three mitigations that matter

I ran each of these in the sandbox above, ranked by how much risk they remove.

1. In CI, check every value, not the metadata. filestatus can’t tell you a value was skipped, so check the leaves yourself. This short Python script (it needs PyYAML) fails on any value outside the sops: block that doesn’t start with ENC[, and skips keys ending in _unencrypted because those are plain on purpose:

import sys, yaml
def walk(node, path):
    if isinstance(node, dict):
        for k, v in node.items():
            if path == "" and k == "sops": continue
            if str(k).endswith("_unencrypted"): continue
            yield from walk(v, f"{path}.{k}")
    elif isinstance(node, list):
        for i, v in enumerate(node): yield from walk(v, f"{path}[{i}]")
    elif not (isinstance(node, str) and node.startswith("ENC[")):
        yield path
bad = 0
for f in sys.argv[1:]:
    for p in walk(yaml.safe_load(open(f)), ""):
        print(f"{f}: plaintext at {p}"); bad = 1
sys.exit(bad)
$ python3 sops-plaintext-check.py secrets.enc.yaml
exit=0
$ python3 sops-plaintext-check.py rx/app.enc.yaml
rx/app.enc.yaml: plaintext at .db.host
rx/app.enc.yaml: plaintext at .db.password
rx/app.enc.yaml: plaintext at .db.port
rx/app.enc.yaml: plaintext at .db.admin_enabled
rx/app.enc.yaml: plaintext at .api_token
exit=1

The real file passes and the regex accident fails, naming every leaked value. If you use encrypted_regex on purpose (Kubernetes Secrets are a fine reason), give those files their own path_regex rule so it can’t catch the rest of your configs.

2. Run your app through exec-env or exec-file, not sops decrypt > .env. exec-env puts the values into one child process’s environment and nowhere else. It won’t take nested YAML, which is a fair first failure:

$ sops exec-env secrets.enc.yaml 'echo "api_token is ${#api_token} chars; db_password=${db_password:-unset}"; env | grep -c sk-live'
cannot use complex value in environment; offending key db
exit=1

So keep runtime secrets in a flat dotenv file, which sops encrypts the same way (DB_PASSWORD=ENC[AES256_GCM,data:FUj/EVgVzg==,…):

$ sops exec-env app.enc.env 'echo "API_TOKEN is ${#API_TOKEN} chars, DB_PASSWORD is ${#DB_PASSWORD}"'
API_TOKEN is 40 chars, DB_PASSWORD is 7
exit=0
$ env | grep -c API_TOKEN
0
$ sops exec-file secrets.enc.yaml 'echo "path: {}"; ls -l {}; grep -c password {}'
path: /tmp/.sops3973919496/tmp-file
prw------- 1 runner runner 0 Dec  4 22:54 /tmp/.sops3973919496/tmp-file
1
exit=0

The variables existed for the child and were gone afterward. The p at the start of the exec-file listing means it’s a named pipe, not a file: the program reads the plaintext through it, and nothing is ever written to disk. For a program that needs a config file path, that’s the one to use. Keep sops edit for editing, and do your edits on a machine whose /tmp you trust.

3. When someone leaves, change the secret, not just the recipient list. sops rotate --rm-age is step two. Step one is changing the actual password at the database or the API provider, so the copy in their git history unlocks something that no longer works. Then write the new value in:

$ sops set secrets.enc.yaml '["db"]["password"]' '"correct-horse-battery-staple"'
exit=0
$ sops decrypt --extract '["db"]["password"]' secrets.enc.yaml
correct-horse-battery-staple
$ sops decrypt --extract '["db"]["password"]' v1.enc.yaml
hunter2
exit=0

v1.enc.yaml is the copy from before the change, and it still decrypts to hunter2. That only matters if hunter2 still works anywhere. Make sure it doesn’t.

Bottom line

sops is the right tool for keeping secrets in git. Its integrity checks held against everything I threw at them, the diffs stay readable, and exec-env/exec-file let you avoid plaintext files entirely. What it can’t do is check that your rules encrypted what you meant to, hide how long a value is, or take back a secret someone already decrypted. Its status command answers a narrower question than it sounds like it does. Check the leaves in CI, decrypt into processes instead of files, and rotate the real credential when the team changes. Source and docs: github.com/getsops/sops and getsops.io.