CVE-2017-12852: Numpy missing input validation

numpy Updated 02 Oct 2025

Summary

13/05/2022
Yes i
High
7.5

CVE-2017-12852: Numpy missing input validation. Affects numpy versions < 1.13.3. Fixed in 1.13.3. How to fix ↓

Also tracked for

The same CVE-2017-12852 is tracked separately for each ecosystem and vendor. Its fix information is the same; the package and affected versions differ.

Free scan

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.

Check my app free

No signup required · Results in about 60 seconds

Sponsored MarkAI Find prospects already talking about the problem you solve AI watches the communities your customers use to find qualified prospects, then alerts you when a conversation is worth joining. See MarkAI

Background

Numpy is a popular package in the Python ecosystem that provides support for large, multi-dimensional arrays and matrices, along with a collection of mathematical functions to operate on these arrays. It is widely used in scientific computing and data analysis applications. However, versions 1.13.1 and older of Numpy suffer from a vulnerability due to missing input validation in the numpy.pad function. This function allows users to add padding to arrays, but an empty list or ndarray passed as input can trigger an infinite loop, leading to a denial-of-service (DoS) attack.

Vulnerability Detail

The vulnerability in Numpy arises from the lack of input validation in the numpy.pad function. When an empty list or ndarray is provided as input, the function enters an infinite loop, causing the program to hang indefinitely. This can be exploited by attackers to launch a DoS attack, rendering the affected application unresponsive. The vulnerability has a CVSS score of 7.5, indicating a high severity level. It is classified under CWE-835.

How To Fix

Minimum fixed version

1.13.3

This is the first release that contains the fix.

pip install --upgrade "numpy==1.13.3"

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Workaround

As a workaround, users can manually validate the input before calling the numpy.pad function. This can be done by checking if the input array is empty or if its dimensions are zero. If the input is invalid, an alternative approach or error handling mechanism can be implemented. Here is an example code snippet demonstrating the workaround:

import numpy as np

def safe_pad(array, pad_width, mode):
    if len(array) == 0 or np.prod(array.shape) == 0:
        raise ValueError('Invalid input array')
    else:
        return np.pad(array, pad_width, mode)

Conclusion

The vulnerability in Numpy, identified as CVE-2017-12852, stems from missing input validation in the numpy.pad function. By providing an empty list or ndarray as input, an infinite loop can be triggered, leading to a denial-of-service (DoS) attack. To mitigate this vulnerability, it is crucial to update Numpy to version 1.13.3 or later. Alternatively, users can implement a workaround by manually validating the input before using the numpy.pad function. For further assistance and support in vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for numpy →

Share this vulnerability

FAQ

Numpy is a Python package that provides support for large, multi-dimensional arrays and matrices, along with a collection of mathematical functions to operate on these arrays. It is widely used in scientific computing and data analysis applications.

The numpy.pad function is used to add padding to arrays. It allows users to specify the amount of padding to be added along each dimension of the array.

The vulnerability in Numpy can be exploited by attackers to cause a denial-of-service (DoS) attack. By providing an empty list or ndarray as input to the numpy.pad function, an infinite loop is triggered, causing the program to hang indefinitely and rendering the affected application unresponsive.

To fix this vulnerability, it is recommended to update Numpy to version 1.13.3 or later. The Numpy development team has addressed this issue by introducing input validation checks in the numpy.pad function.

Yes, as a workaround, users can manually validate the input before calling the numpy.pad function. By checking if the input array is empty or if its dimensions are zero, users can avoid triggering the vulnerability.

Related vulnerabilities

Recent vulnerabilities recorded for numpy.

How To Fix

Minimum fixed version

1.13.3

This is the first release that contains the fix.

pip install --upgrade "numpy==1.13.3"

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback