Skip to content

F-7450: Wipe the ECCSI SSK in wc_FreeEccsiKey - #11998

Open
stenslae wants to merge 2 commits into
wolfSSL:masterfrom
stenslae:fix/eccsi-free-forcezero-ssk
Open

stenslae wants to merge 2 commits into
wolfSSL:masterfrom
stenslae:fix/eccsi-free-forcezero-ssk

Conversation

@stenslae

@stenslae stenslae commented Nov 4, 2026

Copy link
Copy Markdown
Member

Description

  • Updated wc_FreeEccsiKey to call mp_forcezero() on key->ssk and key->tmp instead of mp_free()
  • Added test_wc_Eccsi_FreeZeroizesSsk to test_eccsi.c to verify that the SSK buffer is zeroed out before being released back to the heap.

Testing

Built --enable-all-crypto --enable-heapmath and passed test suite with updated tests.

Checklist

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

@stenslae stenslae self-assigned this Nov 4, 2026
Copilot AI balanced review requested due to automatic review settings November 4, 2026 20:13
@stenslae

stenslae commented Nov 4, 2026

Copy link
Copy Markdown
Member Author

@claude review

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.

🟡 Changes recommended

The test’s allocator hooks can cause invalid accesses or frees during ECC cache cleanup, and its wipe watcher falsely fails when memory-zero checking adds an allocation prefix.

2 open issues
What changed in this PR

This PR strengthens ECCSI key cleanup by wiping sensitive multiprecision values and adds a regression test for secret signing key (SSK) zeroization.

Changes:

  • Replace mp_free() with mp_forcezero() for the SSK and temporary value.
  • Add and register a heap-math test that inspects the SSK buffer before release.
File Description
wolfcrypt/​src/​eccsi.c Wipes the SSK and temporary value during key cleanup.
tests/​api/​test_eccsi.h Declares and registers the zeroization test.
tests/​api/​test_eccsi.c Adds allocator hooks to verify the SSK is wiped before release.

Review effort: Balanced

Comment thread tests/api/test_eccsi.c Resolved
Comment thread tests/api/test_eccsi.c Resolved
@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nothing blocking. The comments below are optional suggestions. There is no need to push a fix for them before merging.

Beyond the inline finding on the test, I also checked the library change in wc_FreeEccsiKey. mp_forcezero exists for all three math backends: sp_int, tfm and integer.c. In heap math it still calls mp_free after zeroing, so switching from mp_free does not leak the ssk/tmp buffers.

Extended reasoning...

The change in wolfcrypt/src/eccsi.c replaces mp_free with mp_forcezero for the ECCSI SSK and tmp, and adds an allocator-hook test. I checked that mp_forcezero is defined for every math backend and still frees heap memory in integer.c.

Comment thread tests/api/test_eccsi.c Resolved

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Fenrir Automated Review — PR #11998

Scan targets checked: wolfcrypt-src, wolfcrypt-bugs, wolfssl-bugs
Not reviewed (no scan target covers them): tests/api/test_eccsi.h
Coverage: 2 of 2 in-scope changed file(s) opened by the reviewer

Fenrir result: Approved ✅

No new issues found in the changed files.

Advisory only — this automated result does not count as a GitHub approval.

Review tier: Lite

@stenslae
stenslae force-pushed the fix/eccsi-free-forcezero-ssk branch from 70dd9b8 to 0747760 Compare November 4, 2026 20:22
@stenslae
stenslae requested review from wolfSSL-Fenrir-bot and a balanced review from Copilot November 4, 2026 20:22
@stenslae

stenslae commented Nov 4, 2026

Copy link
Copy Markdown
Member Author

@claude review

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.

🟢 Approval recommended

No active review issues remain for the ECCSI key-cleanup changes and accompanying zeroization regression test.

No open issues 🎉

2 resolved since last review

Review effort: Balanced

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Fenrir Automated Review — PR #11998

Scan targets checked: wolfssl-bugs
Unchanged since last review (not re-run): wolfcrypt-src, wolfcrypt-bugs
Not reviewed (no scan target covers them): tests/api/test_eccsi.h
Coverage: 1 of 1 in-scope changed file(s) opened by the reviewer

Fenrir result: Approved ✅

No new issues found in the changed files.

Advisory only — this automated result does not count as a GitHub approval.

Review tier: Lite

@stenslae
stenslae force-pushed the fix/eccsi-free-forcezero-ssk branch from 0747760 to 841150b Compare November 4, 2026 20:27
@stenslae
stenslae requested review from wolfSSL-Fenrir-bot and a balanced review from Copilot November 4, 2026 20:27

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code review found no issues

No high-confidence issues detected in this change.

