ext/openssl: Free prior SSL_SESSION on Openssl\Session::__unserialize#22040
Closed
iliaal wants to merge 1 commit into
Closed
ext/openssl: Free prior SSL_SESSION on Openssl\Session::__unserialize#22040iliaal wants to merge 1 commit into
iliaal wants to merge 1 commit into
Conversation
ndossche
reviewed
Jun 15, 2026
ndossche
left a comment
Member
There was a problem hiding this comment.
I wonder if calling __unserialize directly like this shouldn't simply be blocked.
Could have a check at start for obj->session != NULL and then throw if it isn't NULL. I wonder if there's a legitimate use-case for calling __unserialize directly. I'd rather just shut down a footgun.
Calling __unserialize() on an Openssl\Session that already holds an SSL_SESSION overwrote obj->session without freeing the prior one, leaking an SSL_SESSION (OpenSSL's allocator, bypasses memory_limit). There is no legitimate use for re-running __unserialize() on a live instance, so reject it: throw when obj->session is already populated, before any overwrite. Closes phpGH-22040
7220e28 to
5ebc4a9
Compare
Contributor
Author
|
Agreed, better to shut the footgun. Throwing on |
ndossche
approved these changes
Jun 16, 2026
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.
Openssl\Session::__unserialize()overwroteobj->sessionwithout freeing the previousSSL_SESSIONwhen called a second time on the same instance, leaking anSSL_SESSION. These live in OpenSSL's allocator and bypassmemory_limit, so a long-running worker that hits the repeat path accumulates an unbounded leak. There's no legitimate reason to re-run__unserialize()on a live instance, so it now throws whenobj->sessionis already populated, before any overwrite.