Repository navigation
fix: clean up expected-response entry on failed handshake and preserve challenge expiry - #319
Open
MatusKysel wants to merge 1 commit into
Open
MatusKysel wants to merge 1 commit into
MatusKysel wants to merge 1 commit into
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.
Follow-up to #306.
Summary
In
Handler::handle_auth_message, the active challenge was removed before callingSession::establish_from_challenge, leaving two packet-filter exemption leaks:SessionNotEstablished): whenestablish_from_challengereturns any error other thanInvalidChallengeSignature, the challenge is already removed (so the expiry cleanup from fix: remove expected-response entry on challenge expiry #306 never runs) andfail_sessiononly decrementsfilter_expected_responsesfor active requests, not for unsolicited challenges. TheSocketAddrentry therefore remains infilter_expected_responsespermanently, bypassing rate limits and bans for the lifetime of the process.InvalidChallengeSignature: removing and re-inserting the challenge on an invalid signature resets itsHashMapDelaytimer back torequest_timeout, allowing repeated invalid-signature handshakes to keep the packet-filter exemption open indefinitely.Fix
&Challengefromactive_challengesinSession::establish_from_challenge(via an internalChallengeErrorso the publicErrorenum stays unchanged).remove_expected_responseon both success and non-signature handshake failure.InvalidSignature, leave the existing challenge inactive_challengesuntouched so its original expiry deadline is preserved.test_failed_handshake_removes_expected_responseandtest_invalid_challenge_signature_does_not_reset_expiry).