operator-document-archive: allauth auto-signup forks a 2nd, unprivileged account #1607

Closed
opened 2026-09-18 20:56:13 +00:00 by matou-build-agent · 1 comment

The failure

Drive 20260918T200406Z (commit 5b1ca810, artifacts/verdict.json: 45 legs, 40 green, 5 red, 0 skip) went red first at operator-document-archive. artifacts/journey.json carries the same string as the drive's fault:

document-archive: the granted operator did not reach the admin surface /admin/ — HTTP 200, landed "https://document-archive.roles-proof.idss.nz/admin/login/?next=/admin/", 0 match(es) for "#user-tools"; the page reads: "Skip to main content Paperless-ngx You are authenticated as proof-operator3, but are not authorized to access this page. Would you like to login to a different account?"

The username in Paperless's own refusal — proof-operator3, not proof-operator — is the whole fault.

What the live box said

The bare access line in the brief was refused (root@209.38.94.45: Permission denied (publickey,keyboard-interactive)), but artifacts/live-box.json records kept_on_red: true and the drive's own key at state/rent-operator/id_ed25519; read-only over that key the box answered. systemctl --failed is empty — nothing crashed.

$ psql -d paperless -c 'SELECT id, username, is_staff, is_superuser, email, date_joined FROM auth_user ORDER BY id;'
 id |    username     | is_staff | is_superuser |            email             |      date_joined
  3 | admin           | t        | t            | root@localhost               | 2026-09-18 20:40:34+00
  4 | proof-operator  | t        | t            |                              | 2026-09-18 20:43:05+00
  5 | operator        | t        | t            |                              | 2026-09-18 20:45:28+00
  6 | proof-operator3 | f        | f            | proof-operator@idss-proof.nz | 2026-09-18 20:47:01+00
  7 | proof-member    | f        | f            | proof-member@idss-proof.nz   | 2026-09-18 20:47:11+00

$ psql -d paperless -c 'SELECT id, user_id, provider, uid FROM socialaccount_socialaccount ORDER BY id;'
 id | user_id | provider |                 uid
  1 |       6 | kanidm   | 35655f84-674b-45ef-afbb-0e3ef5fa487c
  2 |       7 | kanidm   | 7b8eb741-9f26-4da6-b9c3-80b5a1e7fde3

Read the timestamps against the leg order: 20:43:05 the grant-operator leg pre-provisions id 4 proof-operator (staff+superuser, no email); 20:45:28 the redeploy hook does the same for the founding operator (id 5, same trap, un-sprung only because nobody signed in as them); 20:47:01 the door leg signs in through kanidm and django-allauth creates a brand-new id 6 proof-operator3 with no admin flags, binding the kanidm uid to that row. Id 4 is orphaned and never touched again.

The defect

internal/documentarchivesvc/documentarchivesvc.go:227 states the premise the box falsifies:

The account is username-keyed, exactly the row PAPERLESS_SOCIAL_AUTO_SIGNUP matches on first sign-in (mozilla-django-oidc links by the preferred_username claim), so the auto-provision finds this row rather than making a second, member-role one

Paperless-ngx does not use mozilla-django-oidc. internal/clan/paperless.go:358 registers allauth.socialaccount.providers.openid_connect and :359 sets PAPERLESS_SOCIAL_AUTO_SIGNUP = "true". Allauth's auto-signup never adopts an existing local account by username — on collision it suffixes to a free one. That is proof-operator3 exactly.

Permanent, not a race. account() (documentarchivesvc.go:282) looks the person up with GET /api/users/?username=proof-operator, still finds orphaned id 4 holding both flags, and ReconcileRole takes the idempotent no-op at :209 on every later pass. So artifacts/roles/detail-proof-operator-after-redeploy.json reads {"service":"document-archive","has_access":true,"role_in_app":"superuser"} with no not_applied marker — the panel tells the community the operator bit is applied while the box holds them at no privilege. That is a truthfulness fault on a posture card, not only a missing bit.

member-document-archive is green for the right reason: a plain member is a deliberate no-op (:203), so no pre-provisioned row exists to collide with and proof-member (id 7) auto-signs-up at its exact username.

Subsidiary, same territory: group sync produced nothing — SELECT g.name, u.username FROM auth_group g JOIN auth_user_groups ug … JOIN auth_user u … returns (0 rows). paperless.go:360 sets PAPERLESS_SOCIAL_ACCOUNT_SYNC_GROUPS = "true" and the oneshot maps operators -> admins / idm_all_persons -> members, but neither Django group exists and Paperless's sync assigns to groups that already exist, it does not create them. Worth fixing alongside — it cannot substitute, because /admin/ gates on the is_staff bit no Django group can confer.

Suspected layer

Product. The document-archive port's identity-binding assumption (internal/documentarchivesvc/documentarchivesvc.go:224-241), written against the wrong OIDC library's semantics, plus the allauth linking settings absent from the render (internal/clan/paperless.go:355-361). Not harness (the leg asserted the right thing and quoted Paperless's own words) and not infra (zero failed units).

What plugging it needs

A human ruling first — the candidates are materially different products:

  1. Auto-connect by verified email — SOCIALACCOUNT_EMAIL_AUTHENTICATION + …_AUTO_CONNECT, with provisionOperator writing the email and a verified account_emailaddress row. This lets an IdP-asserted email silently adopt a pre-existing local superuser account: a security posture at a trust moment, wants an ADR.
  2. Drop pre-provision; reconcile after first sign-in, keyed on the socialaccount uid — honest and narrow, but it reverses #1553's ruling (an operator granted before first sign-in lands non-admin until a reconcile pass catches them).
  3. Carry the bit in a claim via an allauth adapter/signal setting is_staff/is_superuser from pgroups at each sign-in — closest to "an operator is admin everywhere" and self-healing, but new product surface on the sign-in path.

Whichever is ruled, the fix spans the render, the port and the double, and cannot be proven on the workstation. Make the double faithful FIRST: internal/documentarchivesvc/documentarchivesvc_test.go:50-52's signUp is username-keyed and its comment encodes the very premise that produced this bug — teach it to suffix on collision and record the social binding, watch the pre-provision test go red the way the box did, then build the ruled fix. The proof is the next drive's operator-document-archive leg.

The other four reds — a KNOWN frontier, no new ticket

operator-whakapapa, member-whakapapa, operator-newsletters, member-newsletters all show kanidm's own Error Code: InvalidState. Confirmed on the live box by the Operation IDs the legs recorded:

3c1d5247-… ERROR 🚨 [error]: No PKCE code challenge was provided with client in enforced PKCE mode | event_tag_id: 12 | o2rs.name: "whakapapa" → error: invalid_request

…and identically for c2cbf6ce (whakapapa), 49be6b32 and b869b83e (o2rs.name: "newsletters"). This is GOTCHAS #252, whose entry already names these two clients as out of scope:

The same is true and NOT yet fixed for two more clients — … Listmonk 6.1.0's binary carries no code_challenge_method at all, and Gramps Web API 3.13.1 registers its provider with client_kwargs = {"scope": …} only. Neither app has a PKCE switch; the only lever is kanidm's warning-insecure-client-disable-pkce on that client — a security-posture change against ADR 0196's "PKCE S256 required for every client", so it waits on Ben's ruling.

And commit e74b1cbb (which landed the same fix for Paperless) says so in its own message: "NOT fixed, waiting on Ben: Listmonk 6.1.0 and Gramps Web API 3.13.1 send no PKCE and have no switch; disabling enforcement on those clients is a security-posture change against ADR 0196." These four re-prove on the next fire and want no new ticket.

Two corrections to the framing

  • The pairing frontier does not apply to this drive. pair is green (237 ms), and artifacts/legs.json contains no skip entries at all (verdict.json: "skip": 0) — so no skip reason in this drive names anything out of scope. The PKCE frontier above is established from GOTCHAS #252 and e74b1cbb, not from skip reasons.
  • artifacts/healer-refusal.json is present (the drive's healer refused to fast-lane this, confident: false, sig aae325ce6cbf) and its document-archive diagnosis is sound — I re-derived it against the box. But its dismissal of the PKCE four as "already addressed … landed by c0c8d550 (ADR 0254), which is newer than this drive's commit" does not check out: git log c0c8d550 → unknown revision, and the ADR sequence ends at 0253-…. The right reason those four are not filed is the standing GOTCHAS #252 ruling, not a fix that has landed.

Absent from the run directory

No logs/electron-* or helper log beyond helper-opened-urls (28 bytes); the logs/guest-*.log set is 127 bytes each (stub-sized — this is a droplet drive, not a guest VM one, and host.json records qemu: exit ENOENT). artifacts/legs/, artifacts/nextcloud/ and the Playwright report under report/ exist but were not needed — the box answered directly.

drive 20260918T200406Z red at operator-whakapapa: kanidm rendered its OWN error page for proof-operator at whakapapa (https://id.roles-proof.idss.nz/ui/oauth2?response_type=code&client_id=whakapapa&redirect_uri=https%3A%2F%2Fwhakapapa.roles-proof.ids
evidence: /home/dev/swarm/Matou/idss/test-results/drive-rented-services/20260918T200406Z on matou-workstation (legs.json and whatever else the drive harvested there) — a representative screenshot is attached here if one was captured

## The failure Drive `20260918T200406Z` (commit `5b1ca810`, `artifacts/verdict.json`: 45 legs, 40 green, 5 red, **0 skip**) went red first at `operator-document-archive`. `artifacts/journey.json` carries the same string as the drive's `fault`: > document-archive: the granted operator did not reach the admin surface /admin/ — HTTP 200, landed "https://document-archive.roles-proof.idss.nz/admin/login/?next=/admin/", 0 match(es) for "#user-tools"; the page reads: "Skip to main content Paperless-ngx **You are authenticated as proof-operator3, but are not authorized to access this page.** Would you like to login to a different account?" The username in Paperless's own refusal — `proof-operator3`, not `proof-operator` — is the whole fault. ## What the live box said The bare access line in the brief was refused (`root@209.38.94.45: Permission denied (publickey,keyboard-interactive)`), but `artifacts/live-box.json` records `kept_on_red: true` and the drive's own key at `state/rent-operator/id_ed25519`; read-only over that key the box answered. `systemctl --failed` is **empty** — nothing crashed. ``` $ psql -d paperless -c 'SELECT id, username, is_staff, is_superuser, email, date_joined FROM auth_user ORDER BY id;' id | username | is_staff | is_superuser | email | date_joined 3 | admin | t | t | root@localhost | 2026-09-18 20:40:34+00 4 | proof-operator | t | t | | 2026-09-18 20:43:05+00 5 | operator | t | t | | 2026-09-18 20:45:28+00 6 | proof-operator3 | f | f | proof-operator@idss-proof.nz | 2026-09-18 20:47:01+00 7 | proof-member | f | f | proof-member@idss-proof.nz | 2026-09-18 20:47:11+00 $ psql -d paperless -c 'SELECT id, user_id, provider, uid FROM socialaccount_socialaccount ORDER BY id;' id | user_id | provider | uid 1 | 6 | kanidm | 35655f84-674b-45ef-afbb-0e3ef5fa487c 2 | 7 | kanidm | 7b8eb741-9f26-4da6-b9c3-80b5a1e7fde3 ``` Read the timestamps against the leg order: **20:43:05** the `grant-operator` leg pre-provisions id 4 `proof-operator` (staff+superuser, no email); **20:45:28** the redeploy hook does the same for the founding `operator` (id 5, same trap, un-sprung only because nobody signed in as them); **20:47:01** the door leg signs in through kanidm and django-allauth creates a *brand-new* id 6 `proof-operator3` with no admin flags, binding the kanidm `uid` to **that** row. Id 4 is orphaned and never touched again. ## The defect `internal/documentarchivesvc/documentarchivesvc.go:227` states the premise the box falsifies: > The account is username-keyed, exactly the row PAPERLESS_SOCIAL_AUTO_SIGNUP matches on first sign-in (**mozilla-django-oidc links by the preferred_username claim**), so the auto-provision finds this row rather than making a second, member-role one Paperless-ngx does not use mozilla-django-oidc. `internal/clan/paperless.go:358` registers `allauth.socialaccount.providers.openid_connect` and `:359` sets `PAPERLESS_SOCIAL_AUTO_SIGNUP = "true"`. Allauth's auto-signup never adopts an existing local account by username — on collision it suffixes to a free one. That is `proof-operator3` exactly. **Permanent, not a race.** `account()` (`documentarchivesvc.go:282`) looks the person up with `GET /api/users/?username=proof-operator`, still finds orphaned id 4 holding both flags, and `ReconcileRole` takes the idempotent no-op at `:209` on every later pass. So `artifacts/roles/detail-proof-operator-after-redeploy.json` reads `{"service":"document-archive","has_access":true,"role_in_app":"superuser"}` with **no `not_applied` marker** — the panel tells the community the operator bit is applied while the box holds them at no privilege. That is a truthfulness fault on a posture card, not only a missing bit. `member-document-archive` is green for the right reason: a plain member is a deliberate no-op (`:203`), so no pre-provisioned row exists to collide with and `proof-member` (id 7) auto-signs-up at its exact username. **Subsidiary, same territory:** group sync produced nothing — `SELECT g.name, u.username FROM auth_group g JOIN auth_user_groups ug … JOIN auth_user u …` returns `(0 rows)`. `paperless.go:360` sets `PAPERLESS_SOCIAL_ACCOUNT_SYNC_GROUPS = "true"` and the oneshot maps `operators -> admins` / `idm_all_persons -> members`, but neither Django group exists and Paperless's sync assigns to groups that already exist, it does not create them. Worth fixing alongside — it cannot substitute, because `/admin/` gates on the `is_staff` bit no Django group can confer. ## Suspected layer **Product.** The document-archive port's identity-binding assumption (`internal/documentarchivesvc/documentarchivesvc.go:224-241`), written against the wrong OIDC library's semantics, plus the allauth linking settings absent from the render (`internal/clan/paperless.go:355-361`). Not harness (the leg asserted the right thing and quoted Paperless's own words) and not infra (zero failed units). ## What plugging it needs A human ruling first — the candidates are materially different products: 1. **Auto-connect by verified email** — `SOCIALACCOUNT_EMAIL_AUTHENTICATION` + `…_AUTO_CONNECT`, with `provisionOperator` writing the email and a verified `account_emailaddress` row. This lets an IdP-asserted email silently adopt a pre-existing local **superuser** account: a security posture at a trust moment, wants an ADR. 2. **Drop pre-provision; reconcile after first sign-in**, keyed on the socialaccount `uid` — honest and narrow, but it reverses #1553's ruling (an operator granted before first sign-in lands non-admin until a reconcile pass catches them). 3. **Carry the bit in a claim** via an allauth adapter/signal setting `is_staff`/`is_superuser` from `pgroups` at each sign-in — closest to "an operator is admin everywhere" and self-healing, but new product surface on the sign-in path. Whichever is ruled, the fix spans the render, the port and the double, and **cannot be proven on the workstation**. Make the double faithful FIRST: `internal/documentarchivesvc/documentarchivesvc_test.go:50-52`'s `signUp` is username-keyed and its comment encodes the very premise that produced this bug — teach it to suffix on collision and record the social binding, watch the pre-provision test go red the way the box did, then build the ruled fix. The proof is the next drive's `operator-document-archive` leg. ## The other four reds — a KNOWN frontier, no new ticket `operator-whakapapa`, `member-whakapapa`, `operator-newsletters`, `member-newsletters` all show kanidm's own `Error Code: InvalidState`. Confirmed on the live box by the Operation IDs the legs recorded: > `3c1d5247-… ERROR 🚨 [error]: No PKCE code challenge was provided with client in enforced PKCE mode | event_tag_id: 12 | o2rs.name: "whakapapa"` → `error: invalid_request` …and identically for `c2cbf6ce` (whakapapa), `49be6b32` and `b869b83e` (`o2rs.name: "newsletters"`). This is **GOTCHAS #252**, whose entry already names these two clients as out of scope: > **The same is true and NOT yet fixed for two more clients** — … Listmonk 6.1.0's binary carries no `code_challenge_method` at all, and Gramps Web API 3.13.1 registers its provider with `client_kwargs = {"scope": …}` only. Neither app has a PKCE switch; the only lever is kanidm's `warning-insecure-client-disable-pkce` on that client — a security-posture change against ADR 0196's "PKCE S256 required for every client", so it waits on Ben's ruling. And commit `e74b1cbb` (which landed the same fix for Paperless) says so in its own message: *"NOT fixed, waiting on Ben: Listmonk 6.1.0 and Gramps Web API 3.13.1 send no PKCE and have no switch; disabling enforcement on those clients is a security-posture change against ADR 0196."* These four re-prove on the next fire and want no new ticket. ## Two corrections to the framing - **The pairing frontier does not apply to this drive.** `pair` is green (237 ms), and `artifacts/legs.json` contains **no skip entries at all** (`verdict.json`: `"skip": 0`) — so no skip reason in this drive names anything out of scope. The PKCE frontier above is established from GOTCHAS #252 and `e74b1cbb`, not from skip reasons. - **`artifacts/healer-refusal.json` is present** (the drive's healer refused to fast-lane this, `confident: false`, sig `aae325ce6cbf`) and its document-archive diagnosis is sound — I re-derived it against the box. But its dismissal of the PKCE four as *"already addressed … landed by `c0c8d550` (ADR 0254), which is newer than this drive's commit"* **does not check out**: `git log c0c8d550` → `unknown revision`, and the ADR sequence ends at `0253-…`. The right reason those four are not filed is the standing GOTCHAS #252 ruling, not a fix that has landed. ## Absent from the run directory No `logs/electron-*` or helper log beyond `helper-opened-urls` (28 bytes); the `logs/guest-*.log` set is 127 bytes each (stub-sized — this is a droplet drive, not a guest VM one, and `host.json` records `qemu: exit ENOENT`). `artifacts/legs/`, `artifacts/nextcloud/` and the Playwright report under `report/` exist but were not needed — the box answered directly. drive `20260918T200406Z` red at `operator-whakapapa`: `kanidm rendered its OWN error page for proof-operator at whakapapa (https://id.roles-proof.idss.nz/ui/oauth2?response_type=code&client_id=whakapapa&redirect_uri=https%3A%2F%2Fwhakapapa.roles-proof.ids` evidence: `/home/dev/swarm/Matou/idss/test-results/drive-rented-services/20260918T200406Z` on matou-workstation (legs.json and whatever else the drive harvested there) — a representative screenshot is attached here if one was captured <!-- rehearsal-sig: 4107bcefcfc0 -->
Owner

Duplicate of #1605 (same run, same diagnosis, filed twice by the reporter). Closing; the ruling lives on #1605.

Duplicate of #1605 (same run, same diagnosis, filed twice by the reporter). Closing; the ruling lives on #1605.
ben closed this issue 2026-09-18 20:58:26 +00:00
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.

Reference
Matou/idss#1607
No description provided.