VAITP Dataset

← Back to the dataset

CVE-2023-41052

Order of evaluation issue in Vyper built-in functions

  • CVSS 5.3
  • CWE-670 Always-Incorrect Control Flow Implementation
  • Input Validation and Sanitization
  • Remote

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.

CVSS base score
5.3
Published
2023-09-04
OWASP
A04 Insecure Design
Orthogonal defect classification
Function
Code defect classification
Incorrect Functionality
Category
Input Validation and Sanitization
Subcategory
Insecure Parsing or Deserialization
Accessibility scope
Remote
Impact
Arbitrary Code Execution
Affected component
Vyper
Fixed by upgrading
Yes

Solution

Update to Vyper version with patch (e.g., >= 0.3.3).

Vulnerable code sample

# Example demonstrating the vulnerability in Vyper with side effects
# This code represents the vulnerability before it was fixed

# Vulnerable code
def vulnerable_function(a, b):
    # Side effect: modifying a global variable
    global side_effect_var
    side_effect_var = a + 1  # This side effect can affect other arguments
    return uint256_addmod(a, side_effect_var, 10)  # Dependent on side effect

Patched code sample

# Example demonstrating the vulnerability in Vyper with side effects
# This code is meant to represent the vulnerability, not the fix

# Vulnerable code
def vulnerable_function(a, b):
    # Side effect: modifying a global variable
    global side_effect_var
    side_effect_var = a + 1
    return uint256_addmod(a, b, 10)

# Corrected code to avoid side effects in arguments
def fixed_function(a, b):
    # Avoid side effects in arguments
    temp_a = a + 1  # Compute side effect separately
    return uint256_addmod(temp_a, b, 10)

Published fix

Public sources link this CVE to the changes below. The code samples above were generated to illustrate the defect; these links lead to the code the project actually changed.

Cite this entry

@misc{vaitp:cve202341052,
  title        = {{Order of evaluation issue in Vyper built-in functions}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2023},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2023-41052},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2023-41052/}}
}

Download this entry as JSON Download the whole dataset

Introducing the "VAITP dataset": a specialized repository of Python vulnerabilities and patches, meticulously compiled for the use of the security research community. As Python's prominence grows, understanding and addressing potential security vulnerabilities become crucial. Crafted by and for the cybersecurity community, this dataset offers a valuable resource for researchers, analysts, and developers to analyze and mitigate the security risks associated with Python. Through the comprehensive exploration of vulnerabilities and corresponding patches, the VAITP dataset fosters a safer and more resilient Python ecosystem, encouraging collaborative advancements in programming security.

The supreme art of war is to subdue the enemy without fighting.

Sun Tzu – “The Art of War”

:: Shaping the future through research and ingenuity ::

Before you use the VAITP AI models

Please read and accept the following disclaimer:

By choosing "I understand and accept", you acknowledge that you understand and agree to these terms.