Skip to content

fix: generate console JWT secret at first boot, not in git - #240

Closed
hivecommons-hive[bot] wants to merge 1 commit into
mainfrom
sec/fix-console-jwt-secret
Closed

hivecommons-hive[bot] wants to merge 1 commit into
mainfrom
sec/fix-console-jwt-secret

Conversation

@hivecommons-hive

Copy link
Copy Markdown
Contributor

Security Fix

files/k0s/manifests/kubestellar/01-kubestellar-console-github-oauth.yaml committed a usable jwt-secret (default-jwt-secret-123456789012345678901234). The console consumes it as JWT_SECRET with optional: false, so every default install signs session tokens with a key published in this repository — anyone can forge valid console sessions.

What this changes

  • 01-kubestellar-console-github-oauth.yaml now creates only the kubestellar-console namespace; the Secret is no longer committed.
  • New files/k0s/kubeflex/generate-console-secret.sh (mirrors the kubeflex-postgres pattern from [sec-check] kubestellar postgres StatefulSet hardcodes superuser password 'kubeflex' as plaintext env, auto-applied by default #98): at first boot it writes /var/lib/k0s/manifests/kubestellar/02-kubestellar-console-secret.yaml with a random 256-bit hex jwt-secret and empty OAuth keys (the console reads client-id/client-secret with optional: true). Idempotent, mode 0600, sorts before 40-kubestellar-console.yaml.
  • k0s-first-boot.service runs the generator after the postgres one, before k0scontroller starts.
  • elements/oci/k0s-sysext.bst chmods the new script alongside the postgres generator.
  • tests/unit/test_k0s_manifests.py: executed coverage — no kind: Secret/jwt-secret in the committed manifest, generator ordering in the unit, and an idempotency run asserting the 64-hex secret, 0600 mode, and stable re-run output.

Upgrade behavior

Existing installs rotate naturally: tmpfiles C+ replaces the stale 01- copy (dropping the published Secret from the stack) and the generator creates the 02- file fresh, invalidating tokens forged with the public value. Operators enabling GitHub OAuth edit the generated Secret in place.

Validation

python3 -m pytest tests/unit -q — 335 passed, 1 xfailed.

Closes #72 (merging leaves nothing for the issue to track: the usable secret is gone from git and rotation of previously deployed values happens on upgrade)


Filed by sec-check agent (ACMM L4/L5 — hold-gated mode). Hold-gated: human review required.

— hive: agent=sec-check backend=copilot model=claude-fable-5 copilot=1.0.88

The kubestellar-console-github-oauth Secret committed a usable jwt-secret
(default-jwt-secret-123456789012345678901234). JWT_SECRET signs console
session tokens, so a value published in git lets anyone forge valid
sessions on every default install.

Mirror the kubeflex-postgres pattern (#98): the committed 01- manifest now
creates only the namespace, and a first-boot generator writes
02-kubestellar-console-secret.yaml with a random 256-bit jwt-secret and
empty OAuth credentials (consumed with optional: true). Idempotent, 0600,
runs from k0s-first-boot.service before k0scontroller starts.

Existing installs rotate on upgrade: tmpfiles C+ replaces the stale 01-
copy (dropping the published Secret) and the generator creates the 02-
file fresh, invalidating any tokens forged with the public value.

Closes #72

Assisted-by: Claude Fable 5 via GitHub Copilot
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: sec-check[bot] <sec-check[bot]@users.noreply.github.com>
@hivecommons-hive hivecommons-hive Bot added the hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 23, 2026
@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

Important

Held for human review by the hive's ACMM level gate.

This PR was opened by the "sec-check" agent while Hive policy required a human checkpoint for that agent. Non-outreach agents are held at ACMM L3–L5; the outreach agent is always held because it publishes project-facing communication.

Hive will automatically remove the hold label once current policy no longer requires a level hold for "sec-check". If this is an outreach PR, a human must review it and remove the label.

@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

CI status: failure is a main baseline breakage, not this diff

installer-test / Install and boot in QEMU on this PR (run 35924346527) fails with k0s=inactive for the whole 900s readiness window plus oem.mount dependency failures.

main @ a0f65026 — this branch's exact merge-base, without this diff — fails the same job with the byte-identical signature: run 35917446585. Last green main verdict was dc48bfb7 (2026-09-22), before the Flatcar payload wave (#132/#140/#136 et al.) merged on 2026-09-23.

Details and regression window documented on #226 (comment of 2026-09-24T01:51Z). The Unit tests job — which exercises everything this PR adds (test_console_jwt_secret_not_hardcoded, test_k0s_first_boot_generates_console_secret_before_k0s, test_generate_console_secret_is_idempotent) — is green on this head (run 35924345435).

No push made: the branch is already cut from the newest main, and a re-run cannot go green until the baseline is fixed. Once main's installer-test is repaired, re-running this PR's Build DDI artifacts should suffice.

🐝 Hive Agent: security | Instance: hosted-projectbluefin-knuckle-gjvq | SHA: unknown

— hive: agent=sec-check backend=copilot model=claude-fable-5 copilot=1.0.88

@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

Baseline failure root-caused — fix is #241

The installer-test / Install and boot in QEMU failure on this PR is the main baseline regression tracked in #226, now root-caused: Flatcar's /usr ships 99-default.preset (disable *), and systemd applies presets in lexicographic filename order with first-match-wins — so every zz-enable-*.preset (including zz-enable-k0s-first-boot.preset) sorted after it and was ignored. k0s-first-boot.service was never enabled; k0s stayed inactive for the full 900s window.

#241 renames the presets to 20-bluefin-*.preset so they sort before the catch-all. Once it merges, this PR needs only a CI re-run — the diff here is not at fault (identical signature on main @ a0f65026, run 35917446585).

🐝 Hive Agent: security | Instance: hosted-projectbluefin-knuckle-gjvq | SHA: unknown

— hive: agent=sec-check backend=copilot model=claude-fable-5 copilot=1.0.88

@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

The failing installer-test / Install and boot in QEMU here shows the exact main-baseline signature: k0s=inactive for the whole 900s window (run 35924346527), identical to main's own red run 35917446585. Root cause is the Flatcar payload switch defeating the zz-enable-*.preset files — fixed by #241, not by anything in this diff. unit and build are green here.

No push needed on this branch: once #241 lands, this PR needs only a re-run of installer-test (per CI-retrigger policy, gh run rerun --failed, no retrigger commits).

🐝 Hive Agent: security | Instance: hosted-projectbluefin-knuckle-gjvq | SHA: unknown

— hive: agent=sec-check backend=copilot model=claude-fable-5 copilot=1.0.88

@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

Triage for the red installer-test here: this branch inherits main's baseline regression, not a defect in this change.

Plan: land #241 first (plus whatever its diagnostics surface), then rebase/rerun this PR — no changes needed here. Not pushing empty commits to retrigger.

🐝 Hive Agent: security | Instance: hosted-projectbluefin-knuckle-gjvq | SHA: unknown

— hive: agent=sec-check backend=copilot model=claude-fable-5 copilot=1.0.88

@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

CI status: this PR's installer-test failure is the main-baseline breakage tracked by #226, not this diff. Unit tests are green here.

Fix chain lives in #241: the zz-enable-* → 20-bluefin-* preset rename (k0s never enabled) plus f1a52e5 seeding the /etc/resolv.conf symlink via tmpfiles.d (kubelet failed every pod sandbox without it). Once #241 lands on main, this PR needs only a rebase/re-run — no code change expected here.

🐝 Hive Agent: security | Instance: hosted-projectbluefin-knuckle-gjvq | SHA: f1a52e5

— hive: agent=sec-check backend=copilot model=claude-fable-5 copilot=1.0.88

@hivecommons-hive hivecommons-hive Bot removed the hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 25, 2026
@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

Superseded: the entire diff of this PR (generate-console-secret.sh, k0s-first-boot.service hook, k0s-sysext.bst chmod, manifest change, and tests/unit/test_k0s_manifests.py) landed on main verbatim in #243 (b81de1a) — git diff main..sec/fix-console-jwt-secret is empty. Issue #72 is closed. The installer-test failure here was a pre-existing main regression (same kiosk-ready: waiting k0s=inactive symptom on main runs 35917446585 / 36002667748, last green dc48bfb), not introduced by this branch. Closing rather than rebasing an empty PR.

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.

[sec-check] kubestellar console ships hardcoded JWT secret + dummy GitHub OAuth credentials, auto-applied by default

0 participants