Skip to content

fix(security): force rotation of seeded root password at first login - #242

Closed
mendezr wants to merge 1 commit into
projectbluefin:mainfrom
mendezr:sec/root-password-first-login-rotation
Closed

mendezr wants to merge 1 commit into
projectbluefin:mainfrom
mendezr:sec/root-password-first-login-rotation

Conversation

@mendezr

@mendezr mendezr commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

Summary

Follow-up to the sshd hardening merged in #169, closing the remaining gap from #168: the shipped DDI still seeded the well-known root password ('bluefin', hash public in this repository) with shadow last-change 19700 — a fixed date, so the credential never expired, was identical in every image, and no rotation was ever enforced at console login.

This PR sets the shadow last-change field to 0 — the chage -d 0 root equivalent — so every login as root (console included) is forced onto a per-install password before any shell is granted. The well-known default is then only ever a one-time bootstrap credential, unusable until rotated.

Changes

What this intentionally does not do

The long-term removal of the baked root password entirely (core operator account, key-only access via systemd credentials) is the larger redesign tracked by #80. This is the issue's requested interim hardening (recommendation item 2: force password rotation at first login); console bring-up via root / bluefin still works and is now rotated per install.

Verification

  • python3 -m pytest tests/unit — 336 passed, 1 xfailed (includes the new contract tests)
  • python3 .github/scripts/docs-checks.py — passed
  • just validate — version checks pass; bst show steps require the FSDK bst2 container (sudo/podman unavailable in this environment), element graph covered by the unit suite which YAML-parses the changed element

Fixes: #168

— hive: backend=pi model=openrouter/z-ai/glm-5.3-flash

🐝 Hive Agent: contributor | SHA: 6888c2f

The DDI seeds a well-known root password ('bluefin', hash public in this
repo) into every shipped image with shadow last-change 19700, so the
credential never expires and is identical fleet-wide. PR projectbluefin#169 already
restored the sshd drop-in hardening (PermitRootLogin prohibit-password,
PasswordAuthentication no), which closes the remote root path; the
remaining gap from projectbluefin#168 is that console bring-up never forces rotation.

Set the shadow last-change field to 0 (the `chage -d 0 root` equivalent):
every login as root — console included — is forced onto a per-install
password before any shell is granted. Update the console banner to
disclose the forced change, and add a unit contract locking in both the
rotation and the SSH no-password-auth policy as a regression guard.

The long-term removal of the baked password (core operator account,
systemd-credentials key provisioning) is tracked by projectbluefin#80; this is the
minimal interim hardening requested by the issue.

Fixes: projectbluefin#168

Hive-Run: projectbluefin#168
Hive-Plan: Security remediation — interim hardening of seeded root credential (issue projectbluefin#168, recommendation item 2)
Hive-Spec: docs/superpowers/specs/2026-09-09-core-login-design.md#interim-shadow-expiry
Assisted-by: GLM (z-ai/glm-5.3-flash) via GitHub Copilot
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: mendezr <mendezr@users.noreply.github.com>

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change does what it says for the console path; I have one open question about the key-based SSH path that a human should test before this lands.

Verified:

  • elements/oci/bluefin-server-ddi.bst:86 sets shadow field 3 (lastchg) to 0. Per shadow(5), 0 means "must change at next login", and pam_unix account returns PAM_NEW_AUTHTOK_REQD for it — so console login forces passwd before a shell, as described.
  • The DDI currently boots rw (docs/skills/architecture-roadmap.md:26, "DDI is currently booted rw"), so passwd can persist the new hash to /etc/shadow; this is not a lockout.
  • files/os/ssh/sshd_config.d/bluefin-server.conf:8-11 has exactly the three directives the new test asserts.
  • Test regex at tests/unit/test_root_credential_contract.py:26 matches the printf 'root:…' line and the field-count check is correct for the 9-field line.

Open question — key-based root SSH after this change. sshd with UsePAM yes (the Flatcar default; this repo's drop-in doesn't override it) runs pam_acct_mgmt for pubkey logins too. When PAM reports PAM_NEW_AUTHTOK_REQD, OpenSSH forces a password change on interactive sessions and, for sessions without a TTY, aborts with Password change required but no TTY available. If that holds here, then until someone rotates the password on the local console:

  • ssh -i key root@host <command> (non-interactive) fails outright;
  • interactive key-based root sessions are made to set a password first.

That would undercut the drop-in's intent (PermitRootLogin prohibit-password — key-based root access should work; only passwords are refused) and break unattended provisioning that ssh's in as root with a key. I could not boot an image to confirm, so I'm not calling it a defect. Question for a maintainer: after a fresh install with an injected authorized_keys, does ssh -i <key> root@<host> true succeed before anyone has logged in on the console? If not, an alternative that keeps the console behaviour without touching the PAM account result is worth considering (e.g. a first-boot unit that runs passwd -e root only when no key was injected), or scoping the expiry so sshd's pam_acct_mgmt isn't affected.

Smaller open question: root is on an A/B partition (files/installer/repart.d/20-root-a.conf) with /var as the only separate mount (bluefin-server-ddi.bst:74). If a future root-image update replaces /etc/shadow, the rotation becomes per-update rather than per-install. Pre-existing, but the new comment and banner promise "per-install", so worth a word.

Confidence: 3/5 (needs attention) — 1 medium finding; 1 perspective requires a human decision

— hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive

Copy link
Copy Markdown
Contributor

Hive filed out-of-scope review findings as backlog issues so they do not block this PR:

Cap: 3 backlog issue(s) per PR.

@hanthor hanthor left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks fully superseded by #243: main already has lastchange 0 at elements/oci/bluefin-server-ddi.bst:88, the "(password change forced at first login)" banner text, and tests/unit/test_root_credential_contract.py. I think this can be closed; nothing is left to merge. Thanks for the fix, it landed.

@castrojo

Copy link
Copy Markdown
Contributor

Closing as superseded: all changes from this PR (setting shadow last-change field to 0 for forced rotation, console banner note, and test_root_credential_contract.py) were incorporated into #243 and landed on main in commit b81de1a.

@castrojo castrojo closed this Sep 26, 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.

[sec-check] Default root password 'bluefin' + PermitRootLogin yes — remote root once sshd is enabled

3 participants