CVE-2017-12852: Vulnerability in numpy allows DoS attack

numpy Updated 02 Oct 2025

Summary

15/08/2017
Yes i
High
7.5

CVE-2017-12852: The numpy.pad function in Numpy 1.13.1 and older versions is 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 Devnack Your last release was probably never penetration tested Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

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. However, versions 1.13.1 and older of Numpy have a vulnerability that can be exploited to cause a Denial of Service (DoS) attack. The issue lies in the numpy.pad function, which lacks input validation. This allows an attacker to trigger an infinite loop by passing an empty list or ndarray as input.

Vulnerability Detail

The vulnerability (CVE-2017-12852) in Numpy allows an attacker to cause a DoS attack by exploiting the lack of input validation in the numpy.pad function. By providing an empty list or ndarray as input, the function enters an infinite loop, consuming excessive resources and rendering the system unresponsive. This can lead to service disruption and potential financial losses for affected organizations. It is important to note that this vulnerability only affects Numpy versions 1.13.1 and older.

How To Fix

Latest published version: 2.5.4 as of 23 Oct 2026

pip install --upgrade "numpy==2.5.4"

Upgrading to it may include breaking changes; the version below is the minimum fixed release for this vulnerability.

If you need the minimum change

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

If upgrading to the latest version of Numpy is not immediately feasible, a temporary workaround can be implemented. One possible workaround is to manually validate the input before calling the numpy.pad function. This can be done by checking if the input is empty or if it is an ndarray. If the input is empty, the function should return an appropriate error message or handle the case gracefully. Here's an example of how this workaround can be implemented in Python:

import numpy as np

def safe_pad(arr, pad_width, mode):
    if not arr:
        raise ValueError('Input array cannot be empty')
    if isinstance(arr, np.ndarray):
        return np.pad(arr, pad_width, mode)
    else:
        raise TypeError('Input array must be of type ndarray')

# Usage example
arr = []
pad_width = 2
mode = 'constant'

try:
    padded_arr = safe_pad(arr, pad_width, mode)
    print('Padded array:', padded_arr)
except (ValueError, TypeError) as e:
    print('Error:', str(e))

Conclusion

The vulnerability in Numpy versions 1.13.1 and older can be exploited to cause a DoS attack by triggering an infinite loop in the numpy.pad function. To mitigate this risk, it is crucial to upgrade to Numpy version 1.13.3 or later. If immediate upgrade is not possible, implementing a temporary workaround by validating the input can help prevent the vulnerability from being exploited. For further support on vulnerability remediation, you can contact DevNack.com.

See every vulnerability recorded for numpy →

Share this vulnerability

FAQ

This vulnerability allows an attacker to cause a DoS attack by exploiting the lack of input validation in the numpy.pad function. By providing an empty list or ndarray as input, the function enters an infinite loop, consuming excessive resources and rendering the system unresponsive.

Versions 1.13.1 and older of Numpy are affected by this vulnerability. It is recommended to upgrade to version 1.13.3 or later to mitigate the risk.

To fix this vulnerability, you should upgrade your Numpy installation to version 1.13.3 or later. This version includes the necessary input validation to prevent the DoS attack.

If upgrading to the latest version of Numpy is not immediately feasible, you can implement a temporary workaround by manually validating the input before calling the numpy.pad function. This involves checking if the input is empty or an ndarray and handling the cases appropriately.

Related vulnerabilities

Recent vulnerabilities recorded for numpy.

How To Fix

Latest published version: 2.5.4 as of 23 Oct 2026

pip install --upgrade "numpy==2.5.4"

Upgrading to it may include breaking changes; the version below is the minimum fixed release for this vulnerability.

If you need the minimum change

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