VYPR
Moderate severityNVD Advisory· Published Sep 4, 2023· Updated Sep 26, 2024

Vyper: incorrect order of evaluation of side effects for some builtins

CVE-2023-41052

Description

Vyper is a Pythonic Smart Contract Language. In affected versions the order of evaluation of the arguments of the builtin functions uint256_addmod, uint256_mulmod, ecadd and ecmul does not follow source order. This behaviour is problematic when the evaluation of one of the arguments produces side effects that other arguments depend on. A patch is currently being developed on pull request #3583. When using builtins from the list above, users should make sure that the arguments of the expression do not produce side effects or, if one does, that no other argument is dependent on those side effects.

AI Insight

LLM-synthesized narrative grounded in this CVE's description and references.

Vyper smart contract builtins uint256_addmod, uint256_mulmod, ecadd, and ecmul evaluate arguments out of source order, causing potential side-effect inconsistencies.

Vulnerability

CVE-2023-41052 describes an evaluation order vulnerability in the Vyper smart contract language, affecting the builtin functions uint256_addmod, uint256_mulmod, ecadd, and ecmul. The root cause is that the compiler does not evaluate the arguments of these functions in the order they appear in source code. Specifically, for uint256_addmod(a,b,c) and uint256_mulmod(a,b,c), the actual evaluation order is c, a, b, while for ecadd(a,b) and ecmul(a,b), the order is b, a [1][4].

Exploitation

This behavior becomes exploitable when the evaluation of one argument produces side effects that another argument depends on. For example, if a contract calls a function that modifies state as part of an argument expression, the unexpected evaluation order could lead to incorrect state changes or reentrancy-like conditions. An attacker can craft transactions that rely on the compiler's unintended evaluation sequence to manipulate contract logic, potentially draining funds or corrupting data [1][4].

Impact

An attacker who can control the arguments passed to these builtins, or influence contract state during argument evaluation, may cause the smart contract to behave differently than intended. This could include bypassing access controls, altering arithmetic results, or triggering unintended state transitions. Since smart contracts often manage valuable assets, such inconsistencies can lead to financial loss [1][4].

Mitigation

The Vyper team is developing a patch in pull request #3583. As a workaround, developers should ensure that no argument expression for these builtins produces side effects, or if one does, that no other argument depends on those side effects. Users should review contracts using these functions and refactor code to avoid side-effect dependencies until the patch is released [1][4].

AI Insight generated on May 20, 2026. Synthesized from this CVE's description and the cited reference URLs; citations are validated against the source bundle.

Affected packages

Versions sourced from the GitHub Security Advisory.

PackageAffected versionsPatched versions
vyperPyPI
< 0.3.10rc10.3.10rc1

Affected products

1

Patches

0

No patches discovered yet.

Vulnerability mechanics

AI mechanics synthesis has not run for this CVE yet.

References

5

News mentions

0

No linked articles in our index yet.