hub: maity-hub rekey: rotate the instance key, re-sealing every value sealed or keyed with it
tsk-xa7wf47nw7r6 In progress Maity Coder Claude 007
The maintainer's go, 2026-12-02 (lead's proposal, option A). For 0.1.2.
Today an operator cannot change the instance key (MAITY_SECRET_KEY) without breaking what was sealed or keyed with it. Rotating it is a normal operator task, for example after a copy of the key was kept somewhere that should not have it.
Build an operator command maity-hub rekey, run once in a hub pod:
- It reads the old key from a second setting (for example
MAITY_SECRET_KEY_OLD) and the new key fromMAITY_SECRET_KEY. - It re-seals with the new key every value sealed with the old one: credential and runner-credential verifiers (#1789/#1840), second-factor secrets, human forge tokens and forge access, forge webhook secrets, mail settings stored in the database, and any other secretbox user. Find every user of the key in hub/src; the list above is a starting point, not the full list.
- Values keyed with the key (HMACs: address and known-source hashes, notification tokens, pending mail codes) are recomputed where the input is stored. Where it is not, the command says what resets: counters and locks start fresh, and links in mails already sent stop working. Document each case.
- It is idempotent and resumable: a value already sealed with the new key is skipped. It prints a count per kind, plus
left with old key 0at the end. - A dry-run mode counts without writing.
- While both keys are set, the hub reads values sealed with either key, so a rolling deploy with the old setting present keeps working. After
left with old key 0the operator removes the old setting. - Operator docs: the chart README (values for the old key) and hub/README.md give the order: new key + old key, rollout, rekey, check, remove the old key.
- Tests for each kind: rotation, a mixed table, a rerun, a dry run, a wrong old key (refused, nothing written), and the hub reading both keys during the window.
Security-relevant: two reviews, security legs included. No secrets in logs or output.