Space encryption keys are named by folder name: a reused name shares the old space's key; split data without a recovery key #965

Closed
opened 2026-10-19 00:20:12 +00:00 by Cordy · 5 comments
Owner

Found in batch 3 (Task D, 2026-10-19). A decision issue: needs research before the decision is asked.

Background (fixed in v0.6.350): group keys were looked up by the space's backend folder name (groups/<folder> in OpenBao, the group named <folder> in Keycloak). A rename convergence moved the folder, so files written before the move kept the old key, while reads looked up the new name and silently provisioned a second key. The bug dates from #771, and it also hit the space trash, version history, restored spaces and Finish rename. On instances with a recovery identity (both dogfoods), OpenBao reads succeeded silently through the recovery key; Keycloak failed. v0.6.350 fixes the read side: the registry records KeyName, the folder a renamed space leaves, and the encrypt layer resolves any folder of a space to that one key. Key custody formats are unchanged.

Open (decision):

  1. Name reuse. When a renamed space's old name is retired, or a deleted space's name is freed, and a new space takes that name, the two spaces share a key. Main already does this for reused deleted names. The clean fix keys spaces by their id (groups/<id>), which changes OpenBao paths and the Keycloak attribute location, so existing keys need a migration.
  2. Data split across two keys before v0.6.350, on instances without a recovery key. Two ways to recover it: a decrypt-only fallback to the old names' keys, or re-encrypting the files. Not needed on the dogfoods, since both have a recovery key.

Read-only checks for the dogfoods: see task-d-report.md in the batch-3 SDD folder (bao kv list secret/cairn/groups, kcadm.sh get groups). They read key metadata only; Nikola runs them.

Found in batch 3 (Task D, 2026-10-19). A decision issue: needs research before the decision is asked. **Background (fixed in v0.6.350):** group keys were looked up by the space's backend folder name (`groups/<folder>` in OpenBao, the group named `<folder>` in Keycloak). A rename convergence moved the folder, so files written before the move kept the old key, while reads looked up the new name and silently provisioned a second key. The bug dates from #771, and it also hit the space trash, version history, restored spaces and Finish rename. On instances with a recovery identity (both dogfoods), OpenBao reads succeeded silently through the recovery key; Keycloak failed. v0.6.350 fixes the read side: the registry records `KeyName`, the folder a renamed space leaves, and the encrypt layer resolves any folder of a space to that one key. Key custody formats are unchanged. **Open (decision):** 1. **Name reuse.** When a renamed space's old name is retired, or a deleted space's name is freed, and a new space takes that name, the two spaces share a key. Main already does this for reused deleted names. The clean fix keys spaces by their id (`groups/<id>`), which changes OpenBao paths and the Keycloak attribute location, so existing keys need a migration. 2. **Data split across two keys before v0.6.350, on instances without a recovery key.** Two ways to recover it: a decrypt-only fallback to the old names' keys, or re-encrypting the files. Not needed on the dogfoods, since both have a recovery key. **Read-only checks for the dogfoods:** see `task-d-report.md` in the batch-3 SDD folder (`bao kv list secret/cairn/groups`, `kcadm.sh get groups`). They read key metadata only; Nikola runs them.
Author
Owner

#1002 research (2026-10-26), research-1002-1-cairn.md §1.6: a directory group that is deleted and recreated under the same name inherits the space, its files, and (under OpenBao custody) the same key name. This is the same root cause as #1002: binding by name instead of by a stable id.

Recommended (stage 3 of #1002): key names keyed by space id (groups/<space id>; spacekeys.json already maps id to key name), and the group binding recorded by directory id. To be designed with #967.

#1002 research (2026-10-26), `research-1002-1-cairn.md` §1.6: a directory group that is deleted and recreated under the same name inherits the space, its files, and (under OpenBao custody) the same key name. This is the same root cause as #1002: binding by name instead of by a stable id. Recommended (stage 3 of #1002): key names keyed by space id (`groups/<space id>`; `spacekeys.json` already maps id to key name), and the group binding recorded by directory id. To be designed with #967.
Author
Owner

Decision (Nikola, 2026-10-26): keys by space id. A recreated group or a reused space name never inherits an old key. Research and design come first, inside the #1002 stage 2+3 batch, together with #967.

**Decision (Nikola, 2026-10-26): keys by space id.** A recreated group or a reused space name never inherits an old key. Research and design come first, inside the #1002 stage 2+3 batch, together with #967.
Author
Owner

Stage 3 research (2026-10-26, research-1002-5-keys.md; summary on #1002).

Confirmed:

  • Nothing is ever deleted from custody. Purge and Forget drop only the registry entries (spaceids.go:519-533).
  • A space created later with the same name, or a recreated group, finds the old key under OpenBao.

Recommended:

  • OpenBao keys at cairn/spaces/<space id>, created only if absent.
  • A key reference per space id with a pinned public key and a generation number.
  • Purged spaces' keys are marked retired, and destroyed only by an explicit admin action.

The upgrade copies existing keys unchanged, so every file stays readable. Decisions follow on #1002.

Stage 3 research (2026-10-26, `research-1002-5-keys.md`; summary on #1002). **Confirmed:** - Nothing is ever deleted from custody. Purge and `Forget` drop only the registry entries (spaceids.go:519-533). - A space created later with the same name, or a recreated group, finds the old key under OpenBao. **Recommended:** - OpenBao keys at `cairn/spaces/<space id>`, created only if absent. - A key reference per space id with a pinned public key and a generation number. - Purged spaces' keys are marked retired, and destroyed only by an explicit admin action. The upgrade copies existing keys unchanged, so every file stays readable. Decisions follow on #1002.
Author
Owner

Decision (Nikola, 2026-10-26):

  • OpenBao keys move to cairn/spaces/<space id>.
  • Existing keys are copied unchanged; old copies are removed by an admin after a verify step.
  • Purged spaces' keys are retired, and destroyed only by an explicit admin action.
  • No rotation on member removal; an admin "Rotate key" is available.

Details are on #1002.

**Decision (Nikola, 2026-10-26):** - OpenBao keys move to `cairn/spaces/<space id>`. - Existing keys are copied unchanged; old copies are removed by an admin after a verify step. - Purged spaces' keys are retired, and destroyed only by an explicit admin action. - No rotation on member removal; an admin "Rotate key" is available. Details are on #1002.
Cordy closed this issue 2026-10-26 22:23:41 +00:00
Author
Owner

Fixed in v0.6.358 (#1002 stage 3, PR #1017). Space keys are found by space id and pinned by a fingerprint, so a new space that reuses a purged or retired name never writes with the old space's key. Reads may still try the old names, but only to decrypt, and only until Remove old copies. The move flags spaces that share a name with a purged one. Live: the move ran on both dogfoods and Check keys passed (5/5 and 4/4).

Point 2 (data split before v0.6.350 on instances without a recovery key) is covered by the decrypt-only fallback to old names. Split deployments (remoteUrl) still use the lookup by name in this release; that is tracked in #1019.

Fixed in v0.6.358 (#1002 stage 3, PR #1017). Space keys are found by space id and pinned by a fingerprint, so a new space that reuses a purged or retired name never writes with the old space's key. Reads may still try the old names, but only to decrypt, and only until Remove old copies. The move flags spaces that share a name with a purged one. Live: the move ran on both dogfoods and Check keys passed (5/5 and 4/4). Point 2 (data split before v0.6.350 on instances without a recovery key) is covered by the decrypt-only fallback to old names. Split deployments (remoteUrl) still use the lookup by name in this release; that is tracked in #1019.
Sign in to join this conversation.
No labels
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: Cordy/Cairn#965
No description provided.