Skip to content

Security/Logic Fix: Autonomous Code Review#216

Open
fliptrigga13 wants to merge 1 commit into
curvefi:masterfrom
fliptrigga13:lucy-red-team
Open

Security/Logic Fix: Autonomous Code Review#216
fliptrigga13 wants to merge 1 commit into
curvefi:masterfrom
fliptrigga13:lucy-red-team

Conversation

@fliptrigga13

Copy link
Copy Markdown

Autonomous Bug Report & Patch

This vulnerability and fix were autonomously discovered by the Lucy Red Team swarm.

The code provided appears to be a series of tests for a smart contract that checks for reentrancy vulnerabilities in various functions of a StableSwap contract. The tests use the brownie framework and pytest to verify that certain functions revert when called recursively.

Critical Bug: Potential Reentrancy Vulnerability

The critical bug lies in the way the __default__ function is implemented within each test case. Specifically, the __default__ function is marked as @payable, which means it can receive Ether (or any other token). However, the function does not properly handle reentrancy checks or ensure that it cannot be called recursively.

Example from test_exchange:

@payable
@external
def __default__():
    if not self.called:
        log Callback()
        self.called = True
        StableSwap(msg.sender).exchange(1, 0, 10**18, 0)

Issue Explanation

  1. Reentrancy Vector: The __default__ function is marked as @payable, which means it can receive Ether. If an attacker manages to send Ether to the contract during the execution of the exchange function, they could potentially trigger a reentrancy attack.

  2. Lack of Reentrancy Protection: The __default__ function does not include any checks to prevent reentrancy. If an attacker sends Ether

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant