Skip to content

Vyper's `_abi_decode` vulnerable to Memory Overflow

Low severity GitHub Reviewed Published Feb 26, 2024 in vyperlang/vyper • Updated Feb 26, 2024

Package

pip vyper (pip)

Affected versions

<= 0.3.10

Patched versions

None

Description

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

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

References

@charles-cooper charles-cooper published to vyperlang/vyper Feb 26, 2024
Published to the GitHub Advisory Database Feb 26, 2024
Reviewed Feb 26, 2024
Published by the National Vulnerability Database Feb 26, 2024
Last updated Feb 26, 2024

Severity

Low
3.7
/ 10

CVSS base metrics

Attack vector
Network
Attack complexity
High
Privileges required
None
User interaction
None
Scope
Unchanged
Confidentiality
Low
Integrity
None
Availability
None
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:N/A:N

CVE ID

CVE-2024-26149

GHSA ID

GHSA-9p8r-4xp4-gw5w

Source code

Credits

Checking history
See something to contribute? Suggest improvements for this vulnerability.