bug: on IDIP every preferred_username-keyed service (Gramps, video, newsletters, surveys, Paperless, portroute) lets a member take over another's account by choosing the same username #1908

Closed
opened 2026-09-27 03:13:50 +00:00 by ben · 3 comments
Owner

Problem

On an IDIP community, every service that keys its accounts on the OIDC preferred_username claim lets a member take over another member's account by choosing the same username. preferred_username comes from the member's credential (internal/idp/ledger_verifier.go:135; words door keri_verifier.go:138), the member picks it at join, and nothing makes it unique. On whakatohea-demo, all three identities carry ben.

#1902 fixes Nextcloud only (ruled A1: IDIP keys Nextcloud on sub = AID). The same collision remains for:

service where it keys on the username
Gramps Web (whakapapa) GRAMPSWEB_OIDC_USERNAME_CLAIM = "preferred_username", internal/clan/whakapapa.go:645
video (PeerTube) "username-property": "preferred_username", internal/clan/video.go:660
newsletters (Listmonk) short uid in preferred_username, internal/clan/newsletters.go:554,635
surveys identity header carries preferred_username, internal/clan/surveys.go:227
Paperless Django user keyed on it, internal/clan/paperless.go:620
portroute identity header, internal/clan/portroute.go:42

(Audit for any others while fixing this.)

Options (Ben to rule)

