Skip to content

Fixes: for GH #10068#10094

Merged
JacobBarthelmeh merged 12 commits intowolfSSL:masterfrom
sebastian-carpenter:GH-10068
Apr 22, 2026
Merged

Fixes: for GH #10068#10094
JacobBarthelmeh merged 12 commits intowolfSSL:masterfrom
sebastian-carpenter:GH-10068

Conversation

@sebastian-carpenter
Copy link
Copy Markdown
Contributor

@sebastian-carpenter sebastian-carpenter commented Mar 27, 2026

Description

Various fixes related to GH #10068.

  • Increased client hello lengths in WOLFSSL_ECH struct to be word32. This wasn't necessary but seems to follow our convention better
  • The error from GetMsgHash was trampled. Fixed the checks. Added a check for when it returns 0 too (not sure if this was intentionally not checked)
  • Added NULL check. Not sure how important this is but it's good defense.
  • Mirrored arguments over to wc_HpkeContextOpenBase since *SealBase had them.
  • ech->type is changed to EHC_TYPE_INNER but on error may not be changed back to ECH_TYPE_OUTER. May cause propagating issues so I restored the value in each return.
  • Optimization: verify key length is exactly equal when setting the key so it doesn't fail later.

Testing

Broke api negative testing (with NULL parameters) into a standalone function. So far I have only written negative tests for what was in hpke_test_single but at some point all the other public hpke api's should be added too.

Checklist

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

@sebastian-carpenter sebastian-carpenter self-assigned this Mar 27, 2026
Copilot AI review requested due to automatic review settings March 27, 2026 21:09
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Targets multiple ECH-related fixes for GH #10068, focusing on correcting length handling, error propagation, and defensive validation to prevent ECH/HPKE misuse and state inconsistencies.

Changes:

  • Widened ECH length fields (aadLen, innerClientHelloLen) to word32 and updated related parsing/expansion logic.
  • Fixed GetMsgHash() error handling (including 0 return) and added ECH NULL checks and state restoration on error paths.
  • Hardened HPKE/ECH config validation (e.g., wc_HpkeContextOpenBase() NULL checks; enforce KEM-specific public key length in ECH config parsing).

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
wolfssl/internal.h Updates ECH struct field widths to avoid truncation issues.
wolfcrypt/src/hpke.c Adds stricter argument validation to wc_HpkeContextOpenBase().
src/tls13.c Fixes ECH acceptance hashing error propagation; restores ECH type on error; adds ECH extension NULL checks.
src/tls.c Adjusts ECH write/parse paths for widened lengths and safer parsing.
src/ssl_ech.c Validates ECH config HPKE public key length against KEM-specific expected length.
Comments suppressed due to low confidence (1)

src/tls.c:13682

  • ech->innerClientHelloLen is now word32, but it is serialized into the ECH extension using a forced cast to word16. If innerClientHelloLen exceeds 65535 (the case this PR is addressing), the value written on the wire will be truncated while the code still writes innerClientHelloLen bytes of payload (and TLSX_ECH_GetSize() also sizes using the full word32). Add an explicit bounds check and fail (or clamp consistently) when innerClientHelloLen > 0xFFFF before calling c16toa(), rather than truncating.
            /* innerClientHelloLen */
            c16toa((word16)ech->innerClientHelloLen, writeBuf_p);
            writeBuf_p += 2;
            /* set payload offset for when we finalize */
            ech->outerClientPayload = writeBuf_p;
            /* write zeros for payload */
            XMEMSET(writeBuf_p, 0, ech->innerClientHelloLen);
            writeBuf_p += ech->innerClientHelloLen;

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/tls13.c
Comment thread wolfcrypt/src/hpke.c Outdated
@sebastian-carpenter
Copy link
Copy Markdown
Contributor Author

sebastian-carpenter commented Mar 30, 2026

Jenkins retest this please.

@sebastian-carpenter sebastian-carpenter added For This Release Release version 5.9.1 and removed For This Release Release version 5.9.1 labels Apr 2, 2026
Copilot AI review requested due to automatic review settings April 7, 2026 16:56
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Comments suppressed due to low confidence (1)

