CVE-2024-22419
Executive Summary
CVE-2024-22419 is a buffer overflow vulnerability in the Vyper smart contract language, specifically within the concat built-in function. The flaw allows writing beyond the allocated memory buffer, potentially overwriting valid data and altering contract semantics. The vulnerability is length-dependent and may go unnoticed during testing, but no vulnerable contracts were found in production. The issue is patched in Vyper 0.4.0.
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 Pythonic smart contract language for the Ethereum Virtual Machine (EVM). This vulnerability affects the Vyper compiler itself, not a package manager like PyPI. However, any project using Vyper versions prior to 0.4.0 is at risk. Developers should upgrade to the latest version and recompile contracts.
CVSS Breakdown & Threat Level
- CVSS Score: 7.3 (High)
- Vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:L
- Attack Vector: Network
- Attack Complexity: Low
- Privileges Required: None
- User Interaction: None
- Scope: Unchanged
- Confidentiality Impact: None
- Integrity Impact: High
- Availability Impact: Low
The high integrity impact reflects the potential to alter contract logic, while the low availability impact indicates limited denial-of-service potential.
Deep Dive & Mechanics
The vulnerability resides in the Vyper compiler's build_IR function for the concat built-in. When concatenating byte arrays, the compiler allocates a memory buffer but fails to properly enforce bounds checking during the copy operation. The copy_bytes function (used in Vyper >=0.3.2) is called without ensuring the destination buffer is large enough, leading to an out-of-bounds write.
The overflow is length-dependent: if the concatenated result exceeds the allocated buffer size, adjacent memory regions are overwritten. This can corrupt other variables or function return data, altering contract behavior. The issue is most likely to manifest in internal functions near return statements where memory allocations are minimal.
Vulnerable vs. Patched Code
Vulnerable (Vyper < 0.4.0):
@internal
def vulnerable_concat(a: Bytes[10], b: Bytes[10]) -> Bytes[20]:
return concat(a, b)
In this example, the compiler allocates a buffer for the result but may not correctly calculate the required size, leading to overflow.
Patched (Vyper 0.4.0):
@internal
def patched_concat(a: Bytes[10], b: Bytes[10]) -> Bytes[20]:
return concat(a, b)
The patched version ensures the build_IR for concat correctly calculates buffer sizes and uses copy_bytes with proper bounds.
Exploitation & Lab Setup
Red Team
Exploitation Scenario:
An attacker deploys a malicious contract that exploits the concat overflow to corrupt return data or state variables. The goal is to alter contract logic, e.g., bypass access controls or manipulate token balances.
Lab Setup:
- Install Vyper < 0.4.0 (e.g., 0.3.10).
- Create a vulnerable contract:
@external def exploit_me(a: Bytes[10], b: Bytes[10]) -> Bytes[20]: return concat(a, b) - Compile and deploy to a local Ethereum testnet (e.g., Ganache).
- Craft input data that triggers overflow (e.g., long byte strings).
- Observe memory corruption via debugger or transaction logs.
No exploit code is publicly available.
Blue Team
Detection:
- Monitor for contracts using
concatwith dynamic byte arrays. - Analyze bytecode for out-of-bounds memory writes.
- Use static analysis tools (e.g., Slither) to detect potential buffer overflows.
Hunting:
- Search for Vyper contracts compiled with versions < 0.4.0.
- Review contract source code for
concatusage in internal functions. - Test contracts with edge-case inputs to trigger overflow.
Indicators of Compromise (IOCs)
- Contract bytecode containing
concatIR with improper bounds checking. - Transaction logs showing unexpected memory corruption or contract state changes.
- Compiler version in contract metadata:
< 0.4.0.
Detection Engineering
YARA Rule
rule CVE_2024_22419_Vyper_Concat_Overflow {
meta:
description = "Detects Vyper contracts compiled with vulnerable concat implementation"
author = "Valters IT"
date = "2024-01-01"
reference = "CVE-2024-22419"
strings:
$concat_ir = /concat.*copy_bytes/i
$vyper_version = /vyper:0\.[0-3]\.\d+/i
condition:
$concat_ir and $vyper_version
}
Sigma Rule
title: Vyper Concat Buffer Overflow Detection
id: 7a8b9c0d-1e2f-3a4b-5c6d-7e8f9a0b1c2d
status: experimental
description: Detects potential exploitation of CVE-2024-22419 in Vyper contracts
author: Valters IT
logsource:
category: blockchain
product: ethereum
detection:
selection:
event: "ContractCreation"
compiler_version|startswith: "0."
compiler_version|lt: "0.4.0"
condition: selection
falsepositives:
- Contracts using concat safely in older versions
level: high
Suricata Rule
alert ip any any -> any any (msg:"CVE-2024-22419 Vyper Concat Overflow Attempt"; content:"|63 6f 6e 63 61 74|"; depth:6; content:"|63 6f 70 79 5f 62 79 74 65 73|"; distance:0; within:100; classtype:attempted-admin; sid:1000001; rev:1;)
Remediation & Mitigation
- Upgrade Vyper to version 0.4.0 or later.
- Recompile all contracts using the patched compiler.
- Review contract logic for any reliance on
concatbehavior that may have changed. - Test contracts with edge-case inputs to ensure no memory corruption.
- Monitor for anomalous transactions that may indicate exploitation attempts.
Valters IT