Skip to main content

Integer Underflow

What it detects

This detector looks for subtractions that could underflow in older Solidity versions or within unchecked blocks. When a smaller value is subtracted from zero, the result wraps to a huge number, corrupting balances.

Typical symptoms

  • Balances balloon unexpectedly after deductions
  • Arithmetic inside unchecked sections using subtraction

Solidity snippet (v0.8.25)

pragma solidity ^0.8.25;

contract Underflow {
function dec(uint256 a, uint256 b) external pure returns (uint256) {
unchecked {
// Wraps to a large value on underflow
return a - b;
}
}
}

Why it matters on EVM

Underflow can grant attackers large balances or reset counters, leading to unauthorized withdrawals or logic errors.