CVE-2024-24564
JSON

3.7low

Vyper extract32 can ready dirty memory

Severity
3.7low CVSS:3.1 by GitHub_M
Exploit likelihood
0.64% (higher than 46% of CVEs)
Published
Last changed
Assigned by
GitHub_M
Also known as
GHSA-4hwq-4cpm-8vmxPYSEC-2024-205

Description

Vyper is a pythonic Smart Contract Language for the ethereum virtual machine. When using the built-in `extract32(b, start)`, if the `start` index provided has for side effect to update `b`, the byte array to extract `32` bytes from, it could be that some dirty memory is read and returned by `extract32`. This vulnerability is fixed in 0.4.0.

Affected

Product or packageVersionsReported by
vyperlang vyper< 0.4.0, before 0.4.0CVE List, NVD
vyper (PyPI)before 0.4.0, before 3d9c537142fb99b2672f21e2057f5f202cde194fGitHub Advisory Database, PyPA Advisory Database

All scores

GitHub_M3.7low CVSS:3.1CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:N/A:N
GitHub3.7low CVSS:3.1CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:N/A:N
NVD5.3medium CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:N
PyPA Advisory Database5.3medium CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:N

Classification

CWE-125

SSVC (CISA-ADP): exploitation poc, automatable no, technical impact partial.

What each source says

CVE List

Vyper is a pythonic Smart Contract Language for the ethereum virtual machine. When using the built-in `extract32(b, start)`, if the `start` index provided has for side effect to update `b`, the byte array to extract `32` bytes from, it could be that some dirty memory is read and returned by `extract32`. This vulnerability is fixed in 0.4.0.

GitHub Advisory Database
Summary

When using the built-in extract32(b, start), if the start index provided has for side effect to update b, the byte array to extract 32 bytes from, it could be that some dirty memory is read and returned by extract32.

As of v0.4.0 (specifically, commit https://github.com/vyperlang/vyper/commit/3d9c537142fb99b2672f21e2057f5f202cde194f), the compiler will panic instead of generating bytecode.

Details

Before evaluating start, the function Extract32.build_IR caches only:

but do not cache the actual content of b. This means that if the evaluation of start changes b's content and length, an outdated length will be used with the new content when extracting 32 bytes from b.

PoC

Calling the function foo of the following contract returns b'uuuuuuuuuuuuuuuuuuuuuuuuuuu\x00\x00789' meaning that extract32 accessed some dirty memory.

var:Bytes[96]

@internal
def bar() -> uint256:
    self.var = b'uuuuuuuuuuuuuuuuuuuuuuuuuuuuuu'
    self.var = b''
    return 3

@external
def foo() -> bytes32:
    self.var = b'abcdefghijklmnopqrstuvwxyz123456789'
    return extract32(self.var, self.bar(), output_type=bytes32)
    # returns b'uuuuuuuuuuuuuuuuuuuuuuuuuuu\x00\x00789'
Impact

For contracts that are affected, it means that calling extract32 returns dirty memory bytes instead of some expected output.

NVD (es)

Vyper es un lenguaje de contrato inteligente pitónico para la máquina virtual ethereum. Cuando se utiliza el `extract32(b, start)` integrado, si el índice `start` proporcionado tiene como efecto secundario actualizar `b`, la matriz de bytes de la que extraer `32` bytes, podría ser que "extract32" lea y devuelva algo de memoria sucia. Esta vulnerabilidad afecta a la versión 0.3.10 y versiones anteriores.

References

Sources

SourceRecordLicence
CVE ListCVE-2024-24564 changed 2024-10-25CVE Terms of Use
GitHub Advisory DatabaseGHSA-4hwq-4cpm-8vmx changed 2026-06-10CC-BY-4.0
NVDCVE-2024-24564 changed 2026-06-17Public domain
PyPA Advisory DatabasePYSEC-2024-205 changed 2026-06-10CC-BY-4.0