Skip to content

Fix dangling secure_renegotiation pointer after TLSX_FreeAll#10210

Draft
ColtonWilley wants to merge 1 commit intowolfSSL:masterfrom
ColtonWilley:fix-scr-dangling-ptr-after-tlsx-freeall
Draft

Fix dangling secure_renegotiation pointer after TLSX_FreeAll#10210
ColtonWilley wants to merge 1 commit intowolfSSL:masterfrom
ColtonWilley:fix-scr-dangling-ptr-after-tlsx-freeall

Conversation

@ColtonWilley
Copy link
Copy Markdown
Contributor

Summary

  • ssl->secure_renegotiation caches a pointer into extension data owned by the ssl->extensions list. Three call sites free that list via TLSX_FreeAll without NULLing the cached pointer, leaving it dangling: wolfSSL_clear(), FreeHandshakeResources(), and wolfSSL_ResourceFree().
  • After wolfSSL_clear(), calling wolfSSL_SSL_get_secure_renegotiation_support() reads the freed SecureRenegotiation struct. Confirmed heap-use-after-free under ASan with nginx, haproxy, and openssl-compat build profiles.
  • NULL the pointer at all three sites. Add regression test covering the wolfSSL_clear path.

Test plan

  • Existing CI passes
  • New test_wolfSSL_clear_secure_renegotiation passes
  • ASan build does not report heap-use-after-free on the wolfSSL_clear → wolfSSL_SSL_get_secure_renegotiation_support sequence

ssl->secure_renegotiation caches a pointer into extension data owned by
the ssl->extensions list. Three call sites free that list via TLSX_FreeAll
without NULLing the cached pointer, leaving it dangling:

- wolfSSL_clear()
- FreeHandshakeResources() (TLSX_FreeAll branch)
- wolfSSL_ResourceFree()

After wolfSSL_clear(), calling wolfSSL_SSL_get_secure_renegotiation_support()
reads the freed SecureRenegotiation struct. Confirmed heap-use-after-free
under ASan with nginx, haproxy, and openssl-compat build profiles.

NULL the pointer at all three sites. Add regression test covering the
wolfSSL_clear path.
@ColtonWilley ColtonWilley marked this pull request as draft April 13, 2026 21:57
@mattia-moffa mattia-moffa self-assigned this Apr 15, 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.

2 participants