]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
[3.13] gh-144833: Fix use-after-free in SSL module when SSL_new() fails (GH-144843...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Mon, 16 Feb 2026 03:09:58 +0000 (04:09 +0100)
committerGitHub <noreply@github.com>
Mon, 16 Feb 2026 03:09:58 +0000 (03:09 +0000)
commit37f818caef77ac78328094ea2b815788374adf06
tree80f6738a04e211671ed62f3f3d2b8e25c0db3452
parente1dbe2263ae23f17ec28f3f1a641578819c9d09a
[3.13] gh-144833: Fix use-after-free in SSL module when SSL_new() fails (GH-144843) (#144859)

gh-144833: Fix use-after-free in SSL module when SSL_new() fails (GH-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 c91638ca0671b8038831f963ed44e66cdda006a2)

Co-authored-by: Ramin Farajpour Cami <ramin.blackhat@gmail.com>
Misc/NEWS.d/next/Library/2026-02-15-00-00-00.gh-issue-144833.TUelo1.rst [new file with mode: 0644]
Modules/_ssl.c