CVE-2024-22419
concat built-in can corrupt memory in vyper
Severity by source
Trivy's own label is CRITICAL. Rated critical by NVD. Rated lower by GHSA (high).
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.
Affected packages and fixed versions
| Source | Package | Fixed in |
|---|---|---|
| pip::GitHub Security Advisory pip | vyper | 0.4.0 |
References
- https://github.com/pypa/advisory-database/tree/main/vulns/vyper/PYSEC-2024-103.yaml
- https://github.com/vyperlang/vyper
- https://github.com/vyperlang/vyper/commit/55e18f6d128b2da8986adbbcccf1cd59a4b9ad6f
- https://github.com/vyperlang/vyper/issues/3737
- https://github.com/vyperlang/vyper/security/advisories/GHSA-2q8v-3gqq-4f8p
- https://nvd.nist.gov/vuln/detail/CVE-2024-22419