CRITICAL🇬🇧 English

CVE-2024-24563

Vyper: nieprawidłowa walidacja indeksu tablicy — dostęp przez liczby ujemne

CVSS 9.8v3.1pub. 2024-02-07upd. 2024-11-21

W języku Vyper (Pythonic Smart Contract Language dla Ethereum Virtual Machine) typechecker nie zgłasza błędu, gdy tablica indeksowana jest liczbą całkowitą ze znakiem (int), choć tablice są zdefiniowane wyłącznie dla indeksów bez znaku (uint). Podatność może prowadzić do nieprzewidywalnego zachowania kontraktu, ominięcia asercji dostępu lub ataku DoS.

Pokaż oryginał (EN)

Vyper is a Pythonic Smart Contract Language for the Ethereum Virtual Machine. Arrays can be keyed by a signed integer, while they are defined for unsigned integers only. The typechecker doesn't throw when spotting the usage of an `int` as an index for an array. The typechecker allows the usage of signed integers to be used as indexes to arrays. The vulnerability is present in different forms in all versions, including `0.3.10`. For ints, the 2's complement representation is used. Because the array was declared very large, the bounds checking will pass Negative values will simply be represented as very large numbers. As of time of publication, a fixed version does not exist. There are three potential vulnerability classes: unpredictable behavior, accessing inaccessible elements and denial of service. Class 1: If it is possible to index an array with a negative integer without reverting, this is most likely not anticipated by the developer and such accesses can cause unpredictable behavior for the contract. Class 2: If a contract has an invariant in the form `assert index < x`, the developer will suppose that no elements on indexes `y | y >= x` are accessible. However, by using negative indexes, this can be bypassed. Class 3: If the index is dependent on the state of the contract, this poses a risk of denial of service. If the state of the contract can be manipulated in such way that the index will be forced to be negative, the array access can always revert (because most likely the array won't be declared extremely large). However, all these the scenarios are highly unlikely. Most likely behavior is a revert on the bounds check.

🤖 Analiza AI
Jak działa

Tablice w Vyperze są zdefiniowane dla indeksów nieujemnych (unsigned int), jednak typechecker akceptuje również indeksy typu signed int bez zgłaszania błędu. Liczby ujemne są reprezentowane w kodzie uzupełnieniowym do dwóch (2's complement), przez co — jeśli tablica jest zadeklarowana jako bardzo duża — sprawdzenie granic (bounds check) przechodzi pomyślnie, a ujemna wartość jest traktowana jako bardzo duża liczba nieujemna. W zależności od kontekstu może to skutkować dostępem do niedostępnych logicznie elementów tablicy, obejściem asercji w stylu `assert index < x` lub wymuszeniem stanu, w którym dostęp do tablicy zawsze kończy się rewertem (DoS). Według informacji na dzień publikacji CVE poprawiona wersja nie istnieje.

Skutki

Atakujący lub nieprawidłowo skonstruowany kontrakt może wywołać nieprzewidywalne zachowanie logiki kontraktu, ominąć zabezpieczenia dostępowe oparte na asercjach bądź spowodować trwały denial of service poprzez wymuszenie ujemnego indeksu tablicy.

Mitygacja

Należy zastosować patche dostępne u producenta zgodnie z referencjami. W momencie publikacji CVE (2024-02-07) poprawiona wersja nie istniała — zaleca się śledzenie repozytorium vyperlang/vyper oraz security advisory GHSA-52xq-j7v9-v4v2 i niezwłoczne wdrożenie poprawki po jej udostępnieniu. Do czasu łatki należy unikać używania signed int jako indeksów tablic w kodzie Vyper.

Kogo dotyczy

Vyperlang Vyper — wszystkie wersje, w tym 0.3.10; według opisu w momencie publikacji brak wersji z poprawką

Uwagi

Opis CVE wskazuje, że najbardziej prawdopodobnym zachowaniem w praktyce jest revert przy sprawdzaniu granic — rzeczywiste wykorzystanie wszystkich trzech klas podatności opisanych w advisory jest oceniane jako mało prawdopodobne, choć nie niemożliwe.

CVSS Vector
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
  • Vyperlang Vyper

    APP
    Vyperlang
    ≤ 0.3.10
🔵
ZWERYFIKUJ U PRODUCENTA
Brak jednoznacznych danych o patchu. Sprawdź referencje od producenta.
Tagi
DoS
CWE
Referencje

Powiązane podatności

CVE-2024-24561CRITICAL9.8PL ✓ten sam produkt

Przepełnienie granic w funkcji slice() języka Vyper — dostęp OOB

CVE-2023-39363CRITICAL9.1ten sam produkt

Vyper is a Pythonic Smart Contract Language for the Ethereum Virtual Machine (EVM). In versions 0.2.15, 0.2.16...

CVE-2024-22419HIGH7.3ten sam produkt

Vyper is a Pythonic Smart Contract Language for the Ethereum Virtual Machine. The `concat` built-in can write ...

CVE-2023-46247HIGH7.5ten sam produkt

Vyper is a Pythonic Smart Contract Language for the Ethereum Virtual Machine (EVM). Contracts containing large...

CVE-2023-42443HIGH8.1ten sam produkt

Vyper is a Pythonic Smart Contract Language for the Ethereum Virtual Machine (EVM). In version 0.3.9 and prior...