B. The bridge makes preferred_username unique per community. The bridge records username → AID in the roster projection the first time an AID presents (#1887's presented rows already hold it). A later AID with a taken username gets a free suffix (ben-2). One change fixes every service, and existing accounts stay where they are. Costs: first come first served (the founder presents first on IDIP), the claim can differ from what the member typed, and communities that already collided stay merged until an admin splits them.

C. Key each service on sub (AID) the way #1902 does for Nextcloud. Accounts follow the permanent identity. It is a per-service change, each service needs its own "existing accounts" answer, and some services may not support an opaque 44-char uid as a login name (to be checked per service).

D. Refuse a colliding username at the door. The bridge refuses a presentation whose username is already held by another AID, with a clear message. It is the simplest and has no suffixes, but the member cannot get in until the credential is reissued with another name, and issuance happens in the app (ADR 0235), not here.

Recommendation: B. It closes the takeover for every service at once with no migration, and it composes with #1902 (Nextcloud on the AID is unaffected by the suffix).

Acceptance criteria (after the ruling)

  • Two IDIP members whose credentials carry the same username can never reach the same account in any service in the table.
  • A seam test per ruled mechanism (e.g. the bridge's userinfo/ID token for the second AID carries a distinct preferred_username).
  • Existing accounts are handled as ruled, and kanidm communities are unchanged.

References

  • #1902 (Nextcloud: same bug, ruled A1), #1887 (where it was found), ADR 0196 (sub = AID), ADR 0235 d.5/d.6

🤖 Generated with Claude Code

## Problem On an IDIP community, every service that keys its accounts on the OIDC `preferred_username` claim lets a member **take over another member's account by choosing the same username**. `preferred_username` comes from the member's credential (`internal/idp/ledger_verifier.go:135`; words door `keri_verifier.go:138`), the member picks it at join, and nothing makes it unique. On whakatohea-demo, all three identities carry `ben`. #1902 fixes **Nextcloud only** (ruled A1: IDIP keys Nextcloud on `sub` = AID). The same collision remains for: | service | where it keys on the username | |---|---| | Gramps Web (whakapapa) | `GRAMPSWEB_OIDC_USERNAME_CLAIM = "preferred_username"`, `internal/clan/whakapapa.go:645` | | video (PeerTube) | `"username-property": "preferred_username"`, `internal/clan/video.go:660` | | newsletters (Listmonk) | short uid in `preferred_username`, `internal/clan/newsletters.go:554,635` | | surveys | identity header carries `preferred_username`, `internal/clan/surveys.go:227` | | Paperless | Django user keyed on it, `internal/clan/paperless.go:620` | | portroute | identity header, `internal/clan/portroute.go:42` | (Audit for any others while fixing this.) ## Options (Ben to rule) **B. The bridge makes `preferred_username` unique per community.** The bridge records `username → AID` in the roster projection the first time an AID presents (#1887's presented rows already hold it). A later AID with a taken username gets a free suffix (`ben-2`). One change fixes every service, and existing accounts stay where they are. Costs: first come first served (the founder presents first on IDIP), the claim can differ from what the member typed, and communities that already collided stay merged until an admin splits them. **C. Key each service on `sub` (AID) the way #1902 does for Nextcloud.** Accounts follow the permanent identity. It is a per-service change, each service needs its own "existing accounts" answer, and some services may not support an opaque 44-char uid as a login name (to be checked per service). **D. Refuse a colliding username at the door.** The bridge refuses a presentation whose username is already held by another AID, with a clear message. It is the simplest and has no suffixes, but the member cannot get in until the credential is reissued with another name, and issuance happens in the app (ADR 0235), not here. **Recommendation:** B. It closes the takeover for every service at once with no migration, and it composes with #1902 (Nextcloud on the AID is unaffected by the suffix). ## Acceptance criteria (after the ruling) - [ ] Two IDIP members whose credentials carry the same username can never reach the same account in **any** service in the table. - [ ] A seam test per ruled mechanism (e.g. the bridge's `userinfo`/ID token for the second AID carries a distinct `preferred_username`). - [ ] Existing accounts are handled as ruled, and kanidm communities are unchanged. ## References - #1902 (Nextcloud: same bug, ruled A1), #1887 (where it was found), ADR 0196 (`sub` = AID), ADR 0235 d.5/d.6 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Author
Owner

Ruled (Ben, 2026-09-26): option B. The bridge makes preferred_username unique per community. The no-triage and ready-for-human holds are removed as this comment is posted.

  • One namespace: roster rows and presented-holder rows (#1887) share one username → AID claim record in the control plane's roster projection. A username is held by the first AID recorded against it, and an existing roster row holds its username for its own AID.
  • Claim at presentation: when an AID presents (either door) with a username held by a different AID, it gets the lowest free suffix (ben-2, ben-3, …). The suffixed name is recorded against that AID and is stable: the same AID always gets the same name on later sign-ins. The claim write goes over the same bearer-authed loopback route as #1887's presented rows, with verifier-attested fields only.
  • Issued everywhere: the bridge's userinfo and ID token carry the recorded (possibly suffixed) name in preferred_username. name (the display name) and sub (the AID) are unchanged.
  • Existing accounts stay where they are: no migration. On a community where two people already share a username, whoever presents first after this lands keeps the bare name. Accounts that were already merged (the demo's ben) stay merged until an admin splits them by hand.
  • Unchanged: kanidm communities (kanidm already makes usernames unique), and #1902 (Nextcloud on IDIP keys on sub, so the suffix does not affect it).
  • Unreachable projection: if the claim cannot be read or written, the sign-in fails as records-unreachable (like #1887's presented write). It never issues an unchecked username.

Acceptance criteria, as ruled:

  • Two IDIP AIDs whose credentials carry the same username get different preferred_username values from the bridge (seam test over userinfo + the ID token). The second is <name>-2, and it is the same on a second sign-in.
  • A roster member's username is never handed to a presented AID.
  • Each service in the table (Gramps, video, newsletters, surveys, Paperless, portroute) therefore gets distinct accounts. At least one render/seam test shows the service's username claim is the bridge's preferred_username (no service-side change needed).
  • An unreachable claim record refuses the sign-in (records-unreachable) rather than issuing an unchecked name.
  • kanidm communities unchanged. No migration of existing accounts.
**Ruled (Ben, 2026-09-26): option B.** The bridge makes `preferred_username` unique per community. The `no-triage` and `ready-for-human` holds are removed as this comment is posted. - **One namespace:** roster rows and presented-holder rows (#1887) share one `username → AID` claim record in the control plane's roster projection. A username is held by the first AID recorded against it, and an existing roster row holds its username for its own AID. - **Claim at presentation:** when an AID presents (either door) with a username held by a **different** AID, it gets the lowest free suffix (`ben-2`, `ben-3`, …). The suffixed name is recorded against that AID and is **stable**: the same AID always gets the same name on later sign-ins. The claim write goes over the same bearer-authed loopback route as #1887's presented rows, with verifier-attested fields only. - **Issued everywhere:** the bridge's `userinfo` and ID token carry the recorded (possibly suffixed) name in `preferred_username`. `name` (the display name) and `sub` (the AID) are unchanged. - **Existing accounts stay where they are:** no migration. On a community where two people already share a username, whoever presents first after this lands keeps the bare name. Accounts that were already merged (the demo's `ben`) stay merged until an admin splits them by hand. - **Unchanged:** kanidm communities (kanidm already makes usernames unique), and #1902 (Nextcloud on IDIP keys on `sub`, so the suffix does not affect it). - **Unreachable projection:** if the claim cannot be read or written, the sign-in fails as records-unreachable (like #1887's presented write). It never issues an unchecked username. Acceptance criteria, as ruled: - [ ] Two IDIP AIDs whose credentials carry the same username get different `preferred_username` values from the bridge (seam test over `userinfo` + the ID token). The second is `<name>-2`, and it is the same on a second sign-in. - [ ] A roster member's username is never handed to a presented AID. - [ ] Each service in the table (Gramps, video, newsletters, surveys, Paperless, portroute) therefore gets distinct accounts. At least one render/seam test shows the service's username claim is the bridge's `preferred_username` (no service-side change needed). - [ ] An unreachable claim record refuses the sign-in (records-unreachable) rather than issuing an unchecked name. - [ ] kanidm communities unchanged. No migration of existing accounts.

swarm-claim host=matou-dev-server-01 run=33854
(automated multi-host claim — lowest live claim id works this ticket)

swarm-claim host=matou-dev-server-01 run=33854 (automated multi-host claim — lowest live claim id works this ticket)

close-report for #1908 — status success

✅ close-report gates passed — every claim verified against main; issue closed.

envelope
{
  "issue": 1908,
  "status": "success",
  "commits": [
    "641fe1137201978f0d840e26a737e1d61e9c7063"
  ],
  "changed_files": [
    "STATUS.md",
    "internal/clan/idip_username_collision_1908_test.go",
    "internal/controlapi/idip_roster.go",
    "internal/controlapi/idip_roster_test.go",
    "internal/idp/appdoor.go",
    "internal/idp/presented_seam_test.go",
    "internal/idp/presentedwriter.go",
    "internal/keria/adapter.go",
    "internal/keria/presented_test.go",
    "internal/keria/registry.go",
    "internal/keriawire/wire.go"
  ],
  "tests": [
    {
      "command": "go test ./internal/keria/ ./internal/idp/ ./internal/controlapi/ ./internal/clan/",
      "exit_code": 0
    },
    {
      "command": "go test ./...",
      "exit_code": 0
    },
    {
      "command": "golangci-lint run ./... (go_1_25 + golangci-lint v2.12.2, the flake-pinned toolchain)",
      "exit_code": 0
    },
    {
      "command": "gofmt -l (affected trees)",
      "exit_code": 0
    }
  ],
  "criteria": {
    "Two IDIP AIDs whose credentials carry the same username get different preferred_username from the bridge (userinfo + ID token); second is <name>-2, same on second sign-in": "internal/idp/presented_seam_test.go TestSeam_AppDoor_CollidingUsernamesGetDistinctPreferredUsername drives the full app-door flow to the id_token for two AIDs both carrying 'ben' -> 'ben' then 'ben-2', and re-signs-in the second to prove ben-2 is stable. id_token and userinfo are both minted by setUserinfo from the same identity (internal/idp/storage.go). Root logic: internal/keria/registry.go resolvePresentedUsername + TestRegistry_RecordPresentedMakesUsernameUnique (ben/ben-2/ben-3, stable).",
    "A roster member's username is never handed to a presented AID": "internal/keria/registry.go resolvePresentedUsername treats every roster row (st.Members) as a holder; internal/keria/presented_test.go TestRegistry_RecordPresentedYieldsToRosterUsername: a presenter colliding with a roster member's 'ben' gets 'ben-2' and the roster row is left untouched.",
    "Each service gets distinct accounts; at least one render/seam test shows the service's username claim is preferred_username (no service-side change needed)": "internal/clan/idip_username_collision_1908_test.go TestIDIP1908_ServicesKeyOnPreferredUsernameNoServiceSideChange pins Gramps (GRAMPSWEB_OIDC_USERNAME_CLAIM=preferred_username) and PeerTube (username-property=preferred_username) keep keying on preferred_username with no service-side change -- the claim #1908 now makes unique at its source (bridge/kanidm). The bridge's unique preferred_username is proven by the idp seam test above.",
    "An unreachable claim record refuses the sign-in records-unreachable rather than issuing an unchecked name": "internal/idp/appdoor.go handlePresent refuses records-unreachable when the projection write fails; internal/idp/presented_seam_test.go TestSeam_AppDoor_UnreachableProjectionRefusesRatherThanIssueUncheckedName.",
    "kanidm communities unchanged; no migration of existing accounts": "No kanidm render or mapping changed (diff touches only internal/keria, internal/idp, internal/controlapi, internal/keriawire, one clan test, STATUS.md). resolvePresentedUsername never rewrites an existing roster/presented row of another AID -- the first AID recorded keeps the bare name; TestRegistry_RecordPresentedYieldsToRosterUsername asserts the roster row is untouched."
  },
  "summary": "The IDIP bridge now makes preferred_username unique per community (roster projection resolves a colliding presenter to a stable <name>-N suffix, returned over the loopback write and minted into the id_token/userinfo), so two members who chose the same handle can never key one per-service account.",
  "blockers": []
}
**close-report** for #1908 — status `success` :white_check_mark: **close-report gates passed** — every claim verified against main; issue closed. <details><summary>envelope</summary> ```json { "issue": 1908, "status": "success", "commits": [ "641fe1137201978f0d840e26a737e1d61e9c7063" ], "changed_files": [ "STATUS.md", "internal/clan/idip_username_collision_1908_test.go", "internal/controlapi/idip_roster.go", "internal/controlapi/idip_roster_test.go", "internal/idp/appdoor.go", "internal/idp/presented_seam_test.go", "internal/idp/presentedwriter.go", "internal/keria/adapter.go", "internal/keria/presented_test.go", "internal/keria/registry.go", "internal/keriawire/wire.go" ], "tests": [ { "command": "go test ./internal/keria/ ./internal/idp/ ./internal/controlapi/ ./internal/clan/", "exit_code": 0 }, { "command": "go test ./...", "exit_code": 0 }, { "command": "golangci-lint run ./... (go_1_25 + golangci-lint v2.12.2, the flake-pinned toolchain)", "exit_code": 0 }, { "command": "gofmt -l (affected trees)", "exit_code": 0 } ], "criteria": { "Two IDIP AIDs whose credentials carry the same username get different preferred_username from the bridge (userinfo + ID token); second is <name>-2, same on second sign-in": "internal/idp/presented_seam_test.go TestSeam_AppDoor_CollidingUsernamesGetDistinctPreferredUsername drives the full app-door flow to the id_token for two AIDs both carrying 'ben' -> 'ben' then 'ben-2', and re-signs-in the second to prove ben-2 is stable. id_token and userinfo are both minted by setUserinfo from the same identity (internal/idp/storage.go). Root logic: internal/keria/registry.go resolvePresentedUsername + TestRegistry_RecordPresentedMakesUsernameUnique (ben/ben-2/ben-3, stable).", "A roster member's username is never handed to a presented AID": "internal/keria/registry.go resolvePresentedUsername treats every roster row (st.Members) as a holder; internal/keria/presented_test.go TestRegistry_RecordPresentedYieldsToRosterUsername: a presenter colliding with a roster member's 'ben' gets 'ben-2' and the roster row is left untouched.", "Each service gets distinct accounts; at least one render/seam test shows the service's username claim is preferred_username (no service-side change needed)": "internal/clan/idip_username_collision_1908_test.go TestIDIP1908_ServicesKeyOnPreferredUsernameNoServiceSideChange pins Gramps (GRAMPSWEB_OIDC_USERNAME_CLAIM=preferred_username) and PeerTube (username-property=preferred_username) keep keying on preferred_username with no service-side change -- the claim #1908 now makes unique at its source (bridge/kanidm). The bridge's unique preferred_username is proven by the idp seam test above.", "An unreachable claim record refuses the sign-in records-unreachable rather than issuing an unchecked name": "internal/idp/appdoor.go handlePresent refuses records-unreachable when the projection write fails; internal/idp/presented_seam_test.go TestSeam_AppDoor_UnreachableProjectionRefusesRatherThanIssueUncheckedName.", "kanidm communities unchanged; no migration of existing accounts": "No kanidm render or mapping changed (diff touches only internal/keria, internal/idp, internal/controlapi, internal/keriawire, one clan test, STATUS.md). resolvePresentedUsername never rewrites an existing roster/presented row of another AID -- the first AID recorded keeps the bare name; TestRegistry_RecordPresentedYieldsToRosterUsername asserts the roster row is untouched." }, "summary": "The IDIP bridge now makes preferred_username unique per community (roster projection resolves a colliding presenter to a stable <name>-N suffix, returned over the loopback write and minted into the id_token/userinfo), so two members who chose the same handle can never key one per-service account.", "blockers": [] } ``` </details>
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
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
Matou/idss#1908
No description provided.