Skip to content

GHSA-4v9q-cgpw-cf38 CVE-2022-29255 PYSEC-2022-43053

Multiple evaluation of contract address in call in vyper

High PyPI
Severity
0.0 / 10
High · CVSS 4.0
Exploit chance (EPSS)
1.35%
Chance of exploitation in the next 30 days. Higher than 71.49% of scored vulnerabilities.
Known exploited
No
Not in CISA's catalog
Weakness
CWE-670 Always-Incorrect Control Flow Implementation
Fix
0.3.4
Upgrade vyper to this version or later

Description

Impact

when a calling an external contract with no return value, the contract address could be evaluated twice. this is usually only an efficiency problem, but if evaluation of the contract address has side effects, it could result in double evaluation of the side effects.

in the following example, Foo(msg.sender).bar() is the contract address for the following call (to .foo()), and could get evaluated twice

interface Foo:
    def foo(): nonpayable
    def bar() -> address: nonpayable

@external
def do_stuff():
    Foo(Foo(msg.sender).bar()).foo()

Patches

6b4d8ff185de071252feaa1c319712b2d6577f8d

Workarounds

assign contract addresses to variables. the above example would change to

@external
def do_stuff():
    t: Foo = Foo(msg.sender).bar()
    t.foo()

References

For more information

Affected versions

PyPI

PackageVulnerableFixed in
vyper
< 0.3.4
0.3.4
vyper
< 0.3.4
0.3.4

How to fix

Move to the fixed version or later with your package manager, update the lockfile, and run your tests. If the package only arrives through another dependency, upgrade that dependency first. If none of its releases pulls a fixed version yet, force the version with your package manager's override.

vyper PyPI → 0.3.4

pip
pip install --upgrade "vyper>=0.3.4"
poetry
poetry add "vyper>=0.3.4"
uv
uv add "vyper>=0.3.4"

Severity breakdown

CVSS 4.0 0.0

CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:H/VA:N/SC:N/SI:N/SA:N

Attack vector
Network
Attack complexity
Low
Attack requirements
None
Privileges required
None
User interaction
None
Confidentiality (vulnerable system)
None
Integrity (vulnerable system)
High
Availability (vulnerable system)
None
Confidentiality (subsequent systems)
None
Integrity (subsequent systems)
None
Availability (subsequent systems)
None

CVSS 3.1 7.5

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

Attack vector
Network
Attack complexity
Low
Privileges required
None
User interaction
None
Scope
Unchanged
Confidentiality
None
Integrity
High
Availability
None

Weakness

CWE-670: Always-Incorrect Control Flow Implementation

The code contains a control flow path that does not reflect the algorithm that the path is intended to implement, leading to incorrect behavior any time this path is navigated.

References

Timeline

  1. Published
  2. Last updated by the source
  3. Latest EPSS score
AdvisorySeverityWhy it's related
GHSA-2r3x-4mrv-mcxf
Vyper: Memory corruption using function calls within tuples / nested calls
Medium Also affects vyper
GHSA-4v7v-gqf9-ww2g
Vyper: Call stack corruption when passing complex type containing non-base type members as argument
Medium Also affects vyper
GHSA-vg88-3v92-rjx2
Vyper: Return inside for loop more than 1 level deep
Low Also affects vyper
GHSA-3vcg-j39x-cwfm
Vyper's `slice()` may elide side-effects when output length is 0
Low Also affects vyper
GHSA-qhr6-mgqr-mchm
Vyper's `concat()` builtin may elide side-effects for zero-length arguments
Low Also affects vyper
GHSA-h33q-mhmp-8p67
Vyper has a double eval in For List Iter
High Also affects vyper
GHSA-4w26-8p97-f4jp
AugAssign evaluation order causing OOB write within the object in Vyper
Critical Also affects vyper
GHSA-2p94-8669-xg86
Vyper's sqrt doesn't define rounding behavior
High Also affects vyper
Is this in your code?

MergeHarbor checks every repository's dependencies against this database, ranks what matters by exploitability and reachability, routes it to the owning team and opens the fix pull request.

Check your repos with MergeHarbor