sshkey: a degraded entropy source mints a corrupt key and reports success #287

Closed
opened 2026-08-05 23:10:17 +00:00 by ben · 3 comments
Owner

internal/sshkey/sshkey.go:101 — _, _ = io.ReadFull(random, check). A failed/short read yields zeroed check-ints in the openssh-key-v1 blob, written 0600 and reported as a successful mint; the helper then bakes the public half into the guest's boot config as trusted.

Acceptance

  • The ReadFull error propagates and no key file is written on failure.
  • Test with a failing reader.

Filed from the 2026-08-05 fail-loud audit (three-agent pre-production sweep; findings verified against code).

`internal/sshkey/sshkey.go:101` — `_, _ = io.ReadFull(random, check)`. A failed/short read yields zeroed check-ints in the openssh-key-v1 blob, written 0600 and reported as a successful mint; the helper then bakes the public half into the guest's boot config as trusted. **Acceptance** - The `ReadFull` error propagates and no key file is written on failure. - Test with a failing reader. --- _Filed from the 2026-08-05 fail-loud audit (three-agent pre-production sweep; findings verified against code)._
Author
Owner

Blocked — the code this issue targets does not exist in the repository.

I attempted to fix internal/sshkey/sshkey.go:101 (_, _ = io.ReadFull(random, check)) and found:

  • There is no internal/sshkey package — not in the current worktree, not on origin/main, and not anywhere in git history (git log --all --diff-filter=A -- 'internal/sshkey/**' is empty). internal/ contains no sshkey directory.
  • There is no sshkey.Ensure minter (grep 'func Ensure' across the repo returns nothing), despite sibling issue #281 describing it as "already used by the helper".
  • There is no openssh-key-v1 marshaller and no swallowed io.ReadFull (_, _ = io.ReadFull) anywhere in the tree.
  • Every SSHHostKey in the codebase is still a raw literal placeholder: agent/cmd/agent/main.go:231,290 ("skeleton-ssh-host-key"), internal/founding/standuprented.go:122 ("rented-gateway-ssh-host-key"), internal/founding/privatepath.go:199 ("private-gateway-vm-ssh-host-key").

This issue (and #281/#282, which reference the same non-existent sshkey.Ensure and a mintPrivateVMKey at privatepath.go:164 that is also absent) appears to have been filed by the 2026-08-05 audit against a codebase state that includes an internal/sshkey package that never landed on this branch. The acceptance ("the ReadFull error propagates and no key file is written on failure") presupposes an existing mint routine there is nothing to amend.

To re-arm, a human must decide:

  1. Land the prerequisite that introduces internal/sshkey (the real host-key minter with Ensure), then re-add ready-for-agent here — this fix is a one-line error-propagation on top of that; or
  2. Re-scope this issue to create the fail-loud sshkey minter from scratch (a new surface, overlapping #281/#282's wiring), if that is the intended deliverable.

I did not create the package, as that would invent a surface this bug-fix issue does not define and overlap the sibling issues' scope. No code changed.

**Blocked — the code this issue targets does not exist in the repository.** I attempted to fix `internal/sshkey/sshkey.go:101` (`_, _ = io.ReadFull(random, check)`) and found: - There is **no `internal/sshkey` package** — not in the current worktree, not on `origin/main`, and not anywhere in git history (`git log --all --diff-filter=A -- 'internal/sshkey/**'` is empty). `internal/` contains no `sshkey` directory. - There is **no `sshkey.Ensure` minter** (`grep 'func Ensure'` across the repo returns nothing), despite sibling issue #281 describing it as "already used by the helper". - There is **no openssh-key-v1 marshaller** and **no swallowed `io.ReadFull`** (`_, _ = io.ReadFull`) anywhere in the tree. - Every `SSHHostKey` in the codebase is still a raw literal placeholder: `agent/cmd/agent/main.go:231,290` (`"skeleton-ssh-host-key"`), `internal/founding/standuprented.go:122` (`"rented-gateway-ssh-host-key"`), `internal/founding/privatepath.go:199` (`"private-gateway-vm-ssh-host-key"`). This issue (and #281/#282, which reference the same non-existent `sshkey.Ensure` and a `mintPrivateVMKey` at `privatepath.go:164` that is also absent) appears to have been filed by the 2026-08-05 audit against a codebase state that includes an `internal/sshkey` package that never landed on this branch. The acceptance ("the `ReadFull` error propagates and no key file is written on failure") presupposes an existing mint routine there is nothing to amend. **To re-arm, a human must decide:** 1. Land the prerequisite that introduces `internal/sshkey` (the real host-key minter with `Ensure`), then re-add `ready-for-agent` here — this fix is a one-line error-propagation on top of that; **or** 2. Re-scope this issue to *create* the fail-loud `sshkey` minter from scratch (a new surface, overlapping #281/#282's wiring), if that is the intended deliverable. I did not create the package, as that would invent a surface this bug-fix issue does not define and overlap the sibling issues' scope. No code changed.
Author
Owner

Ben ruled (2026-08-06, ready-for-human sweep): fix as specced — propagate the ReadFull error, no key file written on failure, failing-reader test. Flipped ready-for-agent for the swarm.

Ben ruled (2026-08-06, ready-for-human sweep): fix as specced — propagate the `ReadFull` error, no key file written on failure, failing-reader test. Flipped `ready-for-agent` for the swarm.
Author
Owner

Fixed in 39a149d (pushed to origin/main).

The internal/sshkey package landed via #281 in ed25519 form (raw private key, no openssh-key-v1 check-ints), so the literal io.ReadFull(random, check) line the audit cited no longer exists — but the underlying hazard (a degraded entropy source minting a corrupt key and reporting success) applies to the seed read inside ed25519.GenerateKey. Fixed as Ben ruled:

  • Entropy source is now a seam: generateFrom(path, random io.Reader); generate passes rand.Reader.
  • ed25519.GenerateKey reads the seed via io.ReadFull, so a short/failed read surfaces the error BEFORE MkdirAll/WriteFile — the error propagates and no key file is written on failure.
  • TestEnsureFailsLoudOnDeadEntropy drives a failingReader and asserts the loud error plus os.IsNotExist on the key path.

Evidence: internal/sshkey/sshkey.go, internal/sshkey/sshkey_test.go; go test ./internal/sshkey/ green, full pre-push gate green.

Fixed in 39a149d (pushed to origin/main). The `internal/sshkey` package landed via #281 in ed25519 form (raw private key, no openssh-key-v1 check-ints), so the literal `io.ReadFull(random, check)` line the audit cited no longer exists — but the underlying hazard (a degraded entropy source minting a corrupt key and reporting success) applies to the seed read inside `ed25519.GenerateKey`. Fixed as Ben ruled: - Entropy source is now a seam: `generateFrom(path, random io.Reader)`; `generate` passes `rand.Reader`. - `ed25519.GenerateKey` reads the seed via `io.ReadFull`, so a short/failed read surfaces the error BEFORE `MkdirAll`/`WriteFile` — the error propagates and no key file is written on failure. - `TestEnsureFailsLoudOnDeadEntropy` drives a `failingReader` and asserts the loud error plus `os.IsNotExist` on the key path. Evidence: `internal/sshkey/sshkey.go`, `internal/sshkey/sshkey_test.go`; `go test ./internal/sshkey/` green, full pre-push gate green.
ben closed this issue 2026-08-06 19:37:50 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Matou/idss#287
No description provided.