fleetwire: MintToken denies idm_admin 30/30 attempts though an on-box login succeeds with the same secret file seconds earlier #641
Labels
No labels
agent-blocked
agent-working
autopilot
bug
deferred
deploy-pending
enhancement
landing-pr
model-haiku
model-opus
model-sonnet
needs-design
needs-info
needs-triage
no-triage
out-of-scope
priority
ready-for-agent
ready-for-human
ready-for-session
rehearsal-183
snapshot-pending
standing-drive
wayfinder:grilling
wayfinder:map
wayfinder:prototype
wayfinder:research
wayfinder:task
wontfix
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Blocks
Reference
Matou/idss#641
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Failure
Activation leg red, signature
4c82deb1e678:Run:
test-results/drive-selfhosted/20260821T224036Z.Evidence
internal/fleetwire/enrolment.go:175-203(MintToken) races kanidm settling after the activation-phaseswitch-to-configurationrestartskanidm.service— this retry (mintTokenSettleAttempts = 30, 2s poll) was added by #635 and the Begin-step lockout classification by #636 (both already landed, confirmed in this run's git log). Both are working as designed here, and the leg still exhausts all 30 attempts with zero successes.logs/droplet-journal.txt:22:48:11-13— activation's secondswitch-to-configurationrestartskanidm.service(store pathyd9kiw991c1cl53wsjwrqk3llqlxgxi9, a distinct generation from the22:47:23deploy-takeover switch).22:48:13(line 494) —handle_admin_recover_account name: "idm_admin"fires (kanidm's built-in provisioning, sourced fromconfig.clan.core.vars.generators.kanidm-admins.files.idm_admin.pathperinternal/clan/vmguest.go:703).22:48:13(lines 503-511) — the on-boxkanidm-credential-flooroneshot (internal/clan/vmguest.go:960-969,export KANIDM_PASSWORD="$(cat ${...idm_admin.path})",kanidm login --name idm_admin) succeeds immediately (Auth result: Success(Token)foridm_admin@id.rehearsal-b.idss.nz) — proving the generator file's current content is a working idm_admin password at this exact moment.22:48:21through22:49:33(grepAuthenticationDenied) — fleetwire'sMintToken, reading the SAME file over SSH (internal/fleetwire/enrolment.go:140-141,cat "$(cat /etc/idss/kanidm-idm-admin-path)"), is denied every single attempt: exactly 15Handler::Password -> Result::Denied - incorrect passwordinterleaved with 15Account is temporarily locked(kanidm's own lockout, self-inflicted by the repeated wrong attempts) = 30/30, matching the error's "did not settle within 30 attempts" exactly. Not one attempt in the ~80s window succeeds, including attempts made while the account was provably unlocked — so this isn't kanidm settling slowly, it's a stable byte-level mismatch between what the on-box script reads and what fleetwire reads via SSH, for a file that (per the local clan-config state dirs,vars/per-machine/gateway/kanidm-admins/idm_admin/secret, byte-identical betweenstate/clan-configandstate/clan-config.pre-flip) was never regenerated during this run.Suspected layer
internal/fleetwire/fleetwire.go:33-43—ExecRunner.Runusescmd.CombinedOutput(), merging the remote command's stdout AND stderr into the single string that becomes the password (enrolment.go:154,strings.TrimSpace(secret)). If the SSH remote shell ever writes anything to stderr on this command (a login/profile message, a transient stat race on the sops-nix symlink, etc.), it silently rides into the "secret" string as extra bytes — an exact-match password consumer (kanidm's/v1/authCred step,internal/kanidm/auth.go:78) would reject it outright, while the CA read on the same double-cat pattern (enrolment.go:135-138) would tolerate trailing garbage silently (x509.CertPool.AppendCertsFromPEMignores bytes outside the PEM block), which is consistent with the CA read never erroring in this run while only the password read fails.internal/fleetwire/*_test.gohas no test exercisingExecRunner/CombinedOutputat all — this path is untested against real stderr contamination. This is GOTCHAS #4's byte-disagreement class (docs/GOTCHAS.md:63-78) in a new shape: not a generator-side trailing newline, but a possible transport-side stderr splice.What plugging it needs
Not confident enough to land a fix blind on a security-sensitive auth path with no droplet left to reproduce against. A swarm worker should:
enrolment.go:140-154so the next red run shows whether the SSH-read secret differs in byte length from the generator file's known length (openssl rand -base64 24aftertr -d '\n'is a fixed 32 chars) — that alone would confirm or rule out contamination.ExecRunner.Run(fleetwire.go:33-43) to capture stdout and stderr separately for exact-match secret reads (keep combined output for error reporting), or add a length/format sanity check before use.GuestForwards.KanidmPort/SSH tunnel resolution possibly routing to a stale endpoint post-restart — worth ruling in/out with the same diagnostic pass.Unrelated to this signature but adjacent: #635 and #636 are both already-landed fixes for symptoms of this same failure family; this issue is the residual case neither actually resolves.
drive
20260821T224036Zred atactivation:activation faulted: founding: mint the credential-enrolment token at seeding: fleetwire: mint the credential-enrolment token: kanidm did not settle within 30 attempts: kanidm: auth: no token issued (devidence:
test-results/…/20260821T224036Z/on matou-workstation (legs.json, droplet-journal.txt, trace) — a representative screenshot is attached here if one was captured (#596)CONFIRMED (not just suspected) — stderr splice from #633's host-key rotation. Skip the diagnostic pass, land the stdout-only fix directly.
The reporter's
CombinedOutput()hypothesis is exactly right, and this run's own logs carry the contaminating bytes — no length/hash diagnostic pass (recommendation #1) is needed to confirm it. Root cause chain, fully evidenced fromtest-results/drive-selfhosted/20260821T224036Z:founding-state.log:300—"rotating the machine's pinned SSH host key across the takeover reboot before reconnecting over your own SSH key (#633)". #633 (just landed) rotates the box's SSH host key across the takeover.internal/fleetwire/carrier.go:17,104,130-143). After the rotation drops the stale pin, the first reconnect is accept-new against an unknown key.droplet-journal.txt:1—Warning: Permanently added '170.64.193.163' (ED25519) to the list of known hosts.— accept-new emits this to stderr.ExecRunner.Run(internal/fleetwire/fleetwire.go:38) usescmd.CombinedOutput()→ thatWarning:line is merged into the string returned byliveIDP'scat "$(cat /etc/idss/kanidm-idm-admin-path)"(enrolment.go:140-141), thenstrings.TrimSpace'd (:154) — so the password handed tokanidm.NewisWarning: Permanently added…\n<secret>, not<secret>.internal/kanidm/auth.go:78) →Denied - incorrect password× 30 → self-inflicted lockout. The on-boxkanidm-credential-floorreads the file with a localcat(no SSH, no warning) →Successat 22:48:13. The CA read rides the same double-cat butx509.CertPool.AppendCertsFromPEMignores the non-PEMWarning:line → tolerated. Both asymmetries the reporter flagged are explained by this single cause.This also explains why it survives #635/#636: neither touches transport.
#635's retry can't help (every attempt re-reads the same contaminated value);ddbc3d13's typed-denial is correct but the denial is real, not a settle race.Fix (land directly — safe regardless of this being the only cause)
A secret read must return the command's stdout only; stderr is diagnostics and must never reach a credential. Two-way door, correct on its own merits:
ExecRunner.Runto capture stdout as the success value and fold stderr into the error on non-zero exit (keep the honest failure output there). Audit the handful ofRuncallers (carrier.gohost-key learn returnsssh-keyscanstdout; supply/seed/idp all want stdout) — none rely on stderr in the success string.liveIDPidm_admin + the CA read) a stdout-only variant and leave the genericRuncombined.internal/fleetwire/*_test.gonever exercisesExecRunner/CombinedOutput): a unit test that a runner whose command writes aWarning:line to stderr yields a secret string with no stderr bytes. Guards the regression directly.Belt-and-braces worth considering (not required for green):
-o LogLevel=ERRORon the ssh args would suppress the "Permanently added" notice too — but the stdout/stderr split is the load-bearing fix; keep it primary.GOTCHAS #4 (byte-disagreement) in a new transport-side shape — worth a GOTCHAS entry in the fix commit. Left
ready-for-session— this is now a scoped, high-confidence code fix, not an investigation.Ruled by agent under ADR 0174 — veto anytime.
Ruling: land the code fix and the requested diagnostic now; this is a two-way door — a code change to
internal/fleetwire/fleetwire.goandenrolment.go, revertible by commit, provable by new tests, no credential/posture/trust-surface change.What I found:
ExecRunner.Run(fleetwire.go:33-43) usedcmd.CombinedOutput(), so a successful remote command's stderr rides silently into the returned string. For most callers (git-ish command output, error text) that's harmless, but two callers treat the return value as exact byte content:enrolment.go'sliveIDPhands it byte-for-byte to kanidm's/v1/authCred step as the idm_admin password. Confirmed this reproduces the exact failure class described in the ticket's evidence — wroteTestExecRunner_SeparatesStdoutFromStderrOnSuccessfirst (red): a command that writesclean-secretto stdout andnoiseto stderr while exiting 0 came back as"clean-secretnoise". That is a stable, unconditional corruption of any successful command that writes anything at all to stderr — matching the evidence's "not one attempt in an ~80s window succeeds" far better than a settling delay would.Fix:
ExecRunner.Runnow keeps stdout and stderr apart (cmd.Output()+ a dedicated stderr buffer) — a successful run returns stdout ONLY; a failing run's wrapped error still concatenates both, so diagnostics lose nothing.TestExecRunner_FailureStillSurfacesStderrproves the failure path is unchanged.Diagnostic (ticket's ask #1): added a redacted length-only log (ADR 0051 — never the secret bytes) around the idm_admin read in
liveIDP, loggingraw_bytes/trimmed_bytes. The generator writes a fixed 32-char secret, so a future red run's logs alone will confirm or rule out a splice —TestEnrolment_LiveIDPLogsSecretLengthNotSecretproves the fields land and the secret itself never does.What I did NOT do: run a live rehearsal drive to directly confirm this was THE cause of
20260821T224036Z's denial. This session (ready-for-session, session-runner) holds/tmp/matou-session-runner.lockfor its whole lifetime, and the standing self-hosted rehearsal'shost_capacity_acquire_exclusive(#577/ADR 0184) grabs the same lock non-blockingly — a prior #636 session found empirically that the standing drive structurally cannot be fired from inside a session like this one, and bypassing that guard to hand-drive one would defeat a deliberate host-contention protection on a shared box. So the live proof is the next cron-triggered rehearsal that reaches activation, not something this session can produce.Relationship to #640: #640 (open,
ready-for-human) is the deeper "does the on-box secret genuinely desync across the twoswitch-to-configurationapplies" question, deferred by #636. This ticket's fix is a different, independent mechanism (fleetwire's own transport layer, not kanidm/sops materialization) — if the next rehearsal greens past activation, that's evidence for the transport-splice explanation over #640's materialization-divergence one; if it still reds at this exact signature even with this fix, #640 is where that narrower live-droplet forensic belongs (not a new ticket).Close-report
Landed:
bd353b34onmain— "sandcastle: #641 — fleetwire: idm_admin secret read no longer swallows stderr into the exact-match password".STATUS.mdupdated in the same commit.What landed (ticket's "What plugging it needs" items 1 and 2):
raw_bytes/trimmed_bytes, ADR 0051 — never the secret) around the idm_admin secret read inenrolment.go'sliveIDP.ExecRunner.Run(fleetwire.go) now captures stdout and stderr separately: a successful command returns stdout ONLY (previouslycmd.CombinedOutput()merged both), while a failing command's wrapped error still carries both concatenated, so failure diagnostics are unchanged.Proof:
TestExecRunner_SeparatesStdoutFromStderrOnSuccess— confirmed RED first: a command writingclean-secretto stdout andnoiseto stderr while exiting 0 came back as"clean-secretnoise"under the oldCombinedOutput()implementation, reproducing exactly the byte-splice class the ticket's suspected-layer analysis named. Green after the fix.TestExecRunner_FailureStillSurfacesStderr— the failure path still surfaces stderr text for diagnosis.TestEnrolment_LiveIDPLogsSecretLengthNotSecret— the new diagnostic logs the length fields and never the secret itself.go build ./...,go vet ./...,go test ./...— no regressions across the repo.Item 3 (own-VPS forwards alternate theory): not pursued — it was scoped as "if NOT contamination," and the reproducing test confirms this IS the contamination class.
Not done — and why that's still an honest close: did not run a live rehearsal to directly confirm this was THE cause of
20260821T224036Z's specific denial. Thisready-for-sessionsession holds/tmp/matou-session-runner.lockfor its lifetime, and the standing self-hosted rehearsal's host-capacity guard (#577/ADR 0184) grabs the same lock non-blockingly — a prior #636 session confirmed empirically that the standing drive cannot be fired from inside a session like this one, and hand-driving one to bypass that guard would defeat a deliberate host-contention protection on a shared box. So the live proof is the next cron-triggered rehearsal reaching activation, mirroring the #635/#636 precedent (ship a test-proven hardening, watch the next rehearsal, rather than block indefinitely on a live drive this session structurally cannot produce).Ruling and full technical detail already posted above under ADR 0174. Closing.