magnetite: confine the builder account's key to the nix protocol - #2887
Merged
Conversation
|
Tick the box to add this pull request to the merge queue (same as
|
The nix-remote-build key that stibnite holds authorized an unrestricted shell on magnetite's builder account, which is a nix trusted user on a host whose sshd accepts connections from the public internet. Wrap that key with restrict and a forced nix-daemon --stdio command, so it can start only the protocol its single consumer speaks: the ssh-ng buildMachines entry in modules/system/magnetite-builder.nix, which authenticates with the matching private half at config.clan.core.vars.generators.nix-remote-build.files.key.path. The forced command interpolates config.nix.package rather than a bare program name so it resolves to the nix deployed on magnetite, and the account keeps its default bash shell because sshd runs the forced command through it. Drop crs58's personal keys from the same account. They authorize the wheel account fleet-wide through modules/system/admins.nix, where wheel also has passwordless sudo, so sudo -u builder still reaches the account for debugging and no access is lost. The builder entry in nix.settings.trusted-users is deliberately unchanged; removing it depends on per-machine store signing, which is tracked separately. Verified by evaluation, which renders the key list as a single entry carrying restrict, the store path of the deployed nix, and no personal keys. Ran the treefmt, structure-nixos-configurations and deployment-safety checks. No deployment was performed, so the live remote build path is untested.
cameronraysmith
force-pushed
the
fm/vx-magnetite-builder-key-restriction
branch
from
September 1, 2026 04:35
a1bdea6 to
d3b3b64
Compare
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.
What changes
Magnetite's
builderaccount, inmodules/machines/nixos/magnetite/default.nix, receives two edits.The
nix-remote-buildpublic key held by stibnite is now wrapped withrestrictand a forcednix-daemon --stdiocommand, following the construction inmodules/system/stibnite-access.nixon thefm/vx-stibnite-darwin-builderbranch, which does the same for the opposite direction of this builder pair. The forced command interpolatesconfig.nix.packagerather than a bare program name, so it resolves to the nix actually deployed on magnetite, and the account keeps its default bash shell because sshd runs a forced command through the account's login shell.The second edit removes
inputs.self.users.crs58.meta.sshKeysfrom the same account, leaving the machine key as its only entry.Why
Before this change the key authorized an unrestricted shell on an account that is a nix trusted user, on a host whose sshd accepts connections from the public internet (
networking.firewall.allowedTCPPortsincludes 22). The private half of that key is a file deployed on a second machine, so the credential's reach was wider than the one protocol it exists to serve.Removing the personal keys costs no access. The only automated consumer of the account authenticates with the machine key:
modules/system/magnetite-builder.nix:69setssshKeyto thenix-remote-buildgenerator's key path, and:99-100writes an ssh config block pinning thatUserandIdentityFile. Interactive access is independent, throughmodules/system/admins.nix, where crs58 is inwheelwith those same keys, root inherits keys from every wheel user, and wheel has passwordless sudo, sosudo -u builderstill reaches the account when debugging needs it.What the forced command does not bound
It restricts which program the key can start. It does not restrict that program's authority. The account remains in
nix.settings.trusted-users, which is deliberately unchanged here: removing it requires per-machine store signing, because an untrusted build account rejects unsigned caller-evaluated store paths. That migration is tracked separately asvx-nix-store-signing-untrust-builders, and folding it into a one-line confinement would couple two changes with unrelated failure modes.Verification, and its ceiling
Evaluation of magnetite's host configuration renders the account's key list as exactly one entry:
restrictand the forced command are present, the command names a store path rather than a bare program, and the personal keys are gone. Two supporting evaluations confirm the surrounding assumptions: the account's shell isbash-interactive, so it can execute the forced command, and crs58's own account still carries both of his keys.Three flake checks were run and pass:
treefmt, which covers formatting of the edited file;structure-nixos-configurations, which evaluates the NixOS configurations including magnetite; anddeployment-safety. The rest of the check set was left out because nothing else evaluates this file, and the rendered value above is the direct evidence for what changed.Evaluation is the ceiling of what this branch demonstrates. It shows that magnetite will be configured with the intended
authorized_keysentry. It does not show that a remote build over the confined key succeeds, because that requires deploying to the live host, which this branch does not do. A forced command breaks any use of the key other than the nix protocol; the only configured use is thessh-ngbuildMachinesentry above, and a search fornix-remote-buildacross the repository finds no other consumer, but the first deployment is where that holds or does not.