Skip to content

fix(router): support key rotation in mutual auth handshake - #337

Merged
aojea merged 1 commit into
google:mainfrom
aojea:fix-router-mutual-auth-key-rotation
Aug 31, 2026
Merged

fix(router): support key rotation in mutual auth handshake#337
aojea merged 1 commit into
google:mainfrom
aojea:fix-router-mutual-auth-key-rotation

Conversation

@aojea

@aojea aojea commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator

While reviewing #334 we swept for other instances of the same bug class and found one in the router: performMutualAuth verifies the remote biscuit against all trusted control plane keys, but then builds the role authorizer from trustedKeys[0]. A biscuit signed by a rotated key passes verification and then fails authorization (biscuit: invalid signature), breaking router-to-router mutual auth for the entire rotation window.

This is the router-side twin of the node-side issue flagged in the #334 review; #334 doesn't touch this file.

Changes:

  • Use identity.VerifyBiscuitAndGetKey and build the authorizer from the key that actually verified.
  • Unit test TestPerformMutualAuthAcceptsRotatedKey: remote biscuit signed by the second trusted key must authenticate. Verified red against the old code (fails with authorizer instantiation failed: biscuit: invalid signature) and green with the fix.

performMutualAuth verified the remote biscuit against all trusted
control plane keys but then built the role authorizer from
trustedKeys[0]. A biscuit signed by a rotated key passed verification
and then failed authorization, breaking router-to-router auth for the
whole rotation window.

Build the authorizer from the key that actually verified, via
identity.VerifyBiscuitAndGetKey. Same bug class as the node-side fix
in google#334.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the mutual authentication process in the router to support key rotation. Instead of always using the first trusted key to instantiate the biscuit authorizer, it now retrieves and uses the specific key that successfully verified the biscuit. A new unit test, TestPerformMutualAuthAcceptsRotatedKey, has been added to verify this behavior. There are no review comments to address.

@aojea
aojea merged commit 8238675 into google:main Aug 31, 2026
18 checks passed
aojea added a commit to aojea/sam that referenced this pull request Aug 31, 2026
performRouterAuthHandshake verified the router biscuit against all
trusted control plane keys but built the role authorizer from
trustedKeys[0]. With a single key loaded this was harmless, which is
why it survived until now: once the node holds the full valid key set
(rotation grace), any router biscuit not signed by the first key fails
with 'authorizer instantiation failed: biscuit: invalid signature' —
exactly the kind-mesh e2e failure on this PR, and the node-side twin
of the router bug fixed in google#337.

The recovery test now seeds a decoy trusted key ahead of the real one
to pin this: verified red (reproduces the CI failure), green with the
fix.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant