CVE-2023-42460
Vyper _abi_decode lacks input validation, allowing bypass of bounds checking and incorrect results
- CVSS 7.5
- CWE-682 Incorrect Calculation
- Input Validation and Sanitization
- Remote
Vyper is a Pythonic Smart Contract Language for the EVM. The `_abi_decode()` function does not validate input when it is nested in an expression. Uses of `_abi_decode()` can be constructed which allow for bounds checking to be bypassed resulting in incorrect results. This issue has not yet been fixed, but a fix is expected in release `0.3.10`. Users are advised to reference pull request #3626.
- CVSS base score
- 7.5
- Published
- 2023-09-27
- OWASP
- A08 Software and Data Integrity Failures
- 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 0.3.10 or higher.
Vulnerable code sample
def _abi_decode(data):
# Decoding logic without proper input validation
# This is a simplified representation of the vulnerability
return data # Assume this returns the decoded data without checking bounds
def example_usage():
# Example usage that demonstrates the vulnerability
nested_expression = _abi_decode(b'\x01\x02') + _abi_decode(b'\x03\x04')
return nested_expressionPatched code sample
def safe_abi_decode(data, expected_type):
# Validate input before decoding
if not isinstance(data, bytes):
raise ValueError("Input data must be of type bytes.")
# Perform bounds checking based on expected type
if expected_type == 'tuple':
# Example of expected size for a tuple, this should be defined based on actual requirements
expected_size = 2 # Change as per actual expected size
if len(data) < expected_size:
raise ValueError("Input data is too short for the expected tuple.")
# Call the actual decoding function after validation
return _abi_decode(data)
def _abi_decode(data):
# Existing decoding logic
# This function should be implemented to decode the ABI-encoded data
passPublished 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.
- fix: `_abi_decode()` validation (vyperlang/vyper)
vyper/builtins/functions.py,vyper/builtins/functions.py · ABIDecode.build_IR
Cite this entry
@misc{vaitp:cve202342460,
title = {{Vyper _abi_decode lacks input validation, allowing bypass of bounds checking and incorrect results}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2023},
note = {VAITP Python Vulnerability Dataset, entry CVE-2023-42460},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2023-42460/}}
}
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 ::
