Skip to main content

How Can an Underflow Be Exploited to Drain Funds from a Contract?

An underflow can be exploited by an attacker to manipulate a contract's balance checks or withdrawal logic. If a contract subtracts a user's withdrawal amount from their balance without a safe math check, and the balance is zero, the subtraction can underflow, causing the balance to wrap to the maximum possible value (e.g.

2^256 – 1). The contract then incorrectly believes the user has a massive balance, allowing them to withdraw an amount far exceeding their actual deposit, thereby draining the contract's funds.

Provide an Example of How Two Functions Might Share a State That Could Be Exploited
What Happens to My Investment If a Rebase Token’s Smart Contract Is Exploited?
How Does a Reentrancy Attack Relate to the DAO Hack?
What Is an Integer Overflow and How Does It Impact Token Balances?