kanidm: setPassword()'s /v1/credential/_update body has the [CUSessionToken, CURequest] array elements backwards #580

Closed
opened 2026-08-15 06:17:57 +00:00 by ben · 2 comments
Owner

Found live

While provisioning a real person's password against a live kanidm 1.10.3 during #319's golden-clan-lab session (ADR 0174 standing), I reproduced internal/kanidm/kanidm.go's setPassword() REST sequence by hand with curl against the SAME server.

setPassword() (kanidm.go:~600) posts:

action := []any{begun.Token, map[string]string{"password": password}}
// POST /v1/credential/_update  body = [CUSessionToken, CURequest]

Against real kanidm this array order 500s: Failed to deserialize CURequest: Error("unknown variant \`, expected one of `primaryremove`, `passwordqualitycheck`, `password`, ...")— the server decodes array position 0 as theCURequest(the action enum) and position 1 as theCUSessionToken, i.e. the body must be [CURequest, CUSessionToken], the REVERSE of what the code sends. Swapping the order ([{"password":...}, token]) returns 200 with can_commit:true`.

This is adjacent to #551 (closed, same call sequence — fixed the _commit URL) but #551's own writeup already asserted this order as correct ("the begin and set-password calls work exactly as setPassword sends them, once the array element order is [CURequest, CUSessionToken]") without actually changing kanidm.go's array literal to match — the code today still has [begun.Token, map...], i.e. [CUSessionToken, CURequest], the wrong way round. Possibly #551 curl-verified the correct order by hand but never diffed it back against the literal Go code.

Impact

Any production/founding path that calls Adapter's admin password-set flow (setPassword) would 500 at the /v1/credential/_update step against real kanidm — this path has still never been exercised live end-to-end (matches the #319/#320/#551 pattern of bugs that only surface once code meets a real deployed kanidm).

Suggested fix

internal/kanidm/kanidm.go — swap the array literal to []any{map[string]string{"password": password}, begun.Token}. TDD against a local kanidmd + curl loop (#320's shape, no clan-lab needed) or a contract test double.

Out of #319's scope (mail's own ticket) — filed separately per the ticket's "work only this ticket" rule.

Ruled by agent under ADR 0174 — veto anytime. This is a bug report with a proposed fix, not itself a ruling; no code changed here.

## Found live While provisioning a real person's password against a live kanidm 1.10.3 during #319's golden-clan-lab session (ADR 0174 standing), I reproduced `internal/kanidm/kanidm.go`'s `setPassword()` REST sequence by hand with curl against the SAME server. `setPassword()` (kanidm.go:~600) posts: ```go action := []any{begun.Token, map[string]string{"password": password}} // POST /v1/credential/_update body = [CUSessionToken, CURequest] ``` Against real kanidm this array order 500s: `Failed to deserialize CURequest: Error("unknown variant \`<token-string>\`, expected one of \`primaryremove\`, \`passwordqualitycheck\`, \`password\`, ...")` — the server decodes array position 0 as the `CURequest` (the action enum) and position 1 as the `CUSessionToken`, i.e. the body must be `[CURequest, CUSessionToken]`, the REVERSE of what the code sends. Swapping the order (`[{"password":...}, token]`) returns 200 with `can_commit:true`. This is adjacent to #551 (closed, same call sequence — fixed the `_commit` URL) but #551's own writeup already asserted this order as correct ("the begin and set-password calls work exactly as setPassword sends them, once the array element order is [CURequest, CUSessionToken]") without actually changing kanidm.go's array literal to match — the code today still has `[begun.Token, map...]`, i.e. `[CUSessionToken, CURequest]`, the wrong way round. Possibly #551 curl-verified the correct order by hand but never diffed it back against the literal Go code. ## Impact Any production/founding path that calls `Adapter`'s admin password-set flow (`setPassword`) would 500 at the `/v1/credential/_update` step against real kanidm — this path has still never been exercised live end-to-end (matches the #319/#320/#551 pattern of bugs that only surface once code meets a real deployed kanidm). ## Suggested fix `internal/kanidm/kanidm.go` — swap the array literal to `[]any{map[string]string{"password": password}, begun.Token}`. TDD against a local kanidmd + curl loop (#320's shape, no clan-lab needed) or a contract test double. Out of #319's scope (mail's own ticket) — filed separately per the ticket's "work only this ticket" rule. Ruled by agent under ADR 0174 — veto anytime. This is a bug report with a proposed fix, not itself a ruling; no code changed here.
Author
Owner

swarm-claim host=elitebook-distributed-server-03 run=6697
(automated multi-host claim — lowest live claim id works this ticket)

swarm-claim host=elitebook-distributed-server-03 run=6697 (automated multi-host claim — lowest live claim id works this ticket)
Author
Owner

close-report for #580 — status success

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

envelope
{
  "issue": 580,
  "status": "success",
  "commits": [
    "e198b8cd3dbeb58d123a39c11b6d25aab7fa2a33"
  ],
  "changed_files": [
    "internal/kanidm/kanidm.go",
    "internal/kanidm/fakekanidm_test.go",
    "STATUS.md"
  ],
  "tests": [
    {
      "command": "nix develop .#go-ci --command go test ./internal/kanidm/",
      "exit_code": 0
    }
  ],
  "criteria": {
    "setPassword posts [CURequest, CUSessionToken] not the reverse": "internal/kanidm/kanidm.go:601 now sends []any{map[string]string{\"password\": password}, begun.Token} (commit e198b8c)",
    "the contract double enforces the real kanidm body order so the bug reds at the seam": "internal/kanidm/fakekanidm_test.go decodes action[0] as CURequest and action[1] as CUSessionToken; the reversed literal 400s (confirmed red before the fix), green after"
  },
  "summary": "setPassword's /v1/credential/_update body now posts [CURequest, CUSessionToken], the order real kanidm 1.10.3 decodes, with the fake double holding that contract.",
  "blockers": []
}
**close-report** for #580 — status `success` :white_check_mark: **close-report gates passed** — every claim verified against main; closing. <details><summary>envelope</summary> ```json { "issue": 580, "status": "success", "commits": [ "e198b8cd3dbeb58d123a39c11b6d25aab7fa2a33" ], "changed_files": [ "internal/kanidm/kanidm.go", "internal/kanidm/fakekanidm_test.go", "STATUS.md" ], "tests": [ { "command": "nix develop .#go-ci --command go test ./internal/kanidm/", "exit_code": 0 } ], "criteria": { "setPassword posts [CURequest, CUSessionToken] not the reverse": "internal/kanidm/kanidm.go:601 now sends []any{map[string]string{\"password\": password}, begun.Token} (commit e198b8c)", "the contract double enforces the real kanidm body order so the bug reds at the seam": "internal/kanidm/fakekanidm_test.go decodes action[0] as CURequest and action[1] as CUSessionToken; the reversed literal 400s (confirmed red before the fix), green after" }, "summary": "setPassword's /v1/credential/_update body now posts [CURequest, CUSessionToken], the order real kanidm 1.10.3 decodes, with the fake double holding that contract.", "blockers": [] } ``` </details>
ben closed this issue 2026-08-15 06:30:00 +00:00
Sign in to join this conversation.
No milestone
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
Matou/idss#580
No description provided.