quic: validate session close error codes - #66302
Open
christianaurichzm wants to merge 1 commit into
Open
christianaurichzm wants to merge 1 commit into
christianaurichzm wants to merge 1 commit into
Conversation
`session.close()` and `session.destroy()` only checked that `options.code` was a bigint or a number. Numbers were then converted to `uint64_t` unchecked, so fractions were truncated and negative, non-finite or too large values were undefined behavior. Bigints were only checked to fit in 64 bits, but QUIC error codes are variable-length integers limited to 62 bits, so larger codes cannot be encoded in the `CONNECTION_CLOSE` frame. Reject codes that are not integers between `0` and `2n ** 62n - 1n`, the range `QuicError` already enforces, before any close or destroy side effects. Signed-off-by: Christian Aurich Zanettini Martins <christian.aurichzm@gmail.com>
Collaborator
|
Review requested:
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #66302 +/- ##
==========================================
- Coverage 90.37% 90.36% -0.01%
==========================================
Files 790 790
Lines 273856 274287 +431
Branches 52394 52503 +109
==========================================
+ Hits 247495 247869 +374
- Misses 16853 16893 +40
- Partials 9508 9525 +17
🚀 New features to boost your workflow:
|
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.
session.close()andsession.destroy()only check thatoptions.codeis a bigint or a number.MaybeSetCloseError()then casts numbers straight touint64_t, and bigints are only checked to fit in 64 bits, but QUIC error codes are 62-bit varints.So an invalid code is sent as some other code. On x64,
1.5goes out as1,-1as2 ** 62 - 1, andNaN,Infinityand2n ** 62nreach the peer asNO_ERROR, which makes an error close look like a clean one.Codes outside
0to2n ** 62n - 1nnow throwERR_OUT_OF_RANGE, the same rangeQuicErroruses. The check is invalidateCloseOptions(), so it runs beforedestroy()tears anything down. The existing validate-options test covers the invalid codes for both methods, and its finaldestroy()now sends the max code and checks that the server gets it unchanged.