Skip to content

fix(enroll): seventh audit — atomic pw write, grep trap, key validation, CV promotion guard#179

Merged
mdheller merged 1 commit into
mainfrom
fix/enroll-seventh-audit
Jun 16, 2026
Merged

fix(enroll): seventh audit — atomic pw write, grep trap, key validation, CV promotion guard#179
mdheller merged 1 commit into
mainfrom
fix/enroll-seventh-audit

Conversation

@mdheller

Copy link
Copy Markdown
Member

Findings and fixes

# Finding Severity Fix
1 echo > KATELLO_ADMIN_PW_FILE non-atomic — interrupted write leaves empty file, password unrecoverable except from .env Medium printf > .tmp && mv
2 Two surviving docker compose (v2) occurrences in die/warn messages missed by audit #6 Low Align to docker-compose
3 grep -v in SIGNING_PUBKEY extraction exits 1 on pathological pub file → set -e fires before the empty guard can print a diagnostic Medium `
4 No [[ -s KEY && -s PUB ]] validation after nix-store --generate-binary-cache-key Medium Size check immediately after generation
5 No [[ -s SIG ]] after minisign -S — some versions exit 0 on failure Low [[ -s "${MINISIGN_CACHE_INFO_SIG}" ]] after signing
6 minisign -S || die message blames passphrase for any failure (corrupt key, perms, disk full) Low Expanded diagnostic listing all likely causes
7 CV promotion docker exec failure masked as "Already at env" — 2>/dev/null on stopped container looks like success Medium Container liveness check before hammer calls
8 for env in candidate stableenv is a common variable/command name; shadowing risk with set -u Low Renamed to _promote_env

Test plan

  • bash -n scripts/enroll.sh — no syntax errors
  • Kill script mid-KATELLO_ADMIN_PW_FILE write → re-run regenerates file
  • Create a minisign pubkey with only the comment line → script exits with clear diagnostic (not set -e silent abort)
  • After nix-store --generate-binary-cache-key, zero out HARMONIA_KEY → [[ -s ]] guard fires
  • Stop katello-foreman container before step 11 → CV promotion block warns and continues rather than printing false "Already at"
  • Full physical M2 enroll run (P0 test)

…on, CV promotion guard

- Atomic KATELLO_ADMIN_PW_FILE write: printf > .tmp then mv; interrupted
  write previously left an empty file with no recovery path (password
  only recoverable from .env manually)

- Fix two remaining `docker compose` (v2) occurrences in die/warn messages
  that audit #6 missed: container count die and Foreman timeout warn block

- Guard SIGNING_PUBKEY grep against pipefail abort: `grep -v` exits 1
  when every line matches the invert pattern; with set -o pipefail this
  fires set -e before the empty guard can print a diagnostic message;
  add `|| true` within the $() so the guard always runs

- Validate nix-store key file sizes after generation: `[[ -s KEY && -s PUB ]]`
  immediately after nix-store --generate-binary-cache-key; a zero-byte
  secret key would cause harmonia to start but fail all signing silently

- Validate minisign .minisig is non-empty after signing: `[[ -s SIG ]]`
  after minisign -S; some minisign versions exit 0 on edge-case failures

- Broaden minisign -S die message: previously blamed only passphrase;
  now lists corrupt key, unreadable permissions, and disk-full as causes

- CV promotion container liveness check: `docker ps --filter name=katello-foreman`
  before hammer calls; a stopped container caused docker exec to silently
  fail (2>/dev/null) and || branch to print "Already at env" — looked like
  success but promotion was silently skipped

- Rename `env` loop variable to `_promote_env`: avoids collision with the
  common `env` command/variable name in the for-loop scope
@mdheller mdheller merged commit 70e5bf5 into main Jun 16, 2026
@mdheller mdheller deleted the fix/enroll-seventh-audit branch June 16, 2026 19:00
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