Skip to content

fix(stack): gate init --force backend-switch destroy on live-services confirmation#773

Merged
bussyjd merged 1 commit into
integration/v0.14.0-rc0from
fix/stack-init-guard
Jul 16, 2026
Merged

fix(stack): gate init --force backend-switch destroy on live-services confirmation#773
bussyjd merged 1 commit into
integration/v0.14.0-rc0from
fix/stack-init-guard

Conversation

@bussyjd

@bussyjd bussyjd commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Full-surface audit finding (CRITICAL): obol stack init --force destroys a live cluster with no confirmation

Found by the 2026-07-16 whole-product-surface audit (PR #770), adversarially confirmed. internal/stack/stack.go Init() calls destroyOldBackendIfSwitchingoldBackend.Destroy() before validating the new backend, and with no ConfirmRunningServicesLoss gate — unlike Down()/Purge(), which added exactly that gate after the 2026-05-22 cross-stack outage (see the comment at stack.go:266). So obol stack init --force --backend k3s against a host running a live k3d stack (stale OBOL_BACKEND, or a muscle-memory re-run) tears down the running cluster — containers, PVCs, agent wallets, registered offers — and if the new backend then fails Prerequisites (k3s is Linux+sudo-only), leaves nothing running with a bare error.

Fix

  1. Reorder: validate the target backend (NewBackend + Prerequisites) before the destroy, so an invalid/unavailable backend aborts with nothing destroyed.
  2. Gate: the backend-switch destroy now goes through ConfirmRunningServicesLoss (new --yes/skipConfirm threaded from the CLI, mirroring purge). Live services + non-TTY + no --yes → refuse; TTY → prompt.

Test: Init with live services, non-TTY, no --yes returns an error and never calls Destroy. go test ./internal/stack/... ./cmd/obol/... green.

https://claude.ai/code/session_014YjPMViNrZ7zBVgUQzwEKk

…ces confirm

Root cause: Init() destroyed the old backend's cluster (destroyOldBackendIfSwitching) unconditionally on --force, then only afterward validated the new backend via NewBackend/Prerequisites — either of which can fail, leaving the old cluster destroyed with nothing running. Unlike Down()/Purge(), this path had no ConfirmRunningServicesLoss gate, so a live-traffic-serving stack could be silently wiped by 'stack init --force --backend <X>'.

Fix: (1) reorder Init() so NewBackend + backend.Prerequisites run before destroyOldBackendIfSwitching, so an invalid/unavailable target backend aborts before anything is destroyed. (2) thread a skipConfirm (--yes) bool through Init and gate the destroy on ConfirmRunningServicesLoss, mirroring Down/Purge; non-interactive callers without --yes now fail closed instead of destroying. CLI wiring in cmd/obol/main.go adds --yes/-y to 'stack init', matching purge's flag. bootstrap.go's internal (force=false) call passes skipConfirm=false, a no-op since force=false never reaches the destroy path.

Confirmed Canary402 full-surface audit finding.

Claude-Session: https://claude.ai/code/session_014YjPMViNrZ7zBVgUQzwEKk
@bussyjd bussyjd merged commit 5eafb5e into integration/v0.14.0-rc0 Jul 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant