Skip to content

fix: drop redundant XMEMSET before XMSS Init#265

Open
MarkAtwood wants to merge 1 commit into
wolfSSL:mainfrom
MarkAtwood:fix/xmss-redundant-memset
Open

fix: drop redundant XMEMSET before XMSS Init#265
MarkAtwood wants to merge 1 commit into
wolfSSL:mainfrom
MarkAtwood:fix/xmss-redundant-memset

Conversation

@MarkAtwood

Copy link
Copy Markdown

Bug: In both XMSS sign functions in src/sign-verify/clu_sign.c, the key struct is zeroized with XMEMSET(key, 0, sizeof(XmssKey)) immediately before calling wc_XmssKey_Init(key, HEAP_HINT, 0). This memset is redundant and reorder-fragile.

Fix: wc_XmssKey_Init() already zeroizes the entire struct via ForceZero(key, sizeof(XmssKey)) before setting heap/devId/state (see wolfcrypt/src/wc_xmss.c). The manual XMEMSET is fully redundant, so it is removed at both sites; the comment is kept and annotated. No behavior change — Init self-zeroizes.

Build-verified: compiled the affected translation unit against a wolfSSL install with -DWOLFSSL_HAVE_XMSS (the config where this block is live); compiles clean (exit 0), object shows the expected U wc_XmssKey_Init reference.

Reported by static analysis (Fenrir finding 581).

Copilot AI review requested due to automatic review settings July 9, 2026 23:47

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

Note

Copilot couldn't run its full agentic review because no GitHub Actions runner was available. Make sure your repository has a runner available to run Copilot's review, or add a copilot-setup-steps.yml file specifying one with the runs-on attribute. See the docs for more details.

Removes redundant zero-initialization of XmssKey structs immediately before wc_XmssKey_Init(), relying on the init function’s internal zeroization to avoid reorder-fragility while preserving behavior.

Changes:

  • Deleted XMEMSET(key, 0, sizeof(XmssKey)) before wc_XmssKey_Init() in wolfCLU_sign_data_xmss().
  • Deleted XMEMSET(key, 0, sizeof(XmssKey)) before wc_XmssKey_Init() in wolfCLU_sign_data_xmssmt().
  • Updated the nearby comments to document that wc_XmssKey_Init() zeroizes the struct internally.

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

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