wolfssl icon indicating copy to clipboard operation
wolfssl copied to clipboard

DTLS 1.3: with the HRR cookie disabled, a lost HelloRetryRequest is never resent and the handshake fails (-308)

Open NordineQuadar opened this issue 2 weeks ago • 9 comments

Companion report to #12022 (the DTLS 1.3 retransmission throttle under NO_ASN_TIME), which mentions this one in its last line. Found while benchmarking post-quantum DTLS 1.3 on Cortex-M devices over emulated narrowband links

wolfssl_issue2_attachments.zip

. Reproduction scripts and logs are attached; the reproduction needs only stock wolfSSL and one Linux host.

Summary

With the HRR cookie disabled on the server (wolfSSL_disable_hrr_cookie(), example server -J n), a DTLS 1.3 handshake that needs a HelloRetryRequest does not survive the loss of that HRR.

  • The client resends its ClientHello after its timer, as RFC 9147 expects.
  • The server answers with an ACK of both ClientHello copies and does not resend the HRR.
  • The client, its ClientHello acknowledged, sends nothing more. wolfSSL_connect() fails with -308 once its retransmission timer passes DTLS_TIMEOUT_MAX, about 127 s later from a 1 s initial timeout.

Three cases, the same on v5.9.4-stable and on current master (550fffce, 2026-11-15):

  • cookie off, default client build: fails (master: 130.2 s; v5.9.4-stable: 130.5 s);
  • cookie off, client built with -DNO_ASN_TIME: fails (129.9 s on both);
  • cookie on: completes (master: 4.8 s; v5.9.4-stable: 4.9 s), because the stateless HRR is simply sent again.

The throttle reported in #12022 has no part in this: the two cookie-off cases see the same two datagrams each way. We see the same failure on a Cortex-M33 board with our own client and server.

RFC 9147:

  • §3.1, "Packet Loss", describes exactly this case (Figure 1: ClientHello, HelloRetryRequest lost, timer expires, ClientHello retransmitted) and continues: "When the server receives the retransmission, it knows to retransmit its HelloRetryRequest or ServerHello."
  • §7.1 lists the handshake flights other than the client's final flight as implicitly acknowledged by the next flight: "ACKs SHOULD NOT be sent for these flights unless the responding flight cannot be generated immediately."

Versions checked

Commit Date Cookie off, HRR lost
v5.9.4-stable 3c5eead44904df64e6a5a1f4ebdce377d35a849a 2026-09-25 fails, -308 (run 2026-11-05)
master 550fffce0b38a46fae49aa304cf57c2353ad4c7f 2026-11-15 fails, -308, the same 47 B reply (run 2026-11-15)

Related, not changing this case:

  • #11475 (merged 2026-09-28), "accept a fragmented first ClientHello when cookies are disabled".
  • #11757's "only a complete ServerHello acknowledges the ClientHello" (906ea085): the client's retransmit buffer, not the server's reply.
  • #11989 (open), "DTLS 1.3 ClientHello reassembly before cookie, shared cookie secret, bounded DTLS receive list". It reworks the server's first-ClientHello path, so it may be the natural place for a fix; we have not tested it.
  • Since 2026-11-05, the only master commit on src/dtls13.c is the sequence-number wrap guard (337f975e).

Reproduction with stock wolfSSL, no hardware

hrr_repro.sh (attached, with repro.sh, slowlink.py and decode_dtls.py beside it; needs git, cmake, a C compiler and python3's standard library):

  • Builds: wolfSSL's CMake with DTLS 1.3, WOLFSSL_DTLS_MTU, ML-KEM, the PQ hybrids, Curve25519 and ECC, with and without -DNO_ASN_TIME (the same two builds as #12022's repro.sh). TAG=master bash hrr_repro.sh <workdir> builds master; the default is v5.9.4-stable.
  • Why an HRR happens: wolfSSL's CMake turns on WOLFSSL_DTLS_CH_FRAG when ML-KEM and DTLS 1.3 are both enabled. At MTU 256 the client's first ClientHello therefore carries no key share, and the server must answer with an HRR.
  • Server: -u 256 -v 4 -b -d -i -l TLS13-AES256-GCM-SHA384 --pqc X25519MLKEM768, with -J n (no cookie).
  • Client: -u 256 -v 4 -l TLS13-AES256-GCM-SHA384 --pqc X25519MLKEM768 -A certs/ca-ecc-cert.pem.
  • Relay (slowlink.py): 9600 bit/s, 8 ms one way, 64 KiB queue; the first server-to-client datagram (the HRR) is dropped.

Result on master 550fffce (2026-11-15; hrr_repro_master_20261115/ in the logs zip):

Client build Server cookie Result Up Down Client error
default off (-J n) fails at 130.2 s 2 datagrams, 131 B each (CH1, then CH1 again after 1 s) HRR (77 B) dropped; then one 47 B datagram, the ACK of both ClientHellos wolfSSL_connect error -308, error state on socket
-DNO_ASN_TIME off fails at 129.9 s the same the same the same
default on ok, 4.8 s 19 18, the cookie HRR dropped and sent again for the CH1 resend none

