Per-user key custody: the start stamp cannot give items from before v0.6.376 an id #1058

Closed
opened 2026-10-31 07:48:32 +00:00 by Cordy · 3 comments
Owner

Problem. At the first start of v0.6.376 Cairn gives existing links and shares the item id of their file or folder (cmd/cairnd/itemstamp835.go, stampItemIDs). For an item from before the release that has no id yet, the stamp must write the folder's owner records (ownermeta.EnsureItemID). Under per-user key custody (keycloak-profile, openbao) those records are encrypted to the person, and a start has no person's key: it can read them through the deployment's recovery identity, but not write them. So:

  • those links and shares stay path only (they serve whatever is at their path, the behaviour before v0.6.376), so the path-reuse guard does not protect them;
  • the stamp never writes done and never writes share-item-ids-stamped; every later start retries and logs WARN shares: could not stamp the item ids of some shares and links; a later start tries again (at once on the same host, after the 15-minute claim on another).

Seen live on the OpenBao dogfood after the v0.6.376 rollout: failed=4 records=5 stamped=0 missing=1, err="encrypt: no authenticated ...".

Documented as a known limit in the v0.6.376 release notes, sharing.md and admin-policy.md. Test: TestStampItemIDsCustody835 (cmd/cairnd).

Proposal (pick one, or combine).

  • Mint lazily with the person's key: the first time the owner's session touches the folder (a listing, a write, the Shares view), mint the missing ids of items that have shares or links, then fill the records (FillItemIDs). Needs a cheap "which folders hold unstamped records" lookup per person.
  • Stamp at the person's next sign-in, for their own records, in the background.
  • Let the stamp write a manifest encrypted to the person's public key (age needs only the recipient to encrypt), if custody can hand out the public key without the private one; check that the read-back through the recovery identity then matches.
  • Stop the endless retry: mark records the stamp could not mint for (stampDeferred) and write done with a deferred=<n> count, so the WARN appears once, and the admin audit record still says what is left.

Acceptance. A stacktest with per-user custody: a link on a pre-release item gets its id after the owner's first session touch (or sign-in), the guard then refuses a different item at its path, and the stamp reaches done without repeating its WARN at every start.

Refs. #835 review notes (T15 docs), wave review S3, spec §7, #175 (recovery read).

Follow-up of #835 (v0.6.376).

**Problem.** At the first start of v0.6.376 Cairn gives existing links and shares the item id of their file or folder (`cmd/cairnd/itemstamp835.go`, `stampItemIDs`). For an item from before the release that has no id yet, the stamp must write the folder's owner records (`ownermeta.EnsureItemID`). Under per-user key custody (`keycloak-profile`, `openbao`) those records are encrypted to the person, and a start has no person's key: it can read them through the deployment's recovery identity, but not write them. So: - those links and shares stay path only (they serve whatever is at their path, the behaviour before v0.6.376), so the path-reuse guard does not protect them; - the stamp never writes `done` and never writes `share-item-ids-stamped`; every later start retries and logs WARN `shares: could not stamp the item ids of some shares and links; a later start tries again` (at once on the same host, after the 15-minute claim on another). Seen live on the OpenBao dogfood after the v0.6.376 rollout: `failed=4 records=5 stamped=0 missing=1`, `err="encrypt: no authenticated ..."`. Documented as a known limit in the v0.6.376 release notes, `sharing.md` and `admin-policy.md`. Test: `TestStampItemIDsCustody835` (cmd/cairnd). **Proposal (pick one, or combine).** - Mint lazily with the person's key: the first time the owner's session touches the folder (a listing, a write, the Shares view), mint the missing ids of items that have shares or links, then fill the records (`FillItemIDs`). Needs a cheap "which folders hold unstamped records" lookup per person. - Stamp at the person's next sign-in, for their own records, in the background. - Let the stamp write a manifest encrypted to the person's public key (age needs only the recipient to encrypt), if custody can hand out the public key without the private one; check that the read-back through the recovery identity then matches. - Stop the endless retry: mark records the stamp could not mint for (`stampDeferred`) and write `done` with a `deferred=<n>` count, so the WARN appears once, and the admin audit record still says what is left. **Acceptance.** A stacktest with per-user custody: a link on a pre-release item gets its id after the owner's first session touch (or sign-in), the guard then refuses a different item at its path, and the stamp reaches `done` without repeating its WARN at every start. **Refs.** #835 review notes (T15 docs), wave review S3, spec §7, #175 (recovery read). Follow-up of #835 (v0.6.376).
Author
Owner

