CVE-2024-24564: Vyper extract32 can ready dirty memory

Published Feb 26, 2024
·
Updated

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.buildIR caches only:

- The pointer in memory/storage to b: https://github.com/vyperlang/vyper/blob/10564dcc37756f3d3684b7a91fd8f4325a38c4d8/vyper/builtins/functions.py#L916-L918 - The length of b: https://github.com/vyperlang/vyper/blob/10564dcc37756f3d3684b7a91fd8f4325a38c4d8/vyper/builtins/functions.py#L920-L922

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.

Vyper 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(), outputtype=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.

Other sources

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.

— MITRE

Affected Software

2 affected componentsFixes available
pip/vyper<=0.3.10
0.4.0
vyperlang Vyper Python<0.4.0

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade pip/vyper to a version that resolves this vulnerability.

    Fixed in 0.4.0
  2. Upgrade

    Upgrade vyper to a version that resolves this vulnerability.

    Fixed in 0.4.0
  3. Configuration

    In affected builds, ensure the compiler does not cache the actual content of `b` in Extract32.build_IR (it should avoid using cached/dirty memory lengths when `b` can be modified as a side effect of evaluating `start`).

    Vyper compiler/runtime (extract32) Extract32.build_IR caching behavior = do not cache the actual content of `b` (cache only length/metadata)

Event History

Feb 26, 2024
Advisory Published
via GitHub·08:11 PM
CVE Published
via MITRE·08:16 PM
Data Sourced
via MITRE·08:16 PM
DescriptionSeverityWeakness
Data Sourced
via NVD·08:19 PM
RemedyDescriptionSeverityWeaknessAffected Software

Frequently Asked Questions

1

What is the severity of CVE-2024-24564?

CVE-2024-24564 is considered to have a moderate severity due to the potential for reading uninitialized memory.

2

How do I fix CVE-2024-24564?

To fix CVE-2024-24564, upgrade to Vyper version 0.4.0 or later.

3

What software is affected by CVE-2024-24564?

CVE-2024-24564 affects Vyper versions prior to 0.4.0.

4

What issue does CVE-2024-24564 describe?

CVE-2024-24564 describes a vulnerability in the extract32 function that may read uninitialized memory.

5

Is there a known workaround for CVE-2024-24564?

There is no specific workaround for CVE-2024-24564; upgrading to the latest version is recommended.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203