Integer Overflows/Underflows
Last updated
Integer Overflows and Underflows occur when mathematical operations exceed the storage limits of a variable, causing unexpected behavior. These vulnerabilities allow attackers to manipulate values in ways that can break contract logic.
Integer Overflows and Underflows occur when mathematical operations exceed the storage limits of a variable, causing unexpected behavior. These vulnerabilities allow attackers to manipulate values in ways that can break contract logic.
Integer Overflow: When a value exceeds the maximum limit of its data type, it wraps around to the minimum value. Example:
solidity
uint8 x = 255; // Max value for uint8
x += 1; // Overflow: x becomes 0Integer Underflow: When a value is reduced below the minimum limit of its data type, it wraps around to the maximum value. Example:
solidity
uint8 x = 0; // Min value for uint8
x -= 1; // Underflow: x becomes 255Attackers exploit overflows/underflows to:
Mint extra tokens.
Bypass balance checks.
Gain unauthorized access to funds.
Last updated
