# CVE-2021-41496: Buffer Copy without Checking Size of Input in NumPy

> A buffer overflow in NumPy allows attackers to cause a denial of service by constructing arrays with negative values, though vendor disputes severity.

- **Severity:** Medium 5.5 (`CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H`)
- **Exploited in the wild:** Not known
- **Login needed:** Any signed-in user
- **Attackable:** Local or same network only
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 17 Dec 2021
- **Updated:** 4 Aug 2024
- **Also known as:** AZL-7056, CLSA-2025-1766621635, CLSA-2026-1791368060, DEBIAN-CVE-2021-41496, ECHO-70fc-d0bb-2f7d, GHSA-f7c7-j99h-c22f, MINI-35fr-chh2-cc57, OESA-2022-1485, PYSEC-2021-857, UBUNTU-CVE-2021-41496

## What is CVE-2021-41496?

CVE-2021-41496 is a medium-severity denial of service vulnerability in n/a, published on 17 Dec 2021. It can only be exploited from the same machine or local network, with no action from the victim.

### Official description

Buffer overflow in the array_from_pyobj function of fortranobject.c in NumPy < 1.19, which allows attackers to conduct a Denial of Service attacks by carefully constructing an array with negative values. NOTE: The vendor does not agree this is a vulnerability; the negative dimensions can only be created by an already privileged user (or internally)

Weakness: CWE-120 (Buffer Copy without Checking Size of Input)

## Which versions are affected by CVE-2021-41496?

3 open source packages ship an affected version, including numpy. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `numpy` | PyPI | All versions | 1.19 |
| `numpy` | PyPI | All versions | 1.19 |
| `numpy` | PyPI | All versions | 1.19.0 |

Products: Numpy Numpy.

## How do I fix CVE-2021-41496?

Upgrade numpy to a fixed version for your release line: 1.19 or 1.19.0.

## Is CVE-2021-41496 being exploited?

There is no known exploitation of CVE-2021-41496 in the wild and no public exploit code.

## Other vulnerabilities in n/a

- [CVE-2017-12852](https://insights.sbomify.com/CVE-2017-12852/): Numpy missing input validation (high 7.5)
- [CVE-2014-1858](https://insights.sbomify.com/CVE-2014-1858/): Arbitrary file write in NumPy (medium 5.5)
- [CVE-2021-33430](https://insights.sbomify.com/CVE-2021-33430/): NumPy Buffer Overflow (Disputed) (medium 5.3)
- [CVE-2021-34141](https://insights.sbomify.com/CVE-2021-34141/): Incorrect Comparison in NumPy (medium 5.3)
- [CVE-2021-41495](https://insights.sbomify.com/CVE-2021-41495/): NumPy NULL Pointer Dereference (medium 5.3)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2021-41496 and fix it if it is affected.

What it is: CVE-2021-41496 is a medium-severity denial of service vulnerability in n/a, published on 17 Dec 2021. It can only be exploited from the same machine or local network, with no action from the victim.
Exploitation: There is no known exploitation of CVE-2021-41496 in the wild and no public exploit code.

Affected packages and fixed versions:
- numpy (PyPI): affected all versions; fixed in 1.19
- numpy (PyPI): affected all versions; fixed in 1.19
- numpy (PyPI): affected all versions; fixed in 1.19.0

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2021-41496/ (Markdown: https://insights.sbomify.com/CVE-2021-41496/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2021-41496
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2021-41496
- OSV: https://osv.dev/vulnerability/CVE-2021-41496

---
From sbomify Insights: https://insights.sbomify.com/CVE-2021-41496/
Summaries are generated and may contain mistakes; the official description above is the record.
