forkidentity: drop a per-fork identity record into every fork#217
Draft
sjmiller609 wants to merge 1 commit intomainfrom
Draft
forkidentity: drop a per-fork identity record into every fork#217sjmiller609 wants to merge 1 commit intomainfrom
sjmiller609 wants to merge 1 commit intomainfrom
Conversation
When N forks come up off the same restored memory snapshot they share /dev/urandom state, machine-id, hostname, and clock — which silently breaks crypto and makes fan-out forks indistinguishable. This change adds lib/forkidentity, a small package that produces a fresh per-fork record (256 bytes of crypto-rand entropy plus a small forward clock jitter) and atomically writes it as fork-identity.json into the fork's data directory. forkInstanceFromStoppedOrStandby now calls it on every fork before metadata save. The hypervisor side never touches guest state. A future guest-agent change reads this file at boot and applies it: reseeds /dev/urandom, refreshes machine-id, and steps the clock by ClockOffsetNs. Failure to build/write the record is fatal because identity reuse is a security regression, not a soft warning. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
lib/forkidentitypackage:Build(forkID)produces an identity with 256 bytes of crypto-rand entropy + a small forward clock jitter;Write(dir, id)atomically writesfork-identity.jsoninto the fork's data directory;Read(dir)loads it.writeForkIdentityintoforkInstanceFromStoppedOrStandbyso every fork drops a fresh record before metadata save.Why
When N forks come up off the same restored memory snapshot they share
/dev/urandomstate, machine-id, hostname, and clock. That silently breaks crypto (TLS keys, JWTs) and makes fan-out forks indistinguishable to operators. Hypeman can't safely rewrite guest state directly, but it can plant a small record that a guest agent (separate work) reads at boot to reseed/dev/urandom, refresh machine-id, and step the clock byClockOffsetNs.Test plan
go test ./lib/forkidentity/...go test ./lib/instances/... -run "TestForkInstance|TestValidateFork|TestForkRequest"<fork>/fork-identity.jsonexists, hasversion: 1, has 256-byteentropy_seed, and a smallclock_offset_ns🤖 Generated with Claude Code