fix(retry): ensure Retry Source CID differs from client DCID#5953
Open
MarkedMuichiro wants to merge 1 commit intomicrosoft:mainfrom
Open
fix(retry): ensure Retry Source CID differs from client DCID#5953MarkedMuichiro wants to merge 1 commit intomicrosoft:mainfrom
MarkedMuichiro wants to merge 1 commit intomicrosoft:mainfrom
Conversation
RFC 9000 \u00a717.2.5.1 requires the Source Connection ID in a Retry packet to differ from the client's Destination CID. The random generation was missing this check, allowing rare but non-compliant collisions. Fixes microsoft#5302
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.
Fixes #5302
Problem
When generating a Retry packet,
CxPlatRandomproduces a random Source Connection ID but does not check that it differs from the client's Destination CID. RFC 9000 §17.2.5.1 requires that the Source Connection ID in a Retry packet MUST NOT equal the Destination Connection ID sent by the client.While a collision is astronomically unlikely, the check is required for RFC compliance.
Fix
Wrapped the
CxPlatRandomcall in a do-while loop that regenerates if the new CID matches the client's DCID:The length guard is load-bearing — the client DCID length is client-controlled and can legitimately differ from
CidTotalLength, so skipping it would risk comparing against a shorter buffer.This also fixes a minor issue in the original:
CxPlatRandomwas called withsizeof(NewDestCid)which randomizes the fullQUIC_CID_MAX_LENGTHbuffer, but onlyMsQuicLib.CidTotalLengthbytes are ever used downstream. The fix randomizes only the bytes that matter.