Level 10 - Re-entrancy ⏺⏺⏺
Last updated
Last updated
The exploit is a standard reentrancy attack made possible because the funds are sent before the state variable is updated. The receiving contract can then call the withdraw function again, leading to more funds being withdrawn than should have been available.
Call the withdraw()
function from the receive()
function.
Submit instance... 🥳
No function, including the receive()
function, can be invoked from logic in the constructor.
In order to prevent re-entrancy attacks when moving funds out of your contract, use the being aware that call
will only return false without interrupting the execution flow. Solutions such as or can also be used.
transfer
and send
are no longer recommended solutions as they can potentially break contracts after the Istanbul hard fork .
The famous DAO hack used reentrancy to extract a huge amount of ether from the victim contract. See .