Skip to content

First good issue: Reentrancy Risk in _rentStorage Function in src/IdGateway.sol #439

Description

@ATella12

Issue: In the _rentStorage function, the contract transfers an overpayment back to the payer using payer.sendNative(overpayment). Using send or transfer in Ethereum can be risky because it allows for potential reentrancy attacks (depending on how sendNative is implemented). If the payer is a contract, they could reenter and exploit the contract by re-calling the function in an unintended way.

Fix: The contract should implement a checks-effects-interactions pattern by ensuring all state changes are made before the external call or consider using call with safe handling.

(bool success, ) = payer.call{value: overpayment}("");
require(success, "Transfer failed");

Fixing a reentrancy risk prevents one of the most notorious attack vectors in Ethereum smart contracts.

Activity

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

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions