cairn-enc dogfood logs "FIRST-RUN SETUP available" on every start #852

Closed
opened 2026-10-06 21:38:50 +00:00 by Cordy · 2 comments
Owner

Seen after the v0.6.318 rollout (2026-10-06). The cairn-enc pod (OIDC mode, keycloak-profile custody) logs on start:

level=WARN msg="FIRST-RUN SETUP available — open /setup and paste this one-time token" token=…

The cairn-openbao pod (also OIDC) does not log it.

Questions to answer when worked on:

  • Is this new in v0.6.318, or older? Check earlier pod logs and the git history of internal/auth/setup.go and its wiring in main.go. The revocation work touched the OIDC-mode local sign-in store that the setup flow uses.
  • What decides that setup is "available": an empty local-users.json? Is that correct on an OIDC instance that already has IdP admins?
  • Security: a live setup token on a running, in-use instance could let anyone holding the token (it's in the pod log) create a local admin. Check what /setup actually allows once an instance is in use, and whether the token should be suppressed, or setup closed, once any admin exists (IdP admins, auth.admins, runtime admins).
  • How this relates to #846 (where the wizard's initial admin lands, and last-admin protection).

Planned after the Keycloak back-channel logout check on the dogfood (#839). Open decisions are asked when this is worked on.

Seen after the v0.6.318 rollout (2026-10-06). The cairn-enc pod (OIDC mode, keycloak-profile custody) logs on start: ``` level=WARN msg="FIRST-RUN SETUP available — open /setup and paste this one-time token" token=… ``` The cairn-openbao pod (also OIDC) does not log it. **Questions to answer when worked on:** - Is this new in v0.6.318, or older? Check earlier pod logs and the git history of `internal/auth/setup.go` and its wiring in main.go. The revocation work touched the OIDC-mode local sign-in store that the setup flow uses. - What decides that setup is "available": an empty `local-users.json`? Is that correct on an OIDC instance that already has IdP admins? - **Security:** a live setup token on a running, in-use instance could let anyone holding the token (it's in the pod log) create a local admin. Check what `/setup` actually allows once an instance is in use, and whether the token should be suppressed, or setup closed, once any admin exists (IdP admins, `auth.admins`, runtime admins). - How this relates to #846 (where the wizard's initial admin lands, and last-admin protection). Planned after the Keycloak back-channel logout check on the dogfood (#839). Open decisions are asked when this is worked on.
Author
Owner

Investigation (2026-10-06)

Not new in v0.6.318. Since #533 (993dbf9d, 2026-09-14: local accounts in every auth mode), cmd/cairnd/main.go (~L852) opens first-run setup in every auth mode whenever local-users.json is empty and auth.users is empty. cairn-enc (OIDC) has never had a local account, so it has logged a fresh token on every start since then. cairn-openbao has a local account, so it doesn't. The revocation work only changed which session store setup uses.

What the token allows (internal/auth/setup.go): POST /setup with the token creates a local administrator and signs that person in. It stays open until the first local account exists. GET /setup/status publicly answers pending: true.

Risk: on an instance that is already in use with IdP admins, anyone who can read the pod log can create a full admin that the IdP doesn't know about, with no time limit. Pod logs often reach a wider audience than the server itself (log shipping, kubectl logs rights, support bundles). The design note in setup.go ("whoever races first cannot claim admin") holds, but "first run" quietly became "forever, until someone adds a local account".

How others handle it (sources)

  • Portainer: an uninitialised instance allows admin creation for only 5 minutes after start, then stops until restarted (oneuptime). Its init endpoints still had an unauthenticated admin-takeover CVE (CVE-2026-55761).
  • Jenkins: a one-time unlock password in a file and the log, needed only for the post-install wizard; after that the instance is locked down (jenkins.io).
  • Gitea/Forgejo: INSTALL_LOCK defaults to false, so the installer stays reachable until it's locked. Exposed unlocked installers are an abused misconfiguration that leads to admin takeover and RCE (Wiz).

The lesson: a bootstrap path must close by itself once the instance is in use, and should only be open for a short window.

Options (decision for Nikola)

  • A. Close setup when the instance already has an admin. Don't open it, and don't log a token, when an IdP or directory admin exists (auth.admins, admin groups, runtime admins) or any admin has ever signed in. Store a persistent "setup closed" marker in state.
  • B. Time window like Portainer. The token only works for N minutes (for example 30) after start; after that, restart to reopen.
  • C. Only in local mode. Never open setup in OIDC or LDAP mode. Break-glass there is auth.users or an IdP admin adding a local account under Users & access.
  • Recommended: A + B. An already-used instance never exposes setup. A genuinely fresh instance gets a 30-minute window. It also covers the D11 wizard flow (#533), whose step 2 still works on a fresh install.

Related: #846 (where the wizard's admin lands, and last-admin protection).

## Investigation (2026-10-06) **Not new in v0.6.318.** Since #533 (993dbf9d, 2026-09-14: local accounts in every auth mode), `cmd/cairnd/main.go` (~L852) opens first-run setup in **every** auth mode whenever `local-users.json` is empty and `auth.users` is empty. cairn-enc (OIDC) has never had a local account, so it has logged a fresh token on every start since then. cairn-openbao has a local account, so it doesn't. The revocation work only changed which session store setup uses. **What the token allows** (`internal/auth/setup.go`): `POST /setup` with the token creates a **local administrator** and signs that person in. It stays open until the first local account exists. `GET /setup/status` publicly answers `pending: true`. **Risk:** on an instance that is already in use with IdP admins, anyone who can read the pod log can create a full admin that the IdP doesn't know about, with no time limit. Pod logs often reach a wider audience than the server itself (log shipping, `kubectl logs` rights, support bundles). The design note in setup.go ("whoever races first cannot claim admin") holds, but "first run" quietly became "forever, until someone adds a local account". ## How others handle it (sources) - **Portainer:** an uninitialised instance allows admin creation for only **5 minutes** after start, then stops until restarted ([oneuptime](https://oneuptime.com/blog/post/2026-03-20-portainer-admin-timeout-fix/view)). Its init endpoints still had an unauthenticated admin-takeover CVE ([CVE-2026-55761](https://securelayer7.net/lab/cve-2026-55761-portainer-unauthenticated-admin-takeover-init-restore)). - **Jenkins:** a one-time unlock password in a file and the log, needed only for the post-install wizard; after that the instance is locked down ([jenkins.io](https://jenkins.io/doc/book/installing/macos)). - **Gitea/Forgejo:** `INSTALL_LOCK` defaults to false, so the installer stays reachable until it's locked. Exposed unlocked installers are an abused misconfiguration that leads to admin takeover and RCE ([Wiz](https://threats.wiz.io/all-techniques/misconfigured-gitea-abuse)). The lesson: a bootstrap path must close by itself once the instance is in use, and should only be open for a short window. ## Options (decision for Nikola) - **A. Close setup when the instance already has an admin.** Don't open it, and don't log a token, when an IdP or directory admin exists (`auth.admins`, admin groups, runtime admins) or any admin has ever signed in. Store a persistent "setup closed" marker in state. - **B. Time window like Portainer.** The token only works for N minutes (for example 30) after start; after that, restart to reopen. - **C. Only in local mode.** Never open setup in OIDC or LDAP mode. Break-glass there is `auth.users` or an IdP admin adding a local account under Users & access. - **Recommended: A + B.** An already-used instance never exposes setup. A genuinely fresh instance gets a 30-minute window. It also covers the D11 wizard flow (#533), whose step 2 still works on a fresh install. Related: #846 (where the wizard's admin lands, and last-admin protection).
Author
Owner

Decision (Nikola, 2026-10-06): A + B.

  • A: setup never opens, and no token is logged, once the instance has any admin: IdP/directory admins, auth.admins, admin groups, runtime admins, or any admin who has signed in. A lasting "setup closed" marker is kept in state, so a restart doesn't reopen it.
  • B: on a truly fresh instance the token works for 30 minutes after start. After that, setup closes until the next restart, which opens a new 30-minute window with a new token.
**Decision (Nikola, 2026-10-06): A + B.** - **A:** setup never opens, and no token is logged, once the instance has any admin: IdP/directory admins, `auth.admins`, admin groups, runtime admins, or any admin who has signed in. A lasting "setup closed" marker is kept in state, so a restart doesn't reopen it. - **B:** on a truly fresh instance the token works for 30 minutes after start. After that, setup closes until the next restart, which opens a new 30-minute window with a new token.
Cordy closed this issue 2026-10-06 22:14:36 +00:00
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#852
No description provided.