Skip to content

[3.10] gh-144833: Fix use-after-free in SSL module when SSL_new() fails (GH-144843)#144862

Open
miss-islington wants to merge 1 commit intopython:3.10from
miss-islington:backport-c91638c-3.10
Open

[3.10] gh-144833: Fix use-after-free in SSL module when SSL_new() fails (GH-144843)#144862
miss-islington wants to merge 1 commit intopython:3.10from
miss-islington:backport-c91638c-3.10

Conversation

@miss-islington
Copy link
Contributor

@miss-islington miss-islington commented Feb 16, 2026

In newPySSLSocket(), when SSL_new() returns NULL, Py_DECREF(self)
was called before _setSSLError(get_state_ctx(self), ...), causing
a use-after-free. Additionally, get_state_ctx() was called with
self (PySSLSocket*) instead of sslctx (PySSLContext*), which is
a type confusion bug.

Fix by calling _setSSLError() before Py_DECREF() and using
sslctx instead of self for get_state_ctx().
(cherry picked from commit c91638c)

Co-authored-by: Ramin Farajpour Cami ramin.blackhat@gmail.com

pythonGH-144843)

In newPySSLSocket(), when SSL_new() returns NULL, Py_DECREF(self)
was called before _setSSLError(get_state_ctx(self), ...), causing
a use-after-free. Additionally, get_state_ctx() was called with
self (PySSLSocket*) instead of sslctx (PySSLContext*), which is
a type confusion bug.

Fix by calling _setSSLError() before Py_DECREF() and using
sslctx instead of self for get_state_ctx().
(cherry picked from commit c91638c)

Co-authored-by: Ramin Farajpour Cami <ramin.blackhat@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Development

Successfully merging this pull request may close these issues.

4 participants