CVE-2021-33430
Description
NumPy 1.9.x buffer overflow in PyArray_NewFromDescr_int when arrays with >32 dimensions are created via complex structured dtypes, leading to denial of service.
AI Insight
LLM-synthesized narrative grounded in this CVE's description and references.
NumPy 1.9.x buffer overflow in PyArray_NewFromDescr_int when arrays with >32 dimensions are created via complex structured dtypes, leading to denial of service.
Vulnerability
A buffer overflow vulnerability exists in NumPy versions 1.9.x in the PyArray_NewFromDescr_int function within ctors.c [1][4]. The flaw occurs when an array with more than 32 dimensions is created from Python code, as the function uses fixed-size stack buffers (newdims and newstrides) of size 2*NPY_MAXDIMS (where NPY_MAXDIMS is 32) but passes the actual number of dimensions (nd) to memcpy without bounds checking [4]. The code path is triggered via calls such as array_new, PyArray_Zeros, or array_fromfile when processing arrays with subarray dtypes [4].
Exploitation
Exploitation requires an attacker to craft Python code that creates a NumPy array with more than 32 dimensions using the uncommon API of complicated structured dtypes [1]. The attacker must have the ability to execute arbitrary Python code and invoke NumPy's array creation functions with a high-dimension argument. No special network position or user interaction beyond running the malicious script is needed [1]. The buffer overflow is provoked by the memcpy operations copying nd*sizeof(npy_intp) bytes into a buffer that can only hold up to NPY_MAXDIMS entries [4].
Impact
A successful overflow can corrupt stack memory, potentially leading to a denial of service (DoS) via application crash [1][4]. The vendor disputes this as a vulnerability, arguing that: (a) triggering it requires an already-privileged attacker who can exhaust memory anyway, and (b) the use of uncommon structured dtype APIs makes exploitation very unlikely for unprivileged users [1]. No arbitrary code execution or information disclosure is known from this bug.
Mitigation
No official patch has been released for the 1.9.x branch, which is now end-of-life [1][2]. Users should upgrade to a supported NumPy version (e.g., 1.22 or later) that does not include this code path [2]. As a workaround, avoid creating arrays with more than 32 dimensions when using structured dtypes [1]. The vulnerability is not listed in CISA's Known Exploited Vulnerabilities catalog as of the last advisory.
AI Insight generated on May 21, 2026. Synthesized from this CVE's description and the cited reference URLs; citations are validated against the source bundle.
Affected packages
Versions sourced from the GitHub Security Advisory.
| Package | Affected versions | Patched versions |
|---|---|---|
numpyPyPI | >= 1.9.0, < 1.21 | 1.21 |
Affected products
71- NumPy/NumPydescription
- ghsa-coords70 versionspkg:pypi/numpypkg:rpm/opensuse/dxflib&distro=openSUSE%20Leap%2015.3pkg:rpm/opensuse/python2-numpy&distro=openSUSE%20Leap%2015.3pkg:rpm/opensuse/python-numba&distro=openSUSE%20Tumbleweedpkg:rpm/opensuse/python-numpy_1_16_5-gnu-hpc&distro=openSUSE%20Leap%2015.3pkg:rpm/opensuse/python-numpy_1_16_5-gnu-hpc&distro=openSUSE%20Leap%2015.4pkg:rpm/opensuse/python-numpy_1_17_3-gnu-hpc&distro=openSUSE%20Leap%2015.3pkg:rpm/opensuse/python-numpy1&distro=openSUSE%20Tumbleweedpkg:rpm/opensuse/python-numpy&distro=openSUSE%20Leap%2015.3pkg:rpm/opensuse/python-numpy&distro=openSUSE%20Tumbleweedpkg:rpm/suse/dxflib&distro=SUSE%20Package%20Hub%2015%20SP3pkg:rpm/suse/python2-numpy&distro=SUSE%20Enterprise%20Storage%206pkg:rpm/suse/python2-numpy&distro=SUSE%20Enterprise%20Storage%207pkg:rpm/suse/python2-numpy&distro=SUSE%20Linux%20Enterprise%20High%20Performance%20Computing%2015%20SP1-ESPOSpkg:rpm/suse/python2-numpy&distro=SUSE%20Linux%20Enterprise%20High%20Performance%20Computing%2015%20SP1-LTSSpkg:rpm/suse/python2-numpy&distro=SUSE%20Linux%20Enterprise%20High%20Performance%20Computing%2015%20SP2-ESPOSpkg:rpm/suse/python2-numpy&distro=SUSE%20Linux%20Enterprise%20High%20Performance%20Computing%2015%20SP2-LTSSpkg:rpm/suse/python2-numpy&distro=SUSE%20Linux%20Enterprise%20High%20Performance%20Computing%2015-ESPOSpkg:rpm/suse/python2-numpy&distro=SUSE%20Linux%20Enterprise%20High%20Performance%20Computing%2015-LTSSpkg:rpm/suse/python2-numpy&distro=SUSE%20Linux%20Enterprise%20Module%20for%20Python%202%2015%20SP3pkg:rpm/suse/python2-numpy&distro=SUSE%20Linux%20Enterprise%20Server%2015%20SP1-BCLpkg:rpm/suse/python2-numpy&distro=SUSE%20Linux%20Enterprise%20Server%2015%20SP1-LTSSpkg:rpm/suse/python2-numpy&distro=SUSE%20Linux%20Enterprise%20Server%2015%20SP2-LTSSpkg:rpm/suse/python2-numpy&distro=SUSE%20Linux%20Enterprise%20Server%2015-LTSSpkg:rpm/suse/python2-numpy&distro=SUSE%20Linux%20Enterprise%20Server%20for%20SAP%20Applications%2015pkg:rpm/suse/python2-numpy&distro=SUSE%20Linux%20Enterprise%20Server%20for%20SAP%20Applications%2015%20SP1pkg:rpm/suse/python2-numpy&distro=SUSE%20Linux%20Enterprise%20Server%20for%20SAP%20Applications%2015%20SP2pkg:rpm/suse/python2-numpy&distro=SUSE%20Manager%20Proxy%204.1pkg:rpm/suse/python2-numpy&distro=SUSE%20Manager%20Retail%20Branch%20Server%204.1pkg:rpm/suse/python2-numpy&distro=SUSE%20Manager%20Server%204.1pkg:rpm/suse/python-numpy_1_13_3-gnu-hpc&distro=SUSE%20Linux%20Enterprise%20Module%20for%20HPC%2012pkg:rpm/suse/python-numpy_1_16_5-gnu-hpc&distro=SUSE%20Linux%20Enterprise%20High%20Performance%20Computing%2015%20SP1-ESPOSpkg:rpm/suse/python-numpy_1_16_5-gnu-hpc&distro=SUSE%20Linux%20Enterprise%20High%20Performance%20Computing%2015%20SP1-LTSSpkg:rpm/suse/python-numpy_1_16_5-gnu-hpc&distro=SUSE%20Linux%20Enterprise%20High%20Performance%20Computing%2015%20SP2-ESPOSpkg:rpm/suse/python-numpy_1_16_5-gnu-hpc&distro=SUSE%20Linux%20Enterprise%20High%20Performance%20Computing%2015%20SP2-LTSSpkg:rpm/suse/python-numpy_1_16_5-gnu-hpc&distro=SUSE%20Linux%20Enterprise%20High%20Performance%20Computing%2015-ESPOSpkg:rpm/suse/python-numpy_1_16_5-gnu-hpc&distro=SUSE%20Linux%20Enterprise%20High%20Performance%20Computing%2015-LTSSpkg:rpm/suse/python-numpy_1_16_5-gnu-hpc&distro=SUSE%20Linux%20Enterprise%20Module%20for%20HPC%2015%20SP3pkg:rpm/suse/python-numpy_1_17_3-gnu-hpc&distro=SUSE%20Linux%20Enterprise%20High%20Performance%20Computing%2015%20SP1-ESPOSpkg:rpm/suse/python-numpy_1_17_3-gnu-hpc&distro=SUSE%20Linux%20Enterprise%20High%20Performance%20Computing%2015%20SP1-LTSSpkg:rpm/suse/python-numpy_1_17_3-gnu-hpc&distro=SUSE%20Linux%20Enterprise%20High%20Performance%20Computing%2015%20SP2-ESPOSpkg:rpm/suse/python-numpy_1_17_3-gnu-hpc&distro=SUSE%20Linux%20Enterprise%20High%20Performance%20Computing%2015%20SP2-LTSSpkg:rpm/suse/python-numpy_1_17_3-gnu-hpc&distro=SUSE%20Linux%20Enterprise%20High%20Performance%20Computing%2015-ESPOSpkg:rpm/suse/python-numpy_1_17_3-gnu-hpc&distro=SUSE%20Linux%20Enterprise%20High%20Performance%20Computing%2015-LTSSpkg:rpm/suse/python-numpy_1_17_3-gnu-hpc&distro=SUSE%20Linux%20Enterprise%20Module%20for%20HPC%2015%20SP3pkg:rpm/suse/python-numpy_1_17_3-gnu-hpc&distro=SUSE%20Linux%20Enterprise%20Real%20Time%2015%20SP2pkg:rpm/suse/python-numpy&distro=SUSE%20Enterprise%20Storage%206pkg:rpm/suse/python-numpy&distro=SUSE%20Enterprise%20Storage%207pkg:rpm/suse/python-numpy&distro=SUSE%20Linux%20Enterprise%20High%20Performance%20Computing%2015%20SP1-ESPOSpkg:rpm/suse/python-numpy&distro=SUSE%20Linux%20Enterprise%20High%20Performance%20Computing%2015%20SP1-LTSSpkg:rpm/suse/python-numpy&distro=SUSE%20Linux%20Enterprise%20High%20Performance%20Computing%2015%20SP2-ESPOSpkg:rpm/suse/python-numpy&distro=SUSE%20Linux%20Enterprise%20High%20Performance%20Computing%2015%20SP2-LTSSpkg:rpm/suse/python-numpy&distro=SUSE%20Linux%20Enterprise%20High%20Performance%20Computing%2015-ESPOSpkg:rpm/suse/python-numpy&distro=SUSE%20Linux%20Enterprise%20High%20Performance%20Computing%2015-LTSSpkg:rpm/suse/python-numpy&distro=SUSE%20Linux%20Enterprise%20Module%20for%20Basesystem%2015%20SP3pkg:rpm/suse/python-numpy&distro=SUSE%20Linux%20Enterprise%20Real%20Time%2015%20SP2pkg:rpm/suse/python-numpy&distro=SUSE%20Linux%20Enterprise%20Server%2012%20SP5pkg:rpm/suse/python-numpy&distro=SUSE%20Linux%20Enterprise%20Server%2015%20SP1-BCLpkg:rpm/suse/python-numpy&distro=SUSE%20Linux%20Enterprise%20Server%2015%20SP1-LTSSpkg:rpm/suse/python-numpy&distro=SUSE%20Linux%20Enterprise%20Server%2015%20SP2-BCLpkg:rpm/suse/python-numpy&distro=SUSE%20Linux%20Enterprise%20Server%2015%20SP2-LTSSpkg:rpm/suse/python-numpy&distro=SUSE%20Linux%20Enterprise%20Server%2015-LTSSpkg:rpm/suse/python-numpy&distro=SUSE%20Linux%20Enterprise%20Server%20for%20SAP%20Applications%2012%20SP5pkg:rpm/suse/python-numpy&distro=SUSE%20Linux%20Enterprise%20Server%20for%20SAP%20Applications%2015pkg:rpm/suse/python-numpy&distro=SUSE%20Linux%20Enterprise%20Server%20for%20SAP%20Applications%2015%20SP1pkg:rpm/suse/python-numpy&distro=SUSE%20Linux%20Enterprise%20Server%20for%20SAP%20Applications%2015%20SP2pkg:rpm/suse/python-numpy&distro=SUSE%20Linux%20Enterprise%20Software%20Development%20Kit%2012%20SP5pkg:rpm/suse/python-numpy&distro=SUSE%20Manager%20Proxy%204.1pkg:rpm/suse/python-numpy&distro=SUSE%20Manager%20Retail%20Branch%20Server%204.1pkg:rpm/suse/python-numpy&distro=SUSE%20Manager%20Server%204.1
>= 1.9.0, < 1.21+ 69 more
- (no CPE)range: >= 1.9.0, < 1.21
- (no CPE)range: < 3.17.0-bp153.2.3.1
- (no CPE)range: < 1.16.5-150200.3.5.1
- (no CPE)range: < 0.61.0-1.1
- (no CPE)range: < 1.16.5-150200.3.5.1
- (no CPE)range: < 1.16.5-150200.3.5.1
- (no CPE)range: < 1.17.3-10.1
- (no CPE)range: < 1.26.4-1.1
- (no CPE)range: < 1.17.3-10.1
- (no CPE)range: < 1.25.2-2.1
- (no CPE)range: < 3.17.0-bp153.2.3.1
- (no CPE)range: < 1.16.5-150000.1.9.1
- (no CPE)range: < 1.16.5-150200.3.5.1
- (no CPE)range: < 1.16.5-150000.1.9.1
- (no CPE)range: < 1.16.5-150000.1.9.1
- (no CPE)range: < 1.16.5-150200.3.5.1
- (no CPE)range: < 1.16.5-150200.3.5.1
- (no CPE)range: < 1.16.5-150000.1.9.1
- (no CPE)range: < 1.16.5-150000.1.9.1
- (no CPE)range: < 1.16.5-150200.3.5.1
- (no CPE)range: < 1.16.5-150000.1.9.1
- (no CPE)range: < 1.16.5-150000.1.9.1
- (no CPE)range: < 1.16.5-150200.3.5.1
- (no CPE)range: < 1.16.5-150000.1.9.1
- (no CPE)range: < 1.16.5-150000.1.9.1
- (no CPE)range: < 1.16.5-150000.1.9.1
- (no CPE)range: < 1.16.5-150200.3.5.1
- (no CPE)range: < 1.16.5-150200.3.5.1
- (no CPE)range: < 1.16.5-150200.3.5.1
- (no CPE)range: < 1.16.5-150200.3.5.1
- (no CPE)range: < 1.13.3-4.12.1
- (no CPE)range: < 1.16.5-150000.1.9.1
- (no CPE)range: < 1.16.5-150000.1.9.1
- (no CPE)range: < 1.16.5-150200.3.5.1
- (no CPE)range: < 1.16.5-150200.3.5.1
- (no CPE)range: < 1.16.5-150000.1.9.1
- (no CPE)range: < 1.16.5-150000.1.9.1
- (no CPE)range: < 1.16.5-150200.3.5.1
- (no CPE)range: < 1.17.3-10.1
- (no CPE)range: < 1.17.3-10.1
- (no CPE)range: < 1.17.3-10.1
- (no CPE)range: < 1.17.3-10.1
- (no CPE)range: < 1.17.3-10.1
- (no CPE)range: < 1.17.3-10.1
- (no CPE)range: < 1.17.3-10.1
- (no CPE)range: < 1.17.3-10.1
- (no CPE)range: < 1.17.3-10.1
- (no CPE)range: < 1.17.3-10.1
- (no CPE)range: < 1.17.3-10.1
- (no CPE)range: < 1.17.3-10.1
- (no CPE)range: < 1.17.3-10.1
- (no CPE)range: < 1.17.3-10.1
- (no CPE)range: < 1.17.3-10.1
- (no CPE)range: < 1.17.3-10.1
- (no CPE)range: < 1.17.3-10.1
- (no CPE)range: < 1.17.3-10.1
- (no CPE)range: < 1.8.0-5.11.1
- (no CPE)range: < 1.17.3-10.1
- (no CPE)range: < 1.17.3-10.1
- (no CPE)range: < 1.17.3-10.1
- (no CPE)range: < 1.17.3-10.1
- (no CPE)range: < 1.17.3-10.1
- (no CPE)range: < 1.8.0-5.11.1
- (no CPE)range: < 1.17.3-10.1
- (no CPE)range: < 1.17.3-10.1
- (no CPE)range: < 1.17.3-10.1
- (no CPE)range: < 1.8.0-5.11.1
- (no CPE)range: < 1.17.3-10.1
- (no CPE)range: < 1.17.3-10.1
- (no CPE)range: < 1.17.3-10.1
Patches
1ae317fd9ff3eMerge pull request #18989 from yetanothercheer/gh-18939-potential_buffer_overflow
1 file changed · +8 −8
numpy/core/src/multiarray/ctors.c+8 −8 modified@@ -668,6 +668,14 @@ PyArray_NewFromDescr_int( int i; npy_intp nbytes; + if ((unsigned int)nd > (unsigned int)NPY_MAXDIMS) { + PyErr_Format(PyExc_ValueError, + "number of dimensions must be within [0, %d]", + NPY_MAXDIMS); + Py_DECREF(descr); + return NULL; + } + if (descr->subarray) { PyObject *ret; npy_intp newdims[2*NPY_MAXDIMS]; @@ -687,14 +695,6 @@ PyArray_NewFromDescr_int( return ret; } - if ((unsigned int)nd > (unsigned int)NPY_MAXDIMS) { - PyErr_Format(PyExc_ValueError, - "number of dimensions must be within [0, %d]", - NPY_MAXDIMS); - Py_DECREF(descr); - return NULL; - } - /* Check datatype element size */ nbytes = descr->elsize; if (PyDataType_ISUNSIZED(descr)) {
Vulnerability mechanics
Generated on May 9, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.
References
5- github.com/advisories/GHSA-6p56-wp2h-9hxrghsaADVISORY
- nvd.nist.gov/vuln/detail/CVE-2021-33430ghsaADVISORY
- github.com/numpy/numpy/commit/ae317fd9ff3e79c0eac357d723bfc29cbd625f2eghsaWEB
- github.com/numpy/numpy/issues/18939ghsax_refsource_MISCWEB
- github.com/pypa/advisory-database/tree/main/vulns/numpy/PYSEC-2021-854.yamlghsaWEB
News mentions
0No linked articles in our index yet.