wolfcrypt/test/test.c:1

  • The new negative-API coverage is valuable, but the repeated pattern (call, compare to BAD_FUNC_ARG, then translate/reset ret) is duplicated many times in hpke_test_api. To make it easier to extend coverage to more HPKE APIs (as noted in the PR description) and reduce copy/paste risk, consider factoring this into a small helper (e.g., a local function or macro like EXPECT_BAD_FUNC_ARG(expr) that sets ret appropriately).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/tls.c
Comment thread src/ssl_ech.c Outdated
Comment thread src/tls13.c
@sebastian-carpenter
Copy link
Copy Markdown
Contributor Author

sebastian-carpenter commented Apr 7, 2026

Jenkins retest this please.

Copy link
Copy Markdown
Member

@dgarske dgarske left a comment

Choose a reason for hiding this comment

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

🐺 Skoll Code Review

Overall recommendation: APPROVE
Findings: 5 total — 5 posted, 0 skipped

Posted findings

  • [Medium] Incomplete fix: ech->type not restored on TLSX_GetRequestSize error returnsrc/tls13.c:4757-4763
  • [Low] Incomplete fix: type = 0 not updated to ECH_TYPE_OUTER for consistencysrc/tls13.c:4766
  • [Medium] No truncation guard on c16toa after widening innerClientHelloLen to word32src/tls.c:13699
  • [Medium] Missing negative tests for changed HPKE context functionswolfcrypt/test/test.c:32182
  • [Medium] SetEchConfigsEx: wc_HpkeKemGetEncLen returns 0 for unsupported KEM, redundant with hpkePubkeyLen == 0 checksrc/ssl_ech.c:551-553

Review generated by Skoll via openclaw

Comment thread src/tls13.c Outdated
Comment thread src/tls13.c Outdated
Comment thread src/tls.c
Comment thread wolfcrypt/test/test.c Outdated
Comment thread src/ssl_ech.c Outdated
test for overflow
more consistency in setting ech->type
simpler hpke check when parsing ech config
negative testing for hpke api's
rejection tests for hpke
Copilot AI review requested due to automatic review settings April 10, 2026 21:04
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (1)

src/tls13.c:5720

  • acceptOffset is derived from ((WOLFSSL_ECH*)args->echX->data)->confBuf - input without validating that confBuf is non-NULL and actually points within the current input buffer. Since EchCheckAcceptance() uses input + acceptOffset directly, an invalid/stale confBuf can lead to out-of-bounds reads during hashing/compare. Add bounds checks (e.g., ensure confBuf >= input and confBuf + ECH_ACCEPT_CONFIRMATION_SZ <= input + helloSz + headerSz) and return a clean error when the offset is invalid.
        /* account for hrr extension instead of server random */
        if (args->extMsgType == hello_retry_request) {
            args->acceptOffset =
                (word32)(((WOLFSSL_ECH*)args->echX->data)->confBuf - input);
            args->acceptLabel = (byte*)echHrrAcceptConfirmationLabel;

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/ssl_ech.c
Comment thread src/tls13.c
@sebastian-carpenter
Copy link
Copy Markdown
Contributor Author

sebastian-carpenter commented Apr 10, 2026

Jenkins retest this please.

@sebastian-carpenter sebastian-carpenter removed their assignment Apr 14, 2026
Copy link
Copy Markdown

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Choose a reason for hiding this comment

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

Fenrir Automated Review — PR #10094

Scan targets checked: wolfcrypt-api_misuse, wolfcrypt-bugs, wolfcrypt-compliance, wolfcrypt-concurrency, wolfcrypt-consttime, wolfcrypt-defaults, wolfcrypt-mutation, wolfcrypt-portability, wolfcrypt-proptest, wolfcrypt-src, wolfcrypt-zeroize, wolfssl-bugs, wolfssl-compliance, wolfssl-consttime, wolfssl-defaults, wolfssl-mutation, wolfssl-proptest, wolfssl-src, wolfssl-zeroize

Findings: 1
1 finding(s) posted as inline comments (see file-level comments below)

This review was generated automatically by Fenrir. Findings are non-blocking.

Comment thread src/tls.c
Copilot AI review requested due to automatic review settings April 15, 2026 15:31
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions
Copy link
Copy Markdown

MemBrowse Memory Report

No memory changes detected for:

@sebastian-carpenter sebastian-carpenter removed their assignment Apr 16, 2026
@JacobBarthelmeh JacobBarthelmeh merged commit bc4bec6 into wolfSSL:master Apr 22, 2026
432 of 436 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.

7 participants