dtls13: epoch mangament improvement and bug fixes - #11016
Open
rizlik wants to merge 1 commit into
Open
Conversation
rizlik
commented
Jul 30, 2026
Contributor
- NULL-ify Dtls13DecryptEcpoch if the pointed epoch is evicted
- Use only epoch that can decrypt as candidate for decrypting records
- Never evict Peer epoch - 1 as it can be active
1. NULL-ify Dtls13DecryptEcpoch if the pointed epoch is evicted 2. Don't use ECRYPT_ONLY epoch as epoch candidates of received records 3. Never evict Peer epoch - 1 as it can be active
Contributor
There was a problem hiding this comment.
Pull request overview
This PR tightens DTLS 1.3 epoch lifecycle handling to avoid stale/invalid decrypt-epoch pointers, ensure only decrypt-capable epochs are considered for incoming record processing, and prevent eviction of epochs that may still be active due to KeyUpdate/ACK loss. It also adds regression tests covering epoch slot reuse, replay behavior, and rejection of post-handshake plaintext records.
Changes:
- Enforce a minimum DTLS 1.3 epoch slot count and expose
Dtls13NewEpochfor testing/prefix-mapped builds. - Make epoch reconstruction and eviction logic DTLS13-aware: skip encrypt-only epochs for decryption and preserve peer epoch − 1; NULL-out
dtls13DecryptEpochwhen its slot is evicted. - Reject DTLSPlaintext records (epoch 0) after handshake completion and add new DTLS13 API tests for the above behaviors.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
wolfssl/internal.h |
Enforces DTLS13_EPOCH_SIZE >= 4 and makes Dtls13NewEpoch test-visible/prefix-mapped. |
src/dtls13.c |
Improves epoch candidate selection and eviction safety (preserve peer epoch − 1; NULL decrypt epoch on eviction). |
src/internal.c |
Hardens record header processing for DTLS13 (recover when decrypt epoch is NULL; drop post-handshake plaintext). |
tests/api/test_dtls13.h |
Registers new DTLS13 regression tests. |
tests/api/test_dtls13.c |
Adds regression tests for epoch slot reuse, replay protection continuity, and post-handshake plaintext ACK dropping. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
julek-wolfssl
approved these changes
Jul 31, 2026
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.