CVE-2025-47774
Executive Summary
CVE-2025-47774 is a vulnerability in the Vyper programming language, a Pythonic language for the Ethereum Virtual Machine (EVM). The flaw resides in the slice() built-in function, which can elide side effects when the output length is 0 and the source bytestring is a built-in like msg.data or <address>.code. This occurs because the check that length >= 1 is skipped for these source locations. The result is that a 0-length bytestring constructed with slice() can be passed to make_byte_array_copier, which elides evaluation of its source argument when the max length is 0. The impact is that side effects in the start argument may be elided when the length argument is 0, e.g., slice(msg.data, self.do_side_effect(), 0). The fix in pull request 4645 disallows any invocation of slice() with length 0, including for the ad hoc locations discussed in this advisory. The fix is expected to be part of version 0.4.2.
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 language for EVM smart contracts. This vulnerability affects the Vyper compiler itself, which is a critical component in the Ethereum development supply chain. If exploited, it could lead to unexpected behavior in smart contracts compiled with vulnerable versions, potentially causing financial loss or logic errors. The package is distributed via PyPI and GitHub, and developers should ensure they are using a patched version (0.4.2 or later) to avoid supply chain risks.
CVSS Breakdown & Threat Level
The CVSS score is 0.0, indicating that no official CVSS vector has been assigned. However, based on the vulnerability description, the following breakdown is estimated:
- Attack Vector (AV): Network (AV:N) - The vulnerability can be triggered by deploying a malicious smart contract.
- Attack Complexity (AC): Low (AC:L) - The attack requires crafting a specific
slice()call. - Privileges Required (PR): None (PR:N) - No special privileges are needed to deploy a contract.
- User Interaction (UI): None (UI:N) - No user interaction is required.
- Scope (S): Unchanged (S:U) - The vulnerability affects the contract's execution.
- Confidentiality (C): None (C:N) - No data confidentiality impact.
- Integrity (I): Low (I:L) - Side effects can be elided, potentially altering contract state.
- Availability (A): Low (A:L) - The vulnerability could cause unexpected behavior.
Estimated CVSS Vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:L
Threat Level: Medium. The vulnerability allows side-effect elision, which could be exploited to bypass security checks or manipulate contract logic.
Deep Dive & Mechanics
The vulnerability is in the Vyper compiler's handling of the slice() built-in function. In Vyper, slice() is used to extract a substring from a bytestring. The function takes three arguments: the source bytestring, the start index, and the length. When the length is 0, the compiler should still evaluate the start index to ensure side effects are executed. However, for built-in source locations like msg.data or <address>.code, the compiler skips the check that length >= 1. This allows a 0-length slice to be passed to make_byte_array_copier, which elides evaluation of the source argument when the max length is 0.
Root Cause: The compiler's optimization logic incorrectly assumes that a 0-length slice does not need to evaluate the start argument, leading to side-effect elision.
Impact: An attacker can craft a smart contract that uses slice() with a length of 0 and a start argument that has side effects (e.g., a function call that modifies state). The side effects will be silently ignored, potentially allowing the attacker to bypass security checks or manipulate contract state.
Vulnerable vs. Patched Code
Vulnerable Code (Vyper <= 0.4.2rc1):
# In the compiler, the slice() function for built-in sources skips the length check
# This allows slice(msg.data, self.do_side_effect(), 0) to elide the side effect
Patched Code (Vyper >= 0.4.2):
# The fix in PR 4645 disallows any invocation of slice() with length 0
# This ensures that side effects in the start argument are always evaluated
Exploitation & Lab Setup
Red Team
Exploitation Scenario: An attacker deploys a smart contract that uses slice() with a length of 0 and a start argument that has side effects. The side effects are elided, allowing the attacker to bypass security checks.
Lab Setup:
- Install a vulnerable version of Vyper (e.g., 0.4.2rc1).
- Create a smart contract with the following code:
@external def exploit() -> bool: # This call should trigger a side effect, but it will be elided slice(msg.data, self.do_side_effect(), 0) return True @internal def do_side_effect() -> uint256: # Modify some state variable self.some_state = 1 return 0 - Compile and deploy the contract on a test Ethereum network.
- Call the
exploit()function and observe thatself.some_stateremains unchanged, indicating the side effect was elided.
Blue Team
Detection: Monitor for smart contracts that use slice() with a length of 0. This can be done by analyzing the bytecode or source code of deployed contracts.
Mitigation: Update to Vyper version 0.4.2 or later, which disallows slice() with length 0.
Indicators of Compromise (IOCs)
- Smart Contract Bytecode: Contracts that contain
slice()calls with a length of 0. - Source Code Patterns: Use of
slice()with a length of 0 and a start argument that has side effects. - Transaction Patterns: Transactions that call functions using
slice()with a length of 0.
Detection Engineering
YARA Rule
rule CVE_2025_47774_Vyper_Slice_Zero_Length {
meta:
description = "Detects Vyper smart contracts using slice() with length 0"
author = "Valters IT"
date = "2025-04-10"
cve = "CVE-2025-47774"
strings:
$slice_zero = /slice\s*\([^,]+,\s*[^,]+,\s*0\s*\)/
condition:
$slice_zero
}
Sigma Rule
title: CVE-2025-47774 - Vyper slice() Zero Length Side Effect Elision
id: 8a4b3c2d-1e5f-4a7b-9c8d-0e1f2a3b4c5d
status: experimental
description: Detects Vyper smart contracts using slice() with length 0
author: Valters IT
date: 2025-04-10
logsource:
category: smart_contract
product: vyper
detection:
selection:
source_code|contains: "slice("
source_code|contains: ", 0)"
condition: selection
falsepositives:
- None expected
level: high
Suricata Rule
alert tcp any any -> any any (msg:"CVE-2025-47774 - Vyper slice() Zero Length Side Effect Elision"; content:"slice("; content:", 0)"; classtype:attempted-admin; sid:1000001; rev:1;)
Remediation & Mitigation
Immediate Actions:
- Update Vyper to version 0.4.2 or later as soon as it is released.
- Review all smart contracts compiled with vulnerable versions for use of
slice()with length 0. - If such usage is found, redeploy the contracts with a patched compiler.
Long-Term Mitigation:
- Implement static analysis tools to detect dangerous
slice()usage. - Educate developers about the risks of side-effect elision in smart contracts.
Workarounds:
- Avoid using
slice()with a length of 0 in Vyper smart contracts. - Use alternative methods to achieve the desired functionality without relying on
slice()with zero length.
Valters IT
DevSecOps & Cyber Threat Intelligence Expert