dtls13: add check over handshake message length#10769
Open
rizlik wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a DTLS 1.3 safety check to prevent buffering/reassembly of unauthenticated handshake fragments that claim an excessive message_length, and introduces a regression test to ensure oversized plaintext handshake messages are dropped rather than stored.
Changes:
- Add a
MAX_HANDSHAKE_SZcap check insrc/dtls13.cbefore buffering handshake fragments for reassembly. - Add a new DTLS 1.3 memio test that spoofs a plaintext
ServerHellohandshakemessage_lengthto exceedMAX_HANDSHAKE_SZand asserts nothing is buffered. - Register the new test in the DTLS API test declarations.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
tests/api/test_dtls.h |
Declares and registers the new DTLS 1.3 oversized handshake-length test. |
tests/api/test_dtls.c |
Adds a memio-based regression test that injects an oversized plaintext handshake fragment and checks it isn’t buffered. |
src/dtls13.c |
Caps DTLS 1.3 handshake messageLength prior to fragment buffering; drops oversized plaintext messages and errors on oversized encrypted ones. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+1892
to
+1896
| /* Cap the handshake message size before it can be buffered for reassembly, | ||
| * matching the DTLSv1.2 path (DoDtlsHandShakeMsg()). RFC 9147 Sec 4.5.2 | ||
| * says invalid records SHOULD be silently discarded, so only error out once | ||
| * the record is authenticated (received in an encrypted epoch); a plaintext | ||
| * message is just dropped. */ |
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.
No description provided.