Null Pointer Dereference Vulnerability in NumPy Package
Summary
DEBIAN-CVE-2021-41495: Null Pointer Dereference vulnerability exists in numpy.sort in NumPy < and 1.19 in the PyArray_DescrNew function due to missing return-value validation, which allows attackers to conduct DoS attacks by repetitively cre... Affects numpy versions 1:1.19.5-1 – 1:2.3.3+ds-1. No fix is published. How to fix ↓
Check if this vulnerability affects your application
Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.
No signup required · Results in about 60 seconds
Background
NumPy is a widely-used library in Python for numerical computing, providing support for large, multi-dimensional arrays and matrices, along with a collection of mathematical functions to operate on these arrays. It is a fundamental package for scientific computing in Python, often used in data analysis, machine learning, and engineering applications. The vulnerability in question affects versions of NumPy prior to 1.19, where a null pointer dereference can occur during the sorting process due to insufficient validation of return values.
Vulnerability Detail
The vulnerability, identified as CVE-2021-41495, arises from a null pointer dereference in the numpy.sort function within NumPy versions less than 1.19. This issue is caused by a lack of validation for return values in the PyArray_DescrNew function. Attackers can exploit this vulnerability to conduct Denial of Service (DoS) attacks by repeatedly creating sort arrays, which may lead to memory exhaustion. While the absence of validation is a concern, it is important to note that an error can only occur if the user has the ability to exhaust memory, indicating that they already possess certain privileges. Constructing a targeted attack to exploit this specific memory exhaustion scenario is considered practically impossible.
How To Fix
No fixed version is published for this vulnerability.
Tip — Not sure whether your app is affected? Vulert can check the versions your app actually runs. Scan free →
Workaround
As a temporary measure, users can avoid creating excessively large sort arrays that may lead to memory exhaustion. Implementing checks in the code to limit the size of arrays being sorted can help prevent triggering the vulnerability.
Conclusion
The null pointer dereference vulnerability in NumPy (CVE-2021-41495) poses a risk of Denial of Service attacks due to insufficient validation in the sorting function. Users are encouraged to update to the latest version of NumPy to mitigate this risk and consider implementing temporary workarounds if an immediate update is not feasible.
See every vulnerability recorded for numpy →
FAQ
CVE-2021-41495 is a vulnerability in NumPy that allows for a null pointer dereference, potentially leading to Denial of Service attacks.
All versions of NumPy prior to 1.19 are affected by this vulnerability.
You can use Vulert, which monitors and alerts for open-source vulnerabilities in your software. Check your application against this vulnerability using the Vulert playground at Vulert Scanner.
As a workaround, limit the size of arrays being sorted in your application to prevent triggering the vulnerability.
Using an affected version of NumPy poses a risk, especially in applications that handle large data sets. It is advisable to implement workarounds until an update can be applied.
References
Related vulnerabilities
Recent vulnerabilities recorded for numpy.