@accee
Day 4
Today I learned how reentrancy attacks work.
A contract sends funds before updating its internal balance.
An attacker can repeatedly call the withdraw function before the balance updates.
Small logic mistake. Massive exploit potential.
This is why order of operations in smart contracts matters.
A quest came to my head while learning about reentrance today, if a contract updates balance first, but still makes an external call later, can reentrancy still happen somewhere else in the contract and yeah I found out that yes reentrancy can still happen if:
1. There are other vulnerable functions e.g cashbacks etc
2. There are multiple balances
3. There are shared state variables
4. There are cross-function dependencies.