Fix dangling secure_renegotiation pointer after TLSX_FreeAll#10210
Open
ColtonWilley wants to merge 3 commits intowolfSSL:masterfrom
Open
Fix dangling secure_renegotiation pointer after TLSX_FreeAll#10210ColtonWilley wants to merge 3 commits intowolfSSL:masterfrom
ColtonWilley wants to merge 3 commits intowolfSSL:masterfrom
Conversation
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.
Contributor
|
Jenkins retest this please |
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a use-after-free where ssl->secure_renegotiation could dangle after TLSX_FreeAll() frees the extensions list that owns the underlying SecureRenegotiation struct.
Changes:
- Clear
ssl->secure_renegotiationwhenwolfSSL_clear()freesssl->extensionsviaTLSX_FreeAll(). - Clear
ssl->secure_renegotiation(and also NULLssl->extensions) whenwolfSSL_ResourceFree()andFreeHandshakeResources()free the extensions list. - Add a regression test covering the
wolfSSL_clear() -> wolfSSL_SSL_get_secure_renegotiation_support()sequence.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| tests/api.c | Adds regression test to ensure secure_renegotiation is cleared by wolfSSL_clear() and the query API behaves safely afterward. |
| src/ssl.c | Clears ssl->secure_renegotiation when wolfSSL_clear() frees the extensions list. |
| src/internal.c | Clears ssl->secure_renegotiation (and NULLs ssl->extensions) in additional cleanup paths that free the extensions list. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ssl->secure_renegotiationcaches a pointer into extension data owned by thessl->extensionslist. Three call sites free that list viaTLSX_FreeAllwithout NULLing the cached pointer, leaving it dangling:wolfSSL_clear(),FreeHandshakeResources(), andwolfSSL_ResourceFree().wolfSSL_clear(), callingwolfSSL_SSL_get_secure_renegotiation_support()reads the freedSecureRenegotiationstruct. Confirmed heap-use-after-free under ASan with nginx, haproxy, and openssl-compat build profiles.wolfSSL_clearpath.Test plan
test_wolfSSL_clear_secure_renegotiationpasses