Skip to content

Fix DTLS CID being dropped when a 1.3 client is downgraded to 1.2 - #12237

Merged
philljj merged 1 commit into
wolfSSL:masterfrom
gasbytes:gh-12208
Nov 25, 2026
Merged

philljj merged 1 commit into
wolfSSL:masterfrom
gasbytes:gh-12208

Conversation

@gasbytes

Copy link
Copy Markdown
Contributor

Description

A client offering DTLS 1.3 with a connection ID aborted when a 1.2 server answered with its own connection ID. The 1.3 code removed the client's connection ID before the 1.2 code had read the reply. It now only does that when 1.3 is actually negotiated.

Fixes #12208

Testing

Adds tests for a downgrade where the server accepts the connection ID and one where it doesn't.

Checklist

  • added tests
  • updated/added doxygen
  • updated appropriate READMEs
  • Updated manual and documentation

@gasbytes gasbytes self-assigned this Nov 23, 2026
Copilot AI balanced review requested due to automatic review settings November 23, 2026 17:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are recorded for the change preserving CID state during DTLS 1.3-to-1.2 downgrades.

No open issues 🎉

What changed in this PR

Fixes #12208 by preserving the client’s DTLS connection ID (CID) state during a downgrade from DTLS 1.3 to 1.2, allowing the DTLS 1.2 handler to process the server’s CID response.

Changes:

  • Limits early CID cleanup to connections that negotiate DTLS 1.3.
  • Adds downgrade regression tests for servers that accept or decline CID negotiation.
  • Clarifies the existing DTLS 1.2 cleanup path in a comment.
File Description
tests/​api/​test_dtls.h Declares and registers both downgrade tests.
tests/​api/​test_dtls.c Tests CID acceptance and rejection during downgrade, including application data exchange.
src/​tls13.c Prevents premature CID cleanup when downgrading to DTLS 1.2.
src/​internal.c Updates a comment explaining CID cleanup for downgraded clients.

Review effort: Balanced

@gasbytes
gasbytes marked this pull request as ready for review November 23, 2026 18:26
@github-actions

Copy link
Copy Markdown

retest this please

@github-actions

github-actions Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

MemBrowse Memory Report · Explore what changed →

zephyr-frdm_rw612

  • FLASH: datas +16 B, log_const_area -8 B, rodata +108 B, text +13,800 B (+4.9%, 296,380 B / 67,108,864 B, total: 0% used)
  • RAM: bss +49 B, datas +16 B (+0.1%, 58,423 B / 983,040 B, total: 6% used)

No memory changes detected for:


Catch memory regressions in CI with MemBrowse. Free for open source.

@julek-wolfssl julek-wolfssl left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think of taking this approach instead? Maybe its cleaner.

--- a/src/tls13.c
+++ b/src/tls13.c
@@ -6223,17 +6223,16 @@
             ssl->msgsReceived.got_hello_retry_request = 1;
             ssl->msgsReceived.got_server_hello = 0;
         }
+#ifdef WOLFSSL_DTLS_CID
+        else if (ssl->options.useDtlsCID)
+            DtlsCIDOnExtensionsParsed(ssl);
+#endif /* WOLFSSL_DTLS_CID */
     }
 
     if (args->totalExtSz > 0) {
         args->idx += args->totalExtSz;
     }
 
-#ifdef WOLFSSL_DTLS_CID
-    if (ssl->options.useDtlsCID && *extMsgType == server_hello)
-        DtlsCIDOnExtensionsParsed(ssl);
-#endif /* WOLFSSL_DTLS_CID */
-
     if (IsAtLeastTLSv1_3(ssl->version)) {
         *inOutIdx = args->idx;
     }

@gasbytes

Copy link
Copy Markdown
Contributor Author

What do you think of taking this approach instead? Maybe its cleaner.

--- a/src/tls13.c
+++ b/src/tls13.c
@@ -6223,17 +6223,16 @@
             ssl->msgsReceived.got_hello_retry_request = 1;
             ssl->msgsReceived.got_server_hello = 0;
         }
+#ifdef WOLFSSL_DTLS_CID
+        else if (ssl->options.useDtlsCID)
+            DtlsCIDOnExtensionsParsed(ssl);
+#endif /* WOLFSSL_DTLS_CID */
     }
 
     if (args->totalExtSz > 0) {
         args->idx += args->totalExtSz;
     }
 
-#ifdef WOLFSSL_DTLS_CID
-    if (ssl->options.useDtlsCID && *extMsgType == server_hello)
-        DtlsCIDOnExtensionsParsed(ssl);
-#endif /* WOLFSSL_DTLS_CID */
-
     if (IsAtLeastTLSv1_3(ssl->version)) {
         *inOutIdx = args->idx;
     }

yeah, thanks! that's much cleaner.

@gasbytes

Copy link
Copy Markdown
Contributor Author

Jenkins retest this please

@gasbytes gasbytes assigned wolfSSL-Bot and unassigned gasbytes Nov 25, 2026
@philljj philljj self-assigned this Nov 25, 2026
@philljj

philljj commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

tests good with skoll, and with multi-test with various tls, dtls, etc scenarios

@philljj
philljj merged commit c81176a into wolfSSL:master Nov 25, 2026
471 of 474 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: DTLS: client offering 1.3 with a Connection ID aborts with UNSUPPORTED_EXTENSION (-429) when a DTLS 1.2 server answers the CID

5 participants