Skip to content

enforce biscuit expiry and revocation in node relay - #334

Merged
aojea merged 1 commit into
google:mainfrom
IbrahimAhmed8:fix_auth_bypass
Sep 1, 2026
Merged

enforce biscuit expiry and revocation in node relay#334
aojea merged 1 commit into
google:mainfrom
IbrahimAhmed8:fix_auth_bypass

Conversation

@IbrahimAhmed8

Copy link
Copy Markdown
Contributor

Resolves #333

@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 refactors the authentication handshake logic in SamNode by extracting trusted public key retrieval into a helper method, utilizing identity.VerifyBiscuit for verification, and adding a check to reject revoked peers. Feedback highlights a critical issue with key rotation in performRouterAuthHandshake where only the first key is used to instantiate the authorizer, and notes that n.BiscuitTimeout is currently uninitialized, causing it to fall back to the default timeout.

Comment thread internal/node/node.go
Comment thread internal/node/node.go Outdated
aojea added a commit that referenced this pull request Aug 31, 2026
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 #334.
@aojea

aojea commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator

please rebase and squash,

@aojea

aojea commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator

/gemini review

@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 refactors biscuit verification in internal/node/node.go and its tests, introducing a helper method getTrustedPublicKeys to safely retrieve trusted public keys and utilizing the new identity.VerifyBiscuitAndGetKey function in performRouterAuthHandshake. The reviewer feedback suggests extending this optimization to HandleAuthHandshake and its corresponding test in node_test.go by using identity.VerifyBiscuitAndGetKey there as well, which would eliminate redundant loops over all trusted public keys when determining token expiration.

Comment thread internal/node/node.go Outdated
}

b, expiry, err := n.verifyBiscuit(exchange.Biscuit, remotePeer)
b, err := identity.VerifyBiscuit(exchange.Biscuit, remotePeer, n.getTrustedPublicKeys(), n.BiscuitTimeout)

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.

medium

We can use identity.VerifyBiscuitAndGetKey instead of identity.VerifyBiscuit to retrieve the specific public key that successfully verified the biscuit. This allows us to avoid looping over all trusted public keys again when we determine the token's expiration later in this function. Note that this pattern is already correctly used in performRouterAuthHandshake.

Suggested change
b, err := identity.VerifyBiscuit(exchange.Biscuit, remotePeer, n.getTrustedPublicKeys(), n.BiscuitTimeout)
b, verifyingKey, err := identity.VerifyBiscuitAndGetKey(exchange.Biscuit, remotePeer, n.getTrustedPublicKeys(), n.BiscuitTimeout)

Comment thread internal/node/node.go
Comment thread internal/node/node_test.go
@IbrahimAhmed8

Copy link
Copy Markdown
Contributor Author

@aojea all sorted n squashed

@aojea

aojea commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator

Needs rebase

@aojea
aojea merged commit b8ae374 into google:main Sep 1, 2026
18 checks passed
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.

Node relay authentication fails to enforce biscuit expiry and revocation

2 participants