v5.9.4-stable (2026-11-05, hrr_repro_v5.9.4_20261105/) gives the same, with 126 B ClientHellos: 130.5 s, 129.9 s, 4.9 s.

The 47 B reply

Every datagram on the link in the default cookie-off case on master (decode_dtls.py on the relay's payload log):

  0.961 up    131 B forward  handshake  epoch=0 seq=0 length=118 client_hello message_seq=0 (unfragmented, 106 B)
  1.081 down   77 B drop     handshake  epoch=0 seq=0 length=64  server_hello/hello_retry_request message_seq=0
  1.966 up    131 B forward  handshake  epoch=0 seq=1 length=118 client_hello message_seq=0 (unfragmented, 106 B)
  2.086 down   47 B forward  ack        epoch=0 seq=1 length=34  acked=[(0, 0), (0, 1)]

After 2.1 s, nothing more in either direction until the client gives up. The 47 B datagram, in full:

1a fefd 0000 000000000001 0022 | 0020 {epoch 0, seq 0} {epoch 0, seq 1}
  • A DTLSPlaintext record of content type 26 (ack), epoch 0, sequence number 1, length 34. Its record-number list (32 B) holds two record numbers of 16 B each: (0, 0) and (0, 1).
  • Those are exactly the two ClientHello records on the up link: the same message (message_seq 0), sent as records 0 and 1.
  • So the server explicitly acknowledges both ClientHellos and never resends its HelloRetryRequest. The client, with nothing unacknowledged, waits for a reply that will not come.
  • The same bytes come from the -DNO_ASN_TIME case and from v5.9.4-stable.

Where in the code

Not located. A hypothesis, not checked in the source: the cookie path recovers because a cookie HRR is generated statelessly for every ClientHello. Without the cookie, the server keeps state after its HRR, and may handle the retransmitted ClientHello as an already-processed message to acknowledge rather than as a cue to resend the HRR.

Effect

On a lossy link (our 2400-9600 bit/s satellite-pass profile), every cookie-off handshake whose HRR is lost costs the full retransmission chain, over two minutes, and then fails. Any configuration that needs an HRR is exposed: here ML-KEM key shares too large for the first datagram at a small MTU, but also a group mismatch.

The cookie exchange is optional in RFC 9147. §5.1: "If the server is being operated in an environment where amplification is not a problem, [...] the server MAY be configured not to perform a cookie exchange. The default SHOULD be that the exchange is performed, however. In addition, the server MAY choose not to do a cookie exchange when a session is resumed or, more generically, when the DTLS handshake uses a PSK-based key exchange and the IP address matches one associated with the PSK." On a narrow link a designer is tempted to turn cookies off to save a round trip: on a 2400 bit/s pass, the cookie round trip's two datagrams alone take about a second of air time. The PSK case §5.1 allows is a natural one for a satellite with a provisioned key. A lost HRR then turns the saved round trip into a failed handshake.

Suggested change (for discussion)

When a stateful server (cookie off) that has sent an HRR receives a retransmission of the ClientHello it answered, resend the HRR, as RFC 9147 §3.1 describes. Don't send an ACK for it: §7.1 says the HRR's flight is implicitly acknowledged by the responding flight.

Attached: wolfssl_issue2_attachments.zip, containing hrr_repro.sh, repro.sh (its build steps), slowlink.py, decode_dtls.py, and the logs of both runs (hrr_repro.out, and per case the client and server logs, the relay's link.csv and payloads.csv).

NordineQuadar avatar Nov 15 '26 17:11 NordineQuadar

Hi,

My name is Anthony and I am a member of the wolfSSL team. My first step is to reproduce what you are seeing. Please stay tuned.

Warm regards, Anthony

anhu avatar Nov 16 '26 14:11 anhu

Browsers (Chrome, Firefox, Edge) already offer X25519MLKEM768; whether a connection uses it depends on the server or CDN, and the classical group stays as a fallback.

Step-by-step guide: https://ather-quantum.com/guides/harvest-now-decrypt-later To verify from outside (which group the server actually negotiates): https://ather-quantum.com/?domain=yourdomain

(Disclosure: I run that scanner; the guide and the check are free.)

moncef00327-cloud avatar Nov 16 '26 17:11 moncef00327-cloud

Hi,

My name is Anthony and I am a member of the wolfSSL team. My first step is to reproduce what you are seeing. Please stay tuned.

Warm regards, Anthony

Thanks, Anthony. Everything needed to reproduce it is in the attached zip: hrr_repro.sh builds wolfSSL at a given tag and runs the three cases through the slow-link script. The companion report is #12022 (the retransmission rate limit compiled out with NO_ASN_TIME); the two were found in the same measurements. I’m happy to re-run either on any branch or patch you’d like tested, including #11989

NordineQuadar avatar Nov 16 '26 17:11 NordineQuadar

Hi Anthony,

Thanks for taking a look and for your willingness to reproduce this.

Everything needed to reproduce the behavior is packaged in the script (hrr_repro.sh). Specifically:

  • It builds wolfSSL at the specified tag.
  • It executes the three test cases through the slow-link script to evaluate the retransmission rate limit.
  • The companion report is tracked in #12022 (compiled with NO_ASN_TIME).

I'm more than happy to re-run or adjust this on any branch or patch you'd like tested, including #11989.

For anyone looking to verify real-world server negotiation of hybrid post-quantum groups like X25519MLKEM768 from the outside, you can also cross-check via the free scanner and guides at Ather Quantum.

Best regards, في ‫اثنين، 16 نوفمبر، 2026 في 18:49‬‏، كتب ‪NordineQuadar < @.***>‬‏:

NordineQuadar left a comment (wolfSSL/wolfssl#12136) https://github.com/wolfSSL/wolfssl/issues/12136#issuecomment-6924381907

Hi,

My name is Anthony and I am a member of the wolfSSL team. My first step is to reproduce what you are seeing. Please stay tuned.

Warm regards, Anthony

Thanks, Anthony. Everything needed to reproduce it is in the attached zip: hrr_repro.sh builds wolfSSL at a given tag and runs the three cases through the slow-link script. The companion report is #12022 https://github.com/wolfSSL/wolfssl/issues/12022 (the retransmission rate limit compiled out with NO_ASN_TIME); the two were found in the same measurements. I’m happy to re-run either on any branch or patch you’d like tested, including #11989 https://github.com/wolfSSL/wolfssl/pull/11989

— Reply to this email directly, view it on GitHub https://github.com/wolfSSL/wolfssl/issues/12136?email_source=notifications&email_token=CPY2IKUKK3MOZHMVJHS2UOL5ZM4ZZA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTMOJSGQZTQMJZGA32M4TFMFZW63VHMNXW23LFNZ2KKZLWMVXHJLDGN5XXIZLSL5RWY2LDNM#issuecomment-6924381907, or unsubscribe https://github.com/notifications/unsubscribe-auth/CPY2IKQ3WXUOF7TXNSJPZJL5ZM4ZZAVCNFSNUABEKJSXA33TNF2G64TZHMZDQOJSHA2TEMR3JFZXG5LFHM3DIMBXGEZDKNRQHCQXMAQ . Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS https://github.com/notifications/mobile/ios/CPY2IKWHKQG2GLERDRZ4V235ZM4ZZA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTMOJSGQZTQMJZGA32M4TFMFZW63VHMNXW23LFNZ2KKZLWMVXHJKTGN5XXIZLSL5UW64Y and Android https://github.com/notifications/mobile/android/CPY2IKRTZR5KYWT7JDPALP35ZM4ZZA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTMOJSGQZTQMJZGA32M4TFMFZW63VHMNXW23LFNZ2KKZLWMVXHJLTGN5XXIZLSL5QW4ZDSN5UWI. Download it today! You are receiving this because you commented.Message ID: @.***>

moncef00327-cloud avatar Nov 16 '26 17:11 moncef00327-cloud

Note: the comments from moncef00327-cloud are not from me or anyone I work with; that account is unrelated to this report.

NordineQuadar avatar Nov 16 '26 18:11 NordineQuadar

I've assigned an engineer to look into this. Warm regards, Anthony

anhu avatar Nov 19 '26 22:11 anhu

Hi @NordineQuadar, The pull request linked above fixes this issue. Feel free to take a look. Best regards, Mattia

mattia-moffa avatar Nov 21 '26 04:11 mattia-moffa

Thanks @mattia-moffa for the update. I ran the #12136 reproduction against this branch (2c823c53), varying only the server build; the client is the base default build (72e43ca8) in every case. 9600 bit/s, MTU 256, cookie off unless noted, one run per case.

Case Server Outcome
HRR lost base client fails with -308 after 130.7 s
HRR lost once this PR ok in 4.7 s
first two HRR copies lost this PR ok in 6.0 s
first three HRR copies lost this PR ok in 8.0 s
cookie on, HRR lost this PR ok in 4.8 s, same datagram counts as base
no loss this PR ok in 3.7 s, same datagram counts as base

So the fix resolves what I reported. On the open review point (a duplicate ClientHello answered with an ACK while the HRR is buffered): in the two-loss case that is what happens on the wire, the ACK is delivered and the HRR travelling with it is dropped, but the handshake does not stall, because the server retransmits the buffered HRR on its timer (1.3 s later, then 2.0 s later in the three-loss case).

Not tested: how many times the server retransmits before giving up, a client built from this branch, and loss of the second ClientHello. Happy to share the scripts and logs or re-run on a new revision.

NordineQuadar avatar Nov 23 '26 01:11 NordineQuadar

On the open review point (a duplicate ClientHello answered with an ACK while the HRR is buffered): in the two-loss case that is what happens on the wire, the ACK is delivered and the HRR travelling with it is dropped, but the handshake does not stall, because the server retransmits the buffered HRR on its timer (1.3 s later, then 2.0 s later in the three-loss case).

Agreed. Thanks for trying it out!

mattia-moffa avatar Nov 24 '26 04:11 mattia-moffa