Repository navigation
✨ hub: registration key rotation with a grace window - #19240
hivecommons-hive[bot] wants to merge 1 commit into
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Open PR overlap checkBase branch: Conflicts are checked with every PR merged onto the current tip of
|
There was a problem hiding this comment.
Decision needed: @clubanderson should a rotated-away registration key stay valid for a configurable window of up to 168h (restarting on every re-rotation) when HIVE_HUB_SELFSERVICE_KEY_GRACE is on?
Read selfservice_key_grace.go and the selfservice_registry.go change. The code does what the body says and I found no defect; this needs a human only because it changes credential-lifetime policy.
Verified: rotateWithPolicy (selfservice_key_grace.go, the replacePending branch) keeps PrevKeyHash and sets PrevKeyExpiresAt = now + window on every rotation. So an owner who rotates because a key leaked still has that key authenticating for 1h by default (up to 7d via HIVE_HUB_SELFSERVICE_KEY_GRACE_WINDOW), and repeated rotations keep pushing the window out. The PR body already names the restart behaviour as its open choice. It is off by default, the legacy rotateIfMatch path is preserved, and the audit line carries no key or hash.
Suggestion, not a defect: there is no way to rotate and revoke the old key immediately in the grace mode; an owner responding to a leak may want that.
-- hive: agent=reviewer-2 backend=claude model=claude-sonnet-5-5 claude=2.1.328
Mutation testing2 mutant(s) in changed files are not reached by any test (NOT COVERED). A maintainer may apply the
Verdict: |
|
Needs a decision, not a merge:
Head: verdict requires_human @9cb87e2, 73/73 checks green, DCO yes, soak 0s of 10m0s. What to do: approve this head ( How to release it:
Clear the cause and the hive re-evaluates on its next pass; the stage moves to Updated 2026-11-19 16:56 UTC. |
|
/approve Posted by @clubanderson from the Hive dashboard; the merge gate decides from here. |
|
/hive decision approve #19240: green head, reviewer question answered with the reversible default — proceed as implemented Rationale: no owner rule holds this back; a merge is reversible and keeps work moving. Hive decided: Approved for merge. Decided by the hive at @clubanderson's request as the owner's delegate under the owner-delegate policy (rule |
|
Approved by @clubanderson for Hive auto-merge on green CI. |
|
Hive queued this PR but could not set the |
|
New changes are detected. LGTM label has been removed. |
There was a problem hiding this comment.
Security delta re-review at ff39fea: the delta is a main merge, and none of this PR's selfservice_* files changed. The previous finding (old key stays valid; the window restarts on each rotation, selfservice_key_grace.go:113) is still present. It is a disclosed, owner-only, flag-off-by-default, capped (168h) design choice, and #19235 doesn't specify the restart. It is downgraded to a low out-of-scope advisory; a revoke-old-key path would be a good follow-up. The merged hub/ hunks (heartbeat_protocol.go) add no new auth surface. I did not review the crux/proxy, customers, dashboard or github hunks in depth.
Verdict: approve.
-- hive: agent=ci-maintainer backend=claude model=claude-sonnet-5-5 claude=2.1.328
|
Hive status — updated in place; edits do not notify. Full history is in the Activity Monitor. Review follow-ups: 1 open of 1 (below
|
|
/approve Posted by @clubanderson from the Hive dashboard; the merge gate decides from here. |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
ff39fea to
9cb87e2
Compare
There was a problem hiding this comment.
Decision needed: @clubanderson should decide whether a rotation inside an open grace window may keep the old key alive and restart its window, given that rotation is then not a way to revoke a leaked key.
Read selfservice_key_grace.go and the two rotate call sites in the diff. The flag-off path is unchanged and the store save/rollback looks right. One credential-policy choice needs an owner, not a code fix: see the thread on rotateWithPolicy.
-- hive: agent=reviewer backend=claude model=claude-sonnet-5-5 claude=2.1.328
| now := st.clock().UTC() | ||
| before := *h | ||
| var info selfServiceRotation | ||
| if policy.replacePending && h.PrevKeyHash != "" && now.Before(h.PrevKeyExpiresAt) { |
There was a problem hiding this comment.
With the flag on, a second rotation inside an open window keeps PrevKeyHash and sets PrevKeyExpiresAt = now.Add(policy.window) (the next lines). So an owner who rotates because the old key leaked cannot revoke it: it stays valid for another full window (up to 168h), and each further rotation restarts it. Conversely, if the owner already deployed the pending key, the second rotation drops the deployed key at once, the same outage this PR set out to remove. Both are consequences of the keep-old/replace-pending rule. Suggest either an explicit owner-initiated revoke of the old key, or not restarting the window (keep the original expiry) on a replace. Which behaviour is wanted is a decision for a maintainer.
|
/approve Posted by @clubanderson from the Hive dashboard; the merge gate decides from here. |
Summary
Step 2 of the hub registration protocol rollout (#19056). Before this, rotating a self-service registration key kept the old key alive for a fixed 10 minutes. That is too short for an owner who redeploys a spoke by hand. Rotating twice inside that window also caused an outage: the key the spoke was still running was retired at once, because the previous slot was given to the key minted a moment earlier.
With the new
HIVE_HUB_SELFSERVICE_KEY_GRACEflag on:HIVE_HUB_SELFSERVICE_KEY_GRACE_WINDOW(default1h, clamped to168h; an invalid value falls back to the default);overlapin both rotate responses andlimits.key_rotation_overlapin discovery report the window in effect.The flag is off by default, and rotation then behaves exactly as before. The record shape is unchanged, so existing registrations need no data change. Nothing writes to GitHub. The
selfservice_hive_rotatedaudit line gainsgrace,replaced_pendingandold_key_expires_at, and still carries no key and no hash. A caller-chosen grace in the request body is still refused, as before.Open choice for review: the window restarts on a replacing rotation, so the owner always gets a full window to deploy the newest key. Repeated rotations can therefore keep the old key alive longer. Only the owner can rotate, and the window is capped.
Related issues
Closes #19235
Fixes #19056
Testing
gofmt -lwas run on changed files.New tests in
selfservice_key_grace_test.go: both keys work inside the window and the old key is refused after it; a second rotation replaces the pending key, keeps the original and restarts the window; with the flag off, the legacy behaviour is unchanged; env parsing (default, custom, invalid, negative, ceiling); and an end-to-end v1 rotate with the audit line checked for grace fields and for no key or hash.🤖 Generated with Claude Code
-- hive: agent=scanner backend=claude model=claude-sonnet-5-5 claude=2.1.328 requested_by=@clubanderson