Key Takeaways
- reentrancy attacks are based on recursively withdrawing an amount before the victim contract can update the balance from which the attacker is withdrawing
- general insight for myself: This means, that the management of balances on a contract (e.g.
balances[msg.sender] += msg.value)
are only a superficial division of the total funds of a contract. For them to work and the funds not being falsly changed, the updating of these balances must be exactly on time and correct.
- general insight for myself: This means, that the management of balances on a contract (e.g.
- ELI5 Example: a bank has 10 money, Lisa has an account with 5, Peter one with 3 and Hans one with 2 money. If Hans withdraws his money, the bank has only 8 money left and needs to update the balance of Hans which is now 0. But if it fails to update that balance of Hans in time, Hans can come back and withdraw as much as his balance states, which would be still 2 money. If he does that one more time, the bank only has 6 money left. Rince and repeat until the bank is at 0 and Hans walks away with 10, instead of 2 m