Skip to content

Fix DTLS 1.3 extSz out-of-bounds and word16 truncation on oversized certificate chains#10103

Open
gasbytes wants to merge 1 commit intowolfSSL:masterfrom
gasbytes:fix-dtls13-oversized-cert-chain
Open

Fix DTLS 1.3 extSz out-of-bounds and word16 truncation on oversized certificate chains#10103
gasbytes wants to merge 1 commit intowolfSSL:masterfrom
gasbytes:fix-dtls13-oversized-cert-chain

Conversation

@gasbytes
Copy link
Copy Markdown
Contributor

@gasbytes gasbytes commented Mar 30, 2026

Description

Fix DTLS 1.3 extSz out-of-bounds and word16 truncation on oversized certificate chains.

Fixes zd#21435

Testing

added test_dtls13_oversized_cert_chain that exercises the appropriate code pathss

Checklist

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

@gasbytes gasbytes requested a review from julek-wolfssl March 30, 2026 16:17
@gasbytes gasbytes force-pushed the fix-dtls13-oversized-cert-chain branch from 7cf8fea to a30c6af Compare March 30, 2026 16:32
src/dtls13.c Outdated
ssl->dtls13FragmentsBuffer.buffer + ssl->dtls13FragOffset,
fragLength);

if ((word32)outputSz > WOLFSSL_MAX_16BIT) {
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.

move it just after outputSz is computed

src/dtls13.c Outdated

seq = ssl->dtls13EncryptEpoch->nextSeqNumber;

if ((word32)sendSz > WOLFSSL_MAX_16BIT) {
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.

move it just after sendSz is computed

@gasbytes gasbytes force-pushed the fix-dtls13-oversized-cert-chain branch from a30c6af to fcd454f Compare March 30, 2026 17:39
@gasbytes gasbytes requested a review from rizlik March 30, 2026 17:39
@gasbytes gasbytes force-pushed the fix-dtls13-oversized-cert-chain branch from fcd454f to a9ff710 Compare March 30, 2026 19:18
rizlik
rizlik previously approved these changes Mar 30, 2026
julek-wolfssl
julek-wolfssl previously approved these changes Mar 31, 2026
@julek-wolfssl julek-wolfssl removed their assignment Mar 31, 2026
@gasbytes gasbytes force-pushed the fix-dtls13-oversized-cert-chain branch from a9ff710 to 5ae6a9d Compare March 31, 2026 12:33
@programsurf
Copy link
Copy Markdown

Thanks for the fix, @gasbytes. I'm the original reporter (zd#21435). Reviewed the changes:

  • tls13.c: sendSz/i bounds check before Dtls13HandshakeSend cast — addresses the root cause. - dtls13.c:1045: outputSz check in Dtls13SendFragmentedInternal — correct. - dtls13.c:1639: sendSz check in Dtls13RtxSendBuffered — correct. - extIdx + 1 < MAX_CERT_EXTENSIONS off-by-one fix — good catch. - Test covers the 70KB+ chain scenario.

LGTM. Thanks for the thorough fix and test.

@gasbytes
Copy link
Copy Markdown
Contributor Author

retest this please

@gasbytes gasbytes added the For This Release Release version 5.9.1 label Mar 31, 2026
@douzzer douzzer added the Conflicts Conflicts with master or staged PRs label Apr 1, 2026
@gasbytes gasbytes dismissed stale reviews from rizlik and julek-wolfssl via 8e35a14 April 2, 2026 08:56
@gasbytes gasbytes force-pushed the fix-dtls13-oversized-cert-chain branch from 5ae6a9d to 8e35a14 Compare April 2, 2026 08:56
@gasbytes gasbytes removed the Conflicts Conflicts with master or staged PRs label Apr 2, 2026
@douzzer
Copy link
Copy Markdown
Contributor

douzzer commented Apr 2, 2026

only failing test is something in the multi-test PRB (logs lost)

@douzzer douzzer added the Staged Staged for merge pending final test results and review label Apr 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

For This Release Release version 5.9.1 Staged Staged for merge pending final test results and review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants