Loading HuntDB...

CVE-2024-24559

LOW
Published 2024-02-05T21:04:42.056Z
Actions:

Expert Analysis

Professional remediation guidance

Get tailored security recommendations from our analyst team for CVE-2024-24559. We'll provide specific mitigation strategies based on your environment and risk profile.

CVSS Score

V3.1
3.7
/10
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:N/A:N
Base Score Metrics
Exploitability: N/A Impact: N/A

EPSS Score

v2025.03.14
0.001
probability
of exploitation in the wild

There is a 0.1% chance that this vulnerability will be exploited in the wild within the next 30 days.

Updated: 2025-06-25
Exploit Probability
Percentile: 0.347
Higher than 34.7% of all CVEs

Attack Vector Metrics

Attack Vector
NETWORK
Attack Complexity
HIGH
Privileges Required
NONE
User Interaction
NONE
Scope
UNCHANGED

Impact Metrics

Confidentiality
LOW
Integrity
NONE
Availability
NONE

Description

Vyper is a Pythonic Smart Contract Language for the EVM. There is an error in the stack management when compiling the `IR` for `sha3_64`. Concretely, the `height` variable is miscalculated. The vulnerability can't be triggered without writing the `IR` by hand (that is, it cannot be triggered from regular vyper code). `sha3_64` is used for retrieval in mappings. No flow that would cache the `key` was found so the issue shouldn't be possible to trigger when compiling the compiler-generated `IR`. This issue isn't triggered during normal compilation of vyper code so the impact is low. At the time of publication there is no patch available.

Available Exploits

No exploits available for this CVE.

Related News

No news articles found for this CVE.

Affected Products

GitHub Security Advisories

Community-driven vulnerability intelligence from GitHub

✓ GitHub Reviewed LOW

Vyper sha3 codegen bug

GHSA-6845-xw22-ffxv

Advisory Details

### Summary There is an error in the stack management when compiling the `IR` for `sha3_64`. Concretely, the `height` variable is miscalculated. The vulnerability can't be triggered without writing the `IR` by hand. That is, it cannot be triggered from regular vyper code, it can only be triggered by using the `fang` binary directly (this binary used to be called `vyper-ir` prior to v0.3.4). ### Details To compile `sha3_64`, the `arg[0]` and `arg[1]` have to be compiled: https://github.com/vyperlang/vyper/blob/c150fc49ee9375a930d177044559b83cb95f7963/vyper/ir/compile_ir.py#L585-L586 As can be seen, after compiling the 0th arg, the `height` variable isn't increased. If new `withargs` are defined in the inner scope, they are manipulated correctly, because both their `height` is off and also the global `height` is off and thus their placement on the stack is computed correctly. `sha3_64` is used for retrieval in mappings. No flow that would cache the `key` was found, the issue shouldn't be possible to trigger when compiling the compiler-generated `IR`. ### PoC Suppose the following hand-written IR: ```lisp (with _loc (with val 1 (with key 2 (sha3_64 val key))) (seq (sstore _loc (with x (sload _loc) (with ans (add x 1) (seq (assert (ge ans x)) ans)))))) ``` after compilation: ``` the generated bytecode: 6001600281806020525f5260405f2090509050805460018101818110610026579050815550005b5f80fd 0000 60 PUSH1 0x01 0002 60 PUSH1 0x02 0004 81 DUP2 0005 80 DUP1 *********** bad code here!!!!!! 0006 60 PUSH1 0x20 0008 52 MSTORE ``` It can be seen that the second `DUP` will dup the item on the top of the stack which is incorrect. ### Patches Patched in https://github.com/vyperlang/vyper/pull/4063. ### Impact Versions v0.2.0-v0.3.10 were evaluated, and access of the variable with the invalid height is not reachable from IR generated by the vyper front-end. Because the issue isn't triggered during normal compilation of vyper code, the impact is considered low.

Affected Packages

PyPI vyper
ECOSYSTEM: ≥0 <0.4.0

CVSS Scoring

CVSS Score

2.5

CVSS Vector

CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:N/A:N

Advisory provided by GitHub Security Advisory Database. Published: February 5, 2024, Modified: November 22, 2024

References

Published: 2024-02-05T21:04:42.056Z
Last Modified: 2024-08-26T18:13:59.422Z
Copied to clipboard!