Skip to content

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
wolfSSL:masterfrom
kareem-wolfssl:zd22232_42_63
Open

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
kareem-wolfssl wants to merge 3 commits into
wolfSSL:masterfrom
kareem-wolfssl:zd22232_42_63

Conversation

@kareem-wolfssl

Copy link
Copy Markdown
Contributor

Description

Fixes zd#22232, zd#22242, zd#22263

Testing

Built in tests, provided reproducers

Checklist

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

Thanks to Clouditera Security; Z.ai Security; NSFOCUS for the report.
Thanks to Ravikanth Reddy Gudipati for the report.
@kareem-wolfssl kareem-wolfssl self-assigned this Aug 3, 2026
Copilot AI review requested due to automatic review settings August 3, 2026 20:35

Copilot AI left a comment

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.

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 thread src/ssl_sess.c
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
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.

3 participants