Flow

Sablier
FoundryDeFi
20,000 USDC
View results
Submission Details
Severity: medium
Invalid

Potential Integer Underflow Vulnerability in recover() Function

Medium

Impact: Medium

Likelihood: Low

Vulnerability Details

In the recover() function, the surplus calculation is performed using an unchecked subtraction:

uint256 surplus = token.balanceOf(address(this)) - aggregateBalance[token];

If aggregateBalance[token] is greater than the actual token balance (token.balanceOf(address(this))), the subtraction will underflow due to Solidity's default checked math, causing the transaction to revert. However, this creates a potential vulnerability if:

  1. aggregateBalance[token] becomes corrupted or manipulated

  2. The actual token balance is reduced through non-standard token mechanisms

  3. A malicious token implementation manipulates its balanceOf return value

Root Cause

The vulnerability stems from:

  1. Implicit trust in the aggregateBalance accounting

  2. Lack of safety checks before performing the subtraction

  3. Assumption that balanceOf will always be greater than or equal to aggregateBalance

Impact

The recover() function contains an unchecked subtraction operation that could lead to an integer underflow, This vulnerability could result in significant financial loss as it affects the core token recovery mechanism.

Tools Used

Recommendations

Implement safe balance checking and surplus calculation:

function recover(IERC20 token, address to) external override onlyAdmin {
// Additional recommendation
if (to == address(0)) {revert Errors.InvalidAddress(); // Custom error
//
uint256 currentBalance = token.balanceOf(address(this));
uint256 expectedBalance = aggregateBalance[token];
// Ensure current balance is sufficient
if (currentBalance < expectedBalance) {
revert Errors.InsufficientBalance(currentBalance, expectedBalance);
}
uint256 surplus = currentBalance - expectedBalance;
if (surplus == 0) {
revert Errors.SablierFlowBase_SurplusZero(address(token));
}
token.safeTransfer(to, surplus);
emit Recover(msg.sender, token, to, surplus);
}
Updates

Lead Judging Commences

inallhonesty Lead Judge 8 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.