sops: decrypt on every Flux Kustomization + static guard against the silent ENC[...] trap #66

Merged
sirius merged 1 commit from wt/t_0fe36052 into master 2026-11-27 05:57:54 +00:00
Owner

What

spec.decryption is opt-in per Flux Kustomization, and its failure mode is silent: a
secret-*.sops.yaml under a tree without the block is still valid YAML, so Flux applies the
Secret with literal ENC[AES256_GCM,…] values and reports success. The Secret is green and
wrong, and the first symptom is an application failing to authenticate days later, looking
nothing like a git problem. Only apps and monitoring carried the block; the other six trees
were a trap for whoever added a Secret there next.

  • add decryption: {provider: sops, secretRef: {name: sops-age}} to cert-manager,
    databases, gateway-api-crds, infrastructure, logging and flux-system
    → 8/8 Kustomizations decrypt now; harmless where no encrypted files exist. The block in
    flux-system/gotk-sync.yaml is hand-added on top of the generated manifest (a future
    flux bootstrap drops it — the guard catches that).
  • scripts/check-sops-decryption.py + make check-sops: static guard (no cluster, no age key,
    no network) that reads the live sync path out of clusters/*/flux-system/gotk-sync.yaml,
    walks each Kustomization's kustomize resource graph, and fails when a *.sops.yaml/*.sops.yml
    file (a) sits under a tree whose owner cannot decrypt, (b) sits under no reconciled tree, or
    (c) contains no sops: block / ENC[AES256_GCM… — plaintext wearing an encrypted name.
  • .gitattributes marks *.sops.yaml with diff=sopsdiffer (opt-in textconv, documented);
    docs/secrets-sops.md explains the opt-in trap, the eight Kustomizations and the guard.

Verification on this branch

$ make check-sops
OK: 8 Flux Kustomizations, 8/8 decrypt with provider=sops (secret sops-age); 35 SOPS file(s),
    all inside decrypting trees and genuinely encrypted.

Synthetic case (introduced, exercised, removed — tree clean afterwards):

FAIL clusters/homek8s/synthetic-check.yaml: synthetic-check: decryption.provider is None, expected 'sops'
FAIL infrastructure/synthetic-check/secret-synthetic.sops.yaml: owned by ...: synthetic-check which does not decrypt
FAIL: 2 problem(s) across 9 Flux Kustomizations (8 decrypt with sops) and 36 SOPS file(s).   # exit 1

plus a plaintext file named secret-plaintext-test.sops.yaml →
FAIL … no SOPS ciphertext (ENC[AES256_GCM...) — is the value plaintext? / missing the 'sops:' metadata block.

A Flux-equivalent kustomize build of clusters/homek8s (auto-generated resource list) renders
8 Kustomization objects, all with provider: sops.

Out of scope, untouched

No secret contents, recipients or keys changed; no secret moved between trees; flux-system/sops-age
untouched; no kubectl create secret.

## What `spec.decryption` is **opt-in per Flux Kustomization**, and its failure mode is silent: a `secret-*.sops.yaml` under a tree without the block is still valid YAML, so Flux applies the Secret with literal `ENC[AES256_GCM,…]` values and reports success. The Secret is green and wrong, and the first symptom is an application failing to authenticate days later, looking nothing like a git problem. Only `apps` and `monitoring` carried the block; the other six trees were a trap for whoever added a Secret there next. - add `decryption: {provider: sops, secretRef: {name: sops-age}}` to `cert-manager`, `databases`, `gateway-api-crds`, `infrastructure`, `logging` and `flux-system` → **8/8 Kustomizations decrypt now**; harmless where no encrypted files exist. The block in `flux-system/gotk-sync.yaml` is hand-added on top of the generated manifest (a future `flux bootstrap` drops it — the guard catches that). - `scripts/check-sops-decryption.py` + `make check-sops`: static guard (no cluster, no age key, no network) that reads the live sync path out of `clusters/*/flux-system/gotk-sync.yaml`, walks each Kustomization's kustomize resource graph, and fails when a `*.sops.yaml`/`*.sops.yml` file (a) sits under a tree whose owner cannot decrypt, (b) sits under no reconciled tree, or (c) contains no `sops:` block / `ENC[AES256_GCM…` — plaintext wearing an encrypted name. - `.gitattributes` marks `*.sops.yaml` with `diff=sopsdiffer` (opt-in textconv, documented); `docs/secrets-sops.md` explains the opt-in trap, the eight Kustomizations and the guard. ## Verification on this branch ``` $ make check-sops OK: 8 Flux Kustomizations, 8/8 decrypt with provider=sops (secret sops-age); 35 SOPS file(s), all inside decrypting trees and genuinely encrypted. ``` Synthetic case (introduced, exercised, removed — tree clean afterwards): ``` FAIL clusters/homek8s/synthetic-check.yaml: synthetic-check: decryption.provider is None, expected 'sops' FAIL infrastructure/synthetic-check/secret-synthetic.sops.yaml: owned by ...: synthetic-check which does not decrypt FAIL: 2 problem(s) across 9 Flux Kustomizations (8 decrypt with sops) and 36 SOPS file(s). # exit 1 ``` plus a plaintext file named `secret-plaintext-test.sops.yaml` → `FAIL … no SOPS ciphertext (ENC[AES256_GCM...) — is the value plaintext?` / `missing the 'sops:' metadata block`. A Flux-equivalent `kustomize build` of `clusters/homek8s` (auto-generated resource list) renders 8 Kustomization objects, all with `provider: sops`. ## Out of scope, untouched No secret contents, recipients or keys changed; no secret moved between trees; `flux-system/sops-age` untouched; no `kubectl create secret`.
`spec.decryption` is opt-in per Flux Kustomization, and a secret-*.sops.yaml
under a tree without it is still valid YAML: Flux applies the Secret with
literal ENC[AES256_GCM,...] values and reports success. The Secret is green and
wrong, and the first symptom is an auth failure days later that looks nothing
like a git problem. Only `apps` and `monitoring` had the block; the other six
trees were a trap for the next person to add a Secret there.

- add decryption: {provider: sops, secretRef: sops-age} to cert-manager,
  databases, gateway-api-crds, infrastructure, logging and flux-system
  (8/8 Kustomizations now decrypt; harmless where no encrypted files exist)
- scripts/check-sops-decryption.py + `make check-sops`: static guard that reads
  the live sync path from gotk-sync.yaml, walks each Kustomization's kustomize
  resource graph, and fails when a *.sops.yaml file is under a tree whose owner
  cannot decrypt, is under no reconciled tree, or is not actually encrypted
  (also catches `flux bootstrap` regenerating gotk-sync.yaml without the block)
- .gitattributes marks *.sops.yaml with diff=sopsdiffer; docs/secrets-sops.md
  explains the opt-in trap, the eight Kustomizations and the guard

No secret contents, recipients or keys touched.
sirius merged commit b269e729fd into master 2026-11-27 05:57:54 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
sirius/homek8s!66
No description provided.