Conversation
|
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved moderate DTLS handling issues and critical test build-guard failures block approval.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Adds configurable DTLS cookie handling so servers can process fragmented initial DTLS 1.3 ClientHellos when cookies are disabled.
Changes:
- Adds cookie policy APIs and shared secret lifecycle handling.
- Updates DTLS accept paths and callback behavior.
- Adds DTLS 1.2/1.3 tests and documentation.
File summaries
| File | Change | Final findings |
|---|---|---|
wolfssl/ssl.h |
Public cookie APIs and callback documentation | None |
wolfssl/internal.h |
Internal state and helper declarations | None |
tests/api/test_tls13.c |
TLS 1.3 API coverage | None |
tests/api/test_dtls13.h |
DTLS 1.3 test registration | None |
tests/api/test_dtls13.c |
DTLS 1.3 handoff and fragmentation tests | None |
tests/api/test_dtls.h |
Shared DTLS test declarations | None |
tests/api/test_dtls.c |
DTLS cookie, fragmentation, and policy tests | Critical (1 vote): Missing server-build guards cause compilation/link failures. Two tests also require both client and server support. |
src/tls13.c |
TLS 1.3 cookie and accept handling | Moderate (1 vote): Stateful processing must account for disabled HRR-cookie support. |
src/ssl.c |
Callback state reset | None |
src/ssl_api_hs.c |
Generic accept state handling | Moderate (1 vote): No-HRR-cookie builds can reject valid no-cookie DTLS 1.3 ClientHellos and must retain DTLS 1.2 HVR downgrade behavior. |
src/ssl_api_dtls.c |
Cookie policy and callback implementation | None |
src/internal.c |
DTLS cookie initialization | Moderate (1 vote): Reset chGoodCbDone when initializing a reused server connection. |
doc/dox_comments/header_files/ssl.h |
Public API documentation | None |
Review details
Suppressed comments (3)
src/internal.c:2440
- This initializer is also used by
wolfSSL_set_accept_state(), so a reused server object can enter a new handshake withchGoodCbDonestill set from its previous no-cookie connection.DtlsNoCookieChGood()will then suppress the callback for the new ClientHello. Reset this per-connection bit alongside the cookie policy when initializing the server side.
src/ssl_api_hs.c:931 - In a build with
WOLFSSL_SEND_HRR_COOKIEdisabled, DTLS 1.3 has no HRR-cookie path, butInitSSL_DtlsServer()still setssendCookieto 1. This leaves the generic accept path stateless before parsing the version, soDoClientHelloStateless()rejects a valid DTLS 1.3 no-cookie ClientHello instead of transitioning to stateful processing; generic methods also need to retain the DTLS 1.2 HVR downgrade behavior.
if (!ssl->options.sendCookie)
ssl->options.dtlsStateful = 1;
src/tls13.c:17781
- This test assumes
sendCookiemeans that a DTLS 1.3 cookie mechanism is available. WithWOLFSSL_SEND_HRR_COOKIEdisabled,InitSSL_DtlsServer()still initializes this bit to 1 for every DTLS server, so this path leavesdtlsStatefulfalse and sends the first no-cookie ClientHello throughDoClientHelloStateless(), which rejects it (and cannot reassemble a first fragment). Please make the stateful decision account for the compile-time absence of HRR-cookie support; the genericwolfSSL_accept()path needs the same correction.
if (!ssl->options.sendCookie)
ssl->options.dtlsStateful = 1;
- Files reviewed: 13/13 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
2356c7b to
1a0dbc1
Compare
Frauschi
left a comment
There was a problem hiding this comment.
Went through the DTLS cookie-mode changes. The feature itself looks right, but making sendCookie the single master switch pulls several existing APIs along with it, and a few of those are silent behaviour changes for current callers.
The ones I would want addressed before merge are the WOLFSSL_NEITHER_END regressions - wolfSSL_send_hrr_cookie(), wolfSSL_disable_hrr_cookie() and wolfDTLS_accept_stateless() all now return SIDE_ERROR on objects that used to work - and wolfSSL_set_accept_state() silently undoing wolfSSL_disable_cookie(). I built the branch and reproduced all four. The rest are smaller: a missing state guard on the new enable/disable pair, the widened scope of wolfSSL_disable_hrr_cookie() which needs a ChangeLog entry, and a non-atomic failure path in wolfSSL_enable_cookie().
Frauschi
left a comment
There was a problem hiding this comment.
Rebuilt at d3dbe4c and re-ran the cases from last round; the side, ordering, state-guard, callback-retry and atomicity points are resolved. I withdraw the wolfSSL_disable_hrr_cookie() one (see thread). Left: ChangeLog/doxygen wording and two small cleanups.
julek-wolfssl
left a comment
There was a problem hiding this comment.
Fixes worth doing now (all small)
- P2, diff-caused doc gap —
wolfSSL_send_hrr_cookiedox attributesBAD_STATE_Esolely to committed stateful processing, but the code also returns it when a secret must be generated andssl->rng == NULL(proven bytest_dtls12_cookie_secret_generate_fail/test_dtls13_hrr_cookie_secret_generate_fail). Add one clause to theBAD_STATE_Ebullet (same clause optionally forwolfSSL_enable_cookie). - P2, headline-feature inertness undocumented — fragmented first CH only works when
WOLFSSL_DTLS_CH_FRAGis compiled;dtls13ChFragdefaults on only with MLKEM, and the newwolfSSL_disable_cookiedox + ChangeLog never state the requirement. Document it (--enable-dtls-frag-ch/wolfSSL_dtls13_allow_ch_frag()), otherwise users in non-MLKEM builds get silent fragment drops. (Alternatively armdtls13ChFragwheneverWOLFSSL_DTLS_CH_FRAGis compiled — that's a behavior change, so doc-first.) - P2, diff-caused, debug-config abort —
InstallCookieSecretnow callswc_MemZero_Addon every rotation (pre-diff code only Added on size change). OnWOLFSSL_CHECK_MEM_ZERObuilds whose free path doesn't remove tracker entries (heap-hint/static-memory variant ofwolfSSL_Free), ≥256 same-size secret rotations overflow the 256-entry cache andabort()(memory.c:256-283). I independently verified this mechanism. One-line fix:wc_MemZero_Check(dst->buffer, dst->length)inFreeCookieSecretafterForceZero, beforeXFREE(removes the entry; no-op when absent). - Two pre-existing stale dox lines the diff touched around:
wolfSSL_DTLS_SetCookieSecret's "\return COOKIE_SECRET_SZ returned if the secret size is 0" (code returns 0) and the HRR-secret default-size fallback claim (WC_SHA_DIGEST_SIZE; code falls back SHA384→SHA512→SM3).
Description
First PR in a series to implement DTLS server that can handle bounded fragmented Client Hello.
This first PR allow to switch return routability check completely by disabling cookies.
A server with cookies disabled is compatible with other libraries that fragments ClientHellos to accomodate big PQC keyshares.