This review covers commit 0747760, which is no longer the latest commit on this pull request; later commits are not covered by it.

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Fenrir Automated Review — PR #11998

Scan targets checked: wolfssl-bugs
Unchanged since last review (not re-run): wolfcrypt-src, wolfcrypt-bugs
Not reviewed (no scan target covers them): tests/api/test_eccsi.h
Coverage: 0 of 1 in-scope changed file(s) opened by the reviewer; not opened: tests/api/test_eccsi.c

Fenrir result: Approved ✅

No new issues found in the changed files.

Advisory only — this automated result does not count as a GitHub approval.

Review tier: Lite

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.

🟡 Changes recommended

The test guard includes heap-math FREERTOS and FREERTOS_TCP configurations without WOLFSSL_TRACK_MEMORY, where XFREE bypasses callbacks and causes false failures even when the SSK is correctly wiped.

1 open issue

Review effort: Balanced

Comment thread tests/api/test_eccsi.c Resolved
@stenslae
stenslae force-pushed the fix/eccsi-free-forcezero-ssk branch from 841150b to 683359b Compare November 4, 2026 20:35
@stenslae
stenslae requested review from wolfSSL-Fenrir-bot and a balanced review from Copilot November 4, 2026 20:35

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Fenrir Automated Review — PR #11998

Scan targets checked: wolfssl-bugs
Unchanged since last review (not re-run): wolfcrypt-src, wolfcrypt-bugs
Not reviewed (no scan target covers them): tests/api/test_eccsi.h
Coverage: 1 of 1 in-scope changed file(s) opened by the reviewer

Fenrir result: Approved ✅

No new issues found in the changed files.

Advisory only — this automated result does not count as a GitHub approval.

Review tier: Lite

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.

🟡 Changes recommended

The callback-based test incorrectly runs under HAVE_IO_POOL or WOLFSSL_EMBOS, where XFREE bypasses allocator callbacks and causes false failures despite correct zeroization.

1 open issue
1 resolved since last review

Review effort: Balanced

Comment thread tests/api/test_eccsi.c Resolved
@stenslae
stenslae force-pushed the fix/eccsi-free-forcezero-ssk branch from 683359b to df9ce1a Compare November 4, 2026 21:09

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.

🟢 Approval recommended

No active review issues are reported for the ECCSI key-cleanup hardening and SSK zeroization regression test.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Fenrir Automated Review — PR #11998

Scan targets checked: wolfssl-bugs
Unchanged since last review (not re-run): wolfcrypt-src, wolfcrypt-bugs
Not reviewed (no scan target covers them): tests/api/test_eccsi.h
Coverage: 1 of 1 in-scope changed file(s) opened by the reviewer

Fenrir result: Approved ✅

No new issues found in the changed files.

Advisory only — this automated result does not count as a GitHub approval.

Review tier: Lite

@stenslae stenslae assigned wolfSSL-Bot and unassigned stenslae Nov 4, 2026
Comment thread wolfcrypt/src/eccsi.c Outdated
mp_free(&key->ssk);
mp_free(&key->tmp);
mp_forcezero(&key->ssk);
mp_forcezero(&key->tmp);

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.

When does key->tmp hold sensitive data.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It doesn't, so I put it back to mp_free. Only the SSK is wiped now.

Comment thread wolfcrypt/src/eccsi.c
#ifdef WOLFCRYPT_ECCSI_CLIENT
mp_free(&key->ssk);
mp_free(&key->tmp);
mp_forcezero(&key->ssk);

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.

Add a WOLFSSL_CHECK_MEM_ZERO check.
When private data is put into key->ssk or key->tmp, call mp_memzero_add().

Emma Stensland added 2 commits November 6, 2026 13:16
@stenslae
stenslae force-pushed the fix/eccsi-free-forcezero-ssk branch from df9ce1a to d0dfa93 Compare November 6, 2026 20:17
@stenslae
stenslae requested review from wolfSSL-Fenrir-bot and a balanced review from Copilot November 6, 2026 20:23
@stenslae

stenslae commented Nov 6, 2026

Copy link
Copy Markdown
Member Author

@claude review

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.

🟢 Approval recommended

No active review issues are reported for the SSK memory-zeroization change.

No open issues 🎉

Review effort: Balanced

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code review found no issues

No high-confidence issues detected in this change.

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Fenrir Automated Review — PR #11998

Scan targets checked: wolfcrypt-src, wolfcrypt-bugs, wolfssl-bugs
Not reviewed (no scan target covers them): tests/api/test_eccsi.h
Coverage: 2 of 2 in-scope changed file(s) opened by the reviewer

Fenrir result: Approved ✅

No new issues found in the changed files.

Advisory only — this automated result does not count as a GitHub approval.

Review tier: Max

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.

5 participants