]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-144833: Fix use-after-free in SSL module when SSL_new() fails (GH-144843)
authorRamin Farajpour Cami <ramin.blackhat@gmail.com>
Mon, 16 Feb 2026 02:43:07 +0000 (06:13 +0330)
committerGitHub <noreply@github.com>
Mon, 16 Feb 2026 02:43:07 +0000 (18:43 -0800)
commitc91638ca0671b8038831f963ed44e66cdda006a2
tree74ec2f2315fecd8d0c2a70048eec12f2411b0b39
parent300de1e98ac236bc887b49c0fbd7398266237b36
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().
Misc/NEWS.d/next/Library/2026-02-15-00-00-00.gh-issue-144833.TUelo1.rst [new file with mode: 0644]
Modules/_ssl.c