Fully clear ECC k when calling wc_ecc_sign_hash_ex with SP math. Avoid aliasing the ticket in wolfSSL_GetSessionAtIndex. Fix IAR warnings. - #11041
Open
kareem-wolfssl wants to merge 3 commits into
Conversation
Thanks to Clouditera Security; Z.ai Security; NSFOCUS for the report.
Thanks to Ravikanth Reddy Gudipati for the report.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses three reported issues by hardening sensitive ECC signing state handling in SP ECC paths, fixing unsafe aliasing when copying sessions out of the internal session cache, and resolving compile-time warnings/assumptions (incl. TLS 1.3 bounds logic and a Renesas TLS port include).
Changes:
- Clear/zeroize ECDSA signing nonce (
k) after SP ECC signing so backing digits aren’t left in memory. - Make
wolfSSL_GetSessionAtIndex()return an independent session copy (no aliasing of ticket buffers / cache-owned fields) and add an API test for the behavior. - Simplify TLS 1.3 ServerHello session-id bounds checking by asserting
ID_LEN == RAN_LEN, and add a Renesas TLS-port header include plus doxygen updates.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| wolfcrypt/src/ecc.c | Ensures key->sign_k is force-zeroed/freed after SP signing paths consume it. |
| src/ssl_sess.c | Switches session cache copying from struct memcpy to wolfSSL_DupSession() to avoid aliasing cache-owned pointers. |
| tests/api/test_session.c | Adds regression test covering wolfSSL_GetSessionAtIndex() deep-copy semantics (ticket/ex_data independence). |
| tests/api/test_session.h | Registers the new session-cache API test. |
| src/tls13.c | Removes redundant sessIdSz check by enforcing ID_LEN == RAN_LEN via wc_static_assert. |
| src/ssl_certman.c | Adds conditional Renesas common header include for TSIP/FSPSM TLS builds. |
| doc/dox_comments/header_files/ssl.h | Updates documentation for wolfSSL_GetSessionAtIndex() copy/ownership semantics and example usage. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+2274
to
+2285
| #ifdef HAVE_EX_DATA | ||
| /* The copy keeps its own ex_data. The struct copy below carries over | ||
| * the cache's pointers, which the cache frees when the entry goes. */ | ||
| WOLFSSL_CRYPTO_EX_DATA exData; | ||
| XMEMCPY(&exData, &session->ex_data, sizeof(exData)); | ||
| #endif | ||
| /* Must not alias the ticket, peer cert and ex_data the cache owns and | ||
| * frees on overwrite or eviction. */ | ||
| result = wolfSSL_DupSession(cacheSession, session, 0); | ||
| #ifdef HAVE_EX_DATA | ||
| XMEMCPY(&session->ex_data, &exData, sizeof(exData)); | ||
| #endif |
SparkiDev
approved these changes
Aug 3, 2026
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
Fixes zd#22232, zd#22242, zd#22263
Testing
Built in tests, provided reproducers
Checklist