| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
There was a problem hiding this comment.
Do we test this private constructor actually?
Sorry, something went wrong.
|
Yes, we do test it in TestRawMersenneTwister in Lib/test/test_random.py :) |
Sorry, something went wrong.
|
Thanks @sobolevn for the PR 🌮🎉.. I'm working now to backport this PR to: 3.14, 3.15. |
Sorry, something went wrong.
|
GH-149997 is a backport of this pull request to the 3.15 branch. |
Sorry, something went wrong.
|
GH-149998 is a backport of this pull request to the 3.14 branch. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
I am not sure that it would be easy to repro / test in a real env, but it can be a potential problem.
Original description from 17.md:
Vulnerability #17
Title: Unlocked init races with PRNG state access
Category: Concurrency and Race Conditions
Tags: race,read,dos
CWEs: CWE-125, CWE-367
CVSS: CVSS:4.0/AV:L/AC:L/AT:P/PR:N/UI:N/VC:L/VI:N/VA:L/SC:N/SI:N/SA:N
Severity: Low (2.1)
Location: cpython/Modules/_randommodule.c:572:572 in function random_init
Description
random_init reseeds internal MT state by calling random_seed without acquiring the object critical section at cpython/Modules/_randommodule.c:572, while normal methods use Py_BEGIN_CRITICAL_SECTION(self) (e.g. cpython/Modules/clinic/_randommodule.c.h:26, cpython/Modules/clinic/_randommodule.c.h:139). During reseed, init_genrand writes self->index = N at cpython/Modules/_randommodule.c:212. A concurrent reader in genrand_uint32 can pass the bounds check self->index >= N at cpython/Modules/_randommodule.c:143 and then use a raced value at cpython/Modules/_randommodule.c:160, causing mt[624] access.
Trigger Conditions
Pre-conditions:
Data flow:
Impact
In the free-threaded runtime, this race introduces undefined behavior and a concrete out-of-bounds read on PRNG object state. Most severe outcomes are process crash (availability impact) or unintended memory disclosure via corrupted/random output, depending on allocator/layout and timing. Exploitability requires precise concurrency and access to concurrent method invocation on the same object, which lowers reliability but does not remove the bug.
Remediation
Reproduction
Code Context