fix: resend original WHOAREYOU during handshake retransmissions#219
Open
Gabriel-Trintinalia wants to merge 3 commits intoConsensys:masterfrom
Open
fix: resend original WHOAREYOU during handshake retransmissions#219Gabriel-Trintinalia wants to merge 3 commits intoConsensys:masterfrom
Gabriel-Trintinalia wants to merge 3 commits intoConsensys:masterfrom
Conversation
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.
When a session is in
WHOAREYOU_SENTand another unauthorised packet arrives (e.g. a retransmission), we were generating a new WHOAREYOU with a fresh nonce.That breaks the handshake: the initiator has already signed against the original challenge, so the next
HANDSHAKEgets rejected.This change reuses the original
WHOAREYOUinstead of creating a new one, keeping the challenge stable and the handshake valid.The spec requires this behaviour:
▎ If the recipient has already sent a WHOAREYOU for the node, it should re-send the same WHOAREYOU packet.
HandshakeResendhive testNote
Medium Risk
Touches session-handshake state and packet emission behavior; incorrect handling could break peer session establishment or cause stuck handshakes under packet loss/retransmit scenarios.
Overview
Ensures
UnauthorizedMessagePacketHandlerdoes not generate a newWHOAREYOUwhen the session is already inWHOAREYOU_SENT, and instead triggers a resend of the original challenge.Adds
NodeSessiontracking for the last outboundWhoAreYouPacketplus aresendOutgoingWhoAreYou()path that reuses the original masking IV/challenge bytes, and clears the pending packet when the handshake state is reset. Updates/extends tests to cover the resend behavior and challenge stability.Reviewed by Cursor Bugbot for commit eac42de. Bugbot is set up for automated code reviews on this repo. Configure here.