Skip to content

Fix: WolfCrypt 7 fenrir fixes#10808

Merged
JacobBarthelmeh merged 1 commit into
wolfSSL:masterfrom
aidankeefe2022:fenrir-fixes-jun29-ak
Jul 17, 2026
Merged

Fix: WolfCrypt 7 fenrir fixes#10808
JacobBarthelmeh merged 1 commit into
wolfSSL:masterfrom
aidankeefe2022:fenrir-fixes-jun29-ak

Conversation

@aidankeefe2022

Copy link
Copy Markdown
Member

Description

Fixed a series of Fenrir issues that mostly pertained to alignment UB when reading byte arrays as various sizes of integers.

https://fenrir.wolfssl.com/finding/6438

FSPSM RSA private-decrypt never updates caller's *outLen (passes &outLen instead of outLen)

  • Swapped the double reference to just pass the outLen ptr

https://fenrir.wolfssl.com/finding/5414

SLH-DSA AVX2 x4 SHAKE helpers cast hash byte streams to word64

  • Changed from direct cast byte -> word64 / word64 -> byte to use Unaligned memory helpers

https://fenrir.wolfssl.com/finding/5415

ML-DSA little-endian pack/unpack paths cast encoded byte buffers to word pointers

  • Fixed a variety of possible alignment issues.

https://fenrir.wolfssl.com/finding/6165

scrypt scryptROMix big-endian Integerify shifts bytes without width cast (signed overflow/oversized shift on 16-bit int)

  • Explicitly cast all intermediate values to word32 to make sure that there is no chance of signed in overflow during bit shifting.

https://fenrir.wolfssl.com/finding/6166

wc_ecc_init_id (SE050) reinterprets byte id[] array as word32 via pointer cast

  • Used unaligned helper function to read byte array as word32

https://fenrir.wolfssl.com/finding/6167

XMSS hash-address byte buffers cast to word32* in address-encoding helpers (unaligned access / strict aliasing)

  • Removed cast to use endian independent operation that copies the byte value in to the last byte because the word is stored in network byte order

https://fenrir.wolfssl.com/finding/6177

PKCS#12 parse leaves decrypted SafeContents (incl. plaintext private KeyBag) in freed heap buffer

  • Added new variable to track temp buffer size and ForceZero it when it is freed

@aidankeefe2022 aidankeefe2022 self-assigned this Jun 29, 2026
@aidankeefe2022
aidankeefe2022 force-pushed the fenrir-fixes-jun29-ak branch from 4db6bea to 7719bc6 Compare June 29, 2026 22:24
@aidankeefe2022 aidankeefe2022 changed the title Fix: WolfCrypt 8 fenrir fixes Fix: WolfCrypt 7 fenrir fixes Jun 29, 2026

@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 #10808

Scan targets checked: wolfcrypt-bugs, wolfcrypt-port-bugs, wolfcrypt-src

No new issues found in the changed files. ✅

@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 #10808

Scan targets checked: wolfcrypt-bugs, wolfcrypt-port-bugs, wolfcrypt-src

No new issues found in the changed files. ✅

@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 #10808

Scan targets checked: wolfcrypt-bugs, wolfcrypt-port-bugs, wolfcrypt-src

No new issues found in the changed files. ✅

Frauschi
Frauschi previously approved these changes Jul 3, 2026
@Frauschi

Frauschi commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Jenkins retest this please

@Frauschi Frauschi 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.

LGTM

@aidankeefe2022

Copy link
Copy Markdown
Member Author

retest this please

@aidankeefe2022
aidankeefe2022 force-pushed the fenrir-fixes-jun29-ak branch from 791842d to 15d2b46 Compare July 16, 2026 17:01
@aidankeefe2022

Copy link
Copy Markdown
Member Author

retest this please

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 multiple Fenrir findings in wolfCrypt by removing undefined behavior caused by unaligned/aliasing-unsafe pointer casts when reading/writing integer types from byte buffers, and by fixing an output-length propagation bug in the Renesas FSPSM RSA private decrypt path.

Changes:

  • Reworked XMSS address byte-setting to use byte-wise stores instead of casting encoded address buffers to word32*.
  • Updated SLH-DSA AVX2 x4 SHAKE helpers to use readUnalignedWord64 / writeUnalignedWord64 instead of casting hash buffers to word64*.
  • Fixed scrypt big-endian Integerify shifts to avoid integer-promotion/shift UB, fixed SE050 ECC key-id reads using unaligned helpers, and corrected FSPSM RSA private decrypt to update the caller’s *outLen.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
wolfcrypt/src/wc_xmss_impl.c Removes word32* casting from encoded XMSS address manipulation to avoid unaligned access / strict-aliasing UB.
wolfcrypt/src/wc_slhdsa.c Replaces word64* casts in AVX2 x4 SHAKE hash buffer helpers with unaligned read/write helpers.
wolfcrypt/src/pwdbased.c Adds explicit word32 casts in scrypt big-endian Integerify composition to prevent shift/promotion UB.
wolfcrypt/src/port/Renesas/renesas_fspsm_rsa.c Fixes RSA private decrypt to pass the correct outLen pointer so the caller’s *outLen is updated.
wolfcrypt/src/ecc.c Uses readUnalignedWord32 to safely read SE050 key IDs from key->id without alignment/aliasing UB.

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

@JacobBarthelmeh
JacobBarthelmeh merged commit 25b5636 into wolfSSL:master Jul 17, 2026
376 of 378 checks passed
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.

6 participants