# CVE-2021-29511: Memory over-allocation in evm crate

> An attacker can cause denial of service by triggering excessive memory allocation in the evm crate via specific EVM opcodes.

- **Severity:** Medium 6.5 (`CVSS:3.1/AV:N/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:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 12 May 2021
- **Updated:** 3 Aug 2024
- **Also known as:** GHSA-4jwq-572w-4388

## What is CVE-2021-29511?

CVE-2021-29511 is a medium-severity denial of service vulnerability in rust-blockchain evm, published on 12 May 2021. Any signed-in user can exploit it over the network, with no action from the victim.

### Official description

evm is a pure Rust implementation of Ethereum Virtual Machine. Prior to the patch, when executing specific EVM opcodes related to memory operations that use `evm_core::Memory::copy_large`, the `evm` crate can over-allocate memory when it is not needed, making it possible for an attacker to perform denial-of-service attack. The flaw was corrected in commit `19ade85`. Users should upgrade to `==0.21.1, ==0.23.1, ==0.24.1, ==0.25.1, >=0.26.1`. There are no workarounds. Please upgrade your `evm` crate version.

Weakness: CWE-787 (Out-of-bounds Write), CWE-770 (Allocation of Resources Without Limits or Throttling)

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

24 open source packages ship an affected version, including evm and evm-core. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `evm` | crates.io | All versions | 0.21.1 |
| `evm` | crates.io | All versions | 0.21.1 |
| `evm` | crates.io | From 0.22.0 | 0.22.1 |
| `evm` | crates.io | From 0.22.0 | 0.22.1 |
| `evm` | crates.io | From 0.23.0 | 0.23.1 |
| `evm` | crates.io | From 0.23.0 | 0.23.1 |
| `evm` | crates.io | From 0.24.0 | 0.24.1 |
| `evm` | crates.io | From 0.24.0 | 0.24.1 |
| `evm` | crates.io | From 0.25.0 | 0.25.1 |
| `evm` | crates.io | From 0.25.0 | 0.25.1 |
| `evm` | crates.io | From 0.26.0 | 0.26.1 |
| `evm` | crates.io | From 0.26.0 | 0.26.1 |
| `evm-core` | crates.io | All versions | 0.21.1 |
| `evm-core` | crates.io | All versions | 0.21.1 |
| `evm-core` | crates.io | From 0.22.0 | 0.22.1 |
| `evm-core` | crates.io | From 0.22.0 | 0.22.1 |
| `evm-core` | crates.io | From 0.23.0 | 0.23.1 |
| `evm-core` | crates.io | From 0.23.0 | 0.23.1 |
| `evm-core` | crates.io | From 0.24.0 | 0.24.1 |
| `evm-core` | crates.io | From 0.24.0 | 0.24.1 |
| `evm-core` | crates.io | From 0.25.0 | 0.25.1 |
| `evm-core` | crates.io | From 0.25.0 | 0.25.1 |
| `evm-core` | crates.io | From 0.26.0 | 0.26.1 |
| `evm-core` | crates.io | From 0.26.0 | 0.26.1 |

Products: Evm Project Evm.

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

Upgrade evm to a fixed version for your release line: 0.21.1, 0.22.1, 0.23.1 or 0.24.1.

## Is CVE-2021-29511 being exploited?

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

## Other vulnerabilities in rust-blockchain evm

- [CVE-2021-41153](https://insights.sbomify.com/CVE-2021-41153/): Specification non-compliance in JUMPI (high 8.7)
- [CVE-2024-21629](https://insights.sbomify.com/CVE-2024-21629/): Erroneous handling of `record_external_operation` error return (medium 5.9)
- [CVE-2022-39354](https://insights.sbomify.com/CVE-2022-39354/): evm has incorrect is_static parameter for custom stateful precompiles (medium 5.9)

## Fix prompt for AI coding agents

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

What it is: CVE-2021-29511 is a medium-severity denial of service vulnerability in rust-blockchain evm, published on 12 May 2021. Any signed-in user can exploit it over the network, with no action from the victim.
Exploitation: There is no known exploitation of CVE-2021-29511 in the wild and no public exploit code.

Affected packages and fixed versions:
- evm (crates.io): affected all versions; fixed in 0.21.1
- evm (crates.io): affected all versions; fixed in 0.21.1
- evm (crates.io): affected from 0.22.0; fixed in 0.22.1
- evm (crates.io): affected from 0.22.0; fixed in 0.22.1
- evm (crates.io): affected from 0.23.0; fixed in 0.23.1
- evm (crates.io): affected from 0.23.0; fixed in 0.23.1
- evm (crates.io): affected from 0.24.0; fixed in 0.24.1
- evm (crates.io): affected from 0.24.0; fixed in 0.24.1
- evm (crates.io): affected from 0.25.0; fixed in 0.25.1
- evm (crates.io): affected from 0.25.0; fixed in 0.25.1
- evm (crates.io): affected from 0.26.0; fixed in 0.26.1
- evm (crates.io): affected from 0.26.0; fixed in 0.26.1

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-29511/ (Markdown: https://insights.sbomify.com/CVE-2021-29511/index.md)
```

## Sources

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

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