CVE-2024-22419 concat built-in can corrupt memory in vyper
The Vyper compiler's concat built-in can corrupt memory, potentially altering smart contract semantics or enabling code execution.
- Exploited in the wild
- Not known
- Login needed
- Not needed
- Attackable
- Over the internet
- Victim action needed
- Not needed
- Fix
- Available
What is CVE-2024-22419?
CVE-2024-22419 is a high-severity memory corruption vulnerability in vyperlang vyper, published on 18 Jan 2024. An attacker can exploit it over the internet without logging in, with no action from the victim.
Official description
Vyper is a Pythonic Smart Contract Language for the Ethereum Virtual Machine. The `concat` built-in can write over the bounds of the memory buffer that was allocated for it and thus overwrite existing valid data. The root cause is that the `build_IR` for `concat` doesn't properly adhere to the API of copy functions (for `>=0.3.2` the `copy_bytes` function). A contract search was performed and no vulnerable contracts were found in production. The buffer overflow can result in the change of semantics of the contract. The overflow is length-dependent and thus it might go unnoticed during contract testing. However, certainly not all usages of concat will result in overwritten valid data as we require it to be in an internal function and close to the return statement where other memory allocations don't occur. This issue has been addressed in 0.4.0.
Which versions are affected by CVE-2024-22419?
3 open source packages ship an affected version, including vyper. It affects 1 product.
| Package | Affected | Fixed in |
|---|---|---|
vyper PyPI | All versions | 0.4.0b1 |
vyper PyPI | From 0.3.0 | 0.4.0 |
vyper PyPI | From 0.3.0 | 0.4.0 |
Products include Vyperlang Vyper.
How do I fix CVE-2024-22419?
Upgrade vyper to a fixed version for your release line: 0.4.0b1 or 0.4.0.
Upgrade to the fixed version. Memory-safe languages, compiler hardening and fuzzing prevent most new cases. More about Memory corruption.
Is CVE-2024-22419 being exploited?
It is not confirmed as exploited in the wild, but public exploit code for CVE-2024-22419 exists.
Other vulnerabilities in vyperlang vyper
- CVE-2024-24563 Vyper array negative index vulnerability
- CVE-2024-24561 Vyper bounds check on built-in `slice()` function can be overflowed
- CVE-2023-39363 Vyper incorrectly allocated named re-entrancy locks
- CVE-2022-24845 Integer bounds error in Vyper
- CVE-2022-29255 Multiple evaluation of contract address in call in vyper
Sources
Also known as GHSA-2q8v-3gqq-4f8p, PYSEC-2024-103.