Miggo Logo

CVE-2024-0397: A defect was discovered in the Python “ssl” module where there is a memory race condition with...

7.4

CVSS Score
3.1

Basic Information

EPSS Score
0.59506%
Published
6/17/2024
Updated
4/12/2025
KEV Status
No
Technology
-

Technical Details

CVSS Vector
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:N/A:H

Vulnerability Intelligence
Miggo AIMiggo AI

Miggo AIRoot Cause Analysis

The vulnerability description explicitly identifies a memory race condition in the Python ssl module's ssl.SSLContext.cert_store_stats() and ssl.SSLContext.get_ca_certs() methods. The provided commit patches (e.g., bce693111bff906ccf9281c22371331aaff766ab and its cherry-picks) modify the C implementation functions for these methods, namely _ssl__SSLContext_cert_store_stats_impl and _ssl__SSLContext_get_ca_certs_impl located in Modules/_ssl.c.

The core of the vulnerability was the use of X509_STORE_get0_objects(store) to access certificate objects. This function returns internal pointers without ensuring thread safety if the store is modified concurrently. The patches replace this call with X509_STORE_get1_objects(store). This newer OpenSSL function (or a polyfill provided in the patch for older OpenSSL versions) ensures thread-safe access by either returning a deep copy of the objects or by locking the store (X509_STORE_lock and X509_STORE_unlock) during the operation of copying the objects (sk_X509_OBJECT_deep_copy).

Thus, the Python methods ssl.SSLContext.cert_store_stats and ssl.SSLContext.get_ca_certs are identified as vulnerable because their C implementations contained the race condition. These are the functions that would appear in a Python runtime profile when the vulnerability is triggered. The patch evidence directly shows the code change that mitigates this race condition within the C functions corresponding to these Python methods.

Vulnerable functions

Only Mi**o us*rs **n s** t*is s**tion

WAF Protection Rules

WAF Rule

* *****t w*s *is*ov*r** in t** Pyt*on “ssl” mo*ul* w**r* t**r* is * m*mory r*** *on*ition wit* t** ssl.SSL*ont*xt m*t*o*s “**rt_stor*_st*ts()” *n* “**t_**_**rts()”. T** r*** *on*ition **n ** tri***r** i* t** m*t*o*s *r* **ll** *t t** s*m* tim* *s **r

Reasoning

T** vuln*r**ility **s*ription *xpli*itly i**nti*i*s * m*mory r*** *on*ition in t** Pyt*on `ssl` mo*ul*'s `ssl.SSL*ont*xt.**rt_stor*_st*ts()` *n* `ssl.SSL*ont*xt.**t_**_**rts()` m*t*o*s. T** provi*** *ommit p*t***s (*.*., *****************************