Skip to content

Zero AllocKey's allocation so its failure path cannot free garbage#10873

Closed
PhilipTaronQ wants to merge 1 commit into
wolfSSL:masterfrom
PhilipTaronQ:zero-allockey-allocation
Closed

Zero AllocKey's allocation so its failure path cannot free garbage#10873
PhilipTaronQ wants to merge 1 commit into
wolfSSL:masterfrom
PhilipTaronQ:zero-allockey-allocation

Conversation

@PhilipTaronQ

Copy link
Copy Markdown

Description

AllocKey hands FreeKey a never-initialized key whenever the type's init function fails: the allocation comes straight from XMALLOC, and e.g. wc_FreeRsaKey then walks uninitialized multiprecision integers whose length fields are garbage. AddressSanitizer caught sp_clear doing a 390KB memset past the allocation during a TLS 1.3 handshake whose wc_InitRsaKey failed transiently (a FIPS known-answer-test error), so a recoverable handshake error becomes... heap corruption.

Zero the key after allocation; every wc_Free* implementation treats an all-zero key as empty.

Testing

I built the Qumulo product with this patch; prior to that, we had sporadic ASAN failures.

Checklist

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

AllocKey hands FreeKey a never-initialized key whenever the type's init
function fails: the allocation comes straight from XMALLOC, and e.g.
wc_FreeRsaKey then walks uninitialized multiprecision integers whose
length fields are garbage. AddressSanitizer caught sp_clear doing a
390KB memset past the allocation during a TLS 1.3 handshake whose
wc_InitRsaKey failed transiently (a FIPS known-answer-test error), so a
recoverable handshake error becomes heap corruption.

Zero the key after allocation; every wc_Free* implementation treats an
all-zero key as empty.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@wolfSSL-Bot

Copy link
Copy Markdown

Can one of the admins verify this patch?

@dgarske

dgarske commented Jul 9, 2026

Copy link
Copy Markdown
Member

ZD 22133

@dgarske

dgarske commented Jul 9, 2026

Copy link
Copy Markdown
Member

Hi @PhilipTaronQ , thank you for this suggested fix. For items that are small like this its easier to support a bug report by emailing support@wolfssl.com or adding to your existing zendesk ticket 22133. Also we can't accept commits with co-author of AI. Thanks, David Garske, wolfSSL

@dgarske dgarske closed this Jul 9, 2026
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