Open
Conversation
Contributor
There was a problem hiding this comment.
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) toword32and updated related parsing/expansion logic. - Fixed
GetMsgHash()error handling (including0return) 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->innerClientHelloLenis nowword32, but it is serialized into the ECH extension using a forced cast toword16. IfinnerClientHelloLenexceeds 65535 (the case this PR is addressing), the value written on the wire will be truncated while the code still writesinnerClientHelloLenbytes of payload (andTLSX_ECH_GetSize()also sizes using the fullword32). Add an explicit bounds check and fail (or clamp consistently) wheninnerClientHelloLen > 0xFFFFbefore callingc16toa(), 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.
Contributor
Author
|
Jenkins retest this please. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Various fixes related to GH #10068.
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_singlebut at some point all the other public hpke api's should be added too.Checklist