Research (2026-10-31, code at v0.6.380). The issue's premise is wrong.

  • Under keycloak-profile and openbao cairnd can fetch any person's key from custody by username; the stamp only lacks a person in its context (openbao.go:153-158, keycloak.go:115-159). Cairn already writes as the owner in background paths (key drain keydrain.go:404-409, grantee writes, peering delivery, public-link uploads, the #835 guard's ownerCtx). Fix: ensure(ownerCtx(ctx, homeOwner(target)), target) in stampItemIDs (itemstamp835.go:161).
  • age encryption needs only recipients, but Cairn custody stores private identities and derives the recipient from them, so "public-key only" gains nothing; a separately published public key would let directory admins swap it and let anyone forge owner records (age is only implicitly authenticated).
  • Market: Nextcloud SSE user keys/E2EE, Cryptomator, Proton, Boxcryptor, Tresorit, Seafile wait for login/unlock only because their server can't get the key; Cairn's peers are Nextcloud master-key mode and Cairn's own key drain.
  • Pitfalls: OpenBao custody creates a key on any write for a username with none (a stamp for a departed name would mint a key a re-created account could inherit, see #1054); post-quantum mode must still allow the key upgrade; a sign-in hook would miss app-password-only users.

Recommended: stamp as the owner (actor system), never create a first key during the stamp, count unstampable-for-good-reason records as deferred and write done with deferred=<n>, keep WARN + retry only for transient failures with a 15-minute background retry. No UI. Questions are being asked now. Full file: research-1058.md.

**Research (2026-10-31, code at v0.6.380). The issue's premise is wrong.** - Under `keycloak-profile` and `openbao` cairnd can fetch any person's key from custody by username; the stamp only lacks a person in its context (`openbao.go:153-158`, `keycloak.go:115-159`). Cairn already writes as the owner in background paths (key drain `keydrain.go:404-409`, grantee writes, peering delivery, public-link uploads, the #835 guard's `ownerCtx`). Fix: `ensure(ownerCtx(ctx, homeOwner(target)), target)` in `stampItemIDs` (`itemstamp835.go:161`). - age encryption needs only recipients, but Cairn custody stores private identities and derives the recipient from them, so "public-key only" gains nothing; a separately published public key would let directory admins swap it and let anyone forge owner records (age is only implicitly authenticated). - Market: Nextcloud SSE user keys/E2EE, Cryptomator, Proton, Boxcryptor, Tresorit, Seafile wait for login/unlock only because their server can't get the key; Cairn's peers are Nextcloud master-key mode and Cairn's own key drain. - Pitfalls: OpenBao custody creates a key on any write for a username with none (a stamp for a departed name would mint a key a re-created account could inherit, see #1054); post-quantum mode must still allow the key upgrade; a sign-in hook would miss app-password-only users. **Recommended:** stamp as the owner (actor `system`), never create a first key during the stamp, count unstampable-for-good-reason records as `deferred` and write `done` with `deferred=<n>`, keep WARN + retry only for transient failures with a 15-minute background retry. No UI. Questions are being asked now. Full file: research-1058.md.
Author
Owner

Decisions (Nikola, 2026-10-31): all research recommendations approved. Stamp as the owner (actor system); never create a first key during the stamp but allow the post-quantum key upgrade; records that can't get an id for a good reason (homes off, owner without a key, deleted directory account) count as deferred and the stamp writes done with deferred=<n>; WARN and retry only for transient failures, retried in the background every 15 minutes; departed owners whose key is still in custody are stamped too; no admin badge; the lazy sign-in and public-key ideas are dropped. No UI; spec and build next.

**Decisions (Nikola, 2026-10-31): all research recommendations approved.** Stamp as the owner (actor `system`); never create a first key during the stamp but allow the post-quantum key upgrade; records that can't get an id for a good reason (homes off, owner without a key, deleted directory account) count as `deferred` and the stamp writes `done` with `deferred=<n>`; WARN and retry only for transient failures, retried in the background every 15 minutes; departed owners whose key is still in custody are stamped too; no admin badge; the lazy sign-in and public-key ideas are dropped. No UI; spec and build next.
Cordy closed this issue 2026-11-01 02:01:55 +00:00
Author
Owner

Released in v0.6.381 (PR #1064), live on both dogfoods (v0.6.382).

  • The stamp runs as the owner (stampCtx), off the serving path (stampInBackground), and releases its claim on shutdown. Records it cannot stamp yet are counted as deferred and retried, and done is written with the count, so the WARN no longer repeats at every start.
  • Under per-user custody, the stamp never creates a first key (WithNoProvision, header X-Cairn-No-Provision, 503 no-user / user-key-unavailable).
  • Keycloak setAttribute re-merges before the PUT.

Live: the OpenBao dogfood start log reads records=5 stamped=4 missing=1 deferred=0. Remaining live checks are in #1005.

Released in **v0.6.381** (PR #1064), live on both dogfoods (v0.6.382). - The stamp runs as the owner (`stampCtx`), off the serving path (`stampInBackground`), and releases its claim on shutdown. Records it cannot stamp yet are counted as `deferred` and retried, and `done` is written with the count, so the WARN no longer repeats at every start. - Under per-user custody, the stamp never creates a first key (`WithNoProvision`, header `X-Cairn-No-Provision`, 503 `no-user` / `user-key-unavailable`). - Keycloak `setAttribute` re-merges before the PUT. Live: the OpenBao dogfood start log reads `records=5 stamped=4 missing=1 deferred=0`. Remaining live checks are in #1005.
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#1058
No description provided.