Repository navigation
fix(admission): Keep Machine power to the power projector - #224
Conversation
Nothing but convention stopped another identity from writing a Machine's status.power. In Milo, a status write is authorized with the Machine's update and patch permissions, which the consumer roles hold, and the manager's other status writers share the projector's identity, so RBAC cannot hold the field to one writer. Add a fail-closed webhook, served by fleet-registration, that admits a change to status.power only from the identity named by its new --machine-power-writer flag; unset, every power change is refused. Only status writes that change power are routed. config/milo installs it, and config/standalone enforces the same rule with a ValidatingAdmissionPolicy admitting only the smoke runner, which runs the projector there. A render check over every root fails when another Kubernetes role gains Machine status writes or another Milo role gains a Machine status, update or patch permission. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nder check Name the webhook under the Machine's own API group, and add it and its writer flag to the registration rollout contract. The render check now reads roles held in JSON strings and treats an aggregated ClusterRole as a Machine status writer. Move the writer audit into the device custody guide and drop deployment state from it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
124982e to
0b4c1d7
Compare
ecv
left a comment
There was a problem hiding this comment.
Approve.
The handler admits a machines/status UPDATE that leaves status.power unchanged, and a change only from --machine-power-writer. Unset, it refuses every change. It reads power from the raw JSON with exact keys, so a case-folded or duplicate key cannot slip a value past it. The webhook routes only status writes that change power and is fail-closed. The standalone ValidatingAdmissionPolicy applies the same rule. The Machine CRD declares subresources: {status: {}}, so a main-resource update cannot carry a power change around the guard. The envtest drives update and patch from nine other identities against both guards, and the render test fails if any role other than the controller gains Machine status writes.
- Fail-closed with an empty writer by default means the projector's first power write is refused in any Milo root that has not set
--machine-power-writer. The rollout note says to set it before enabling the projector. Make sure the deploying repository's registration overlay sets it in the same change that enables the projector. - Other Machine status fields stay writable by consumer roles until Milo enables subresource authorization. The PR says so; that is the larger gap.
Follow-ups:
- Track the Milo work the PR names (subresource authorization, the Machine ProtectedResource declaring its status subresource, controller-only
machines/statusupdate and patch) as an issue, so the remaining status fields are not forgotten.
Summary
Follow-up to #182. Only the power projector may change a Machine’s observed
status.power. Milo authorizes status writes through Machine update and patch permissions, which consumer roles hold, so RBAC alone cannot enforce this restriction. This PR adds a fail-closed admission webhook in the Milo root and an equivalent admission policy in standalone.Rollout and scope
--machine-power-writerto the manager’s Milo identity before enabling the projector. The Milo root leaves it unset by default, which refuses every power change.Verification
🤖 Generated with Claude Code