Flow

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

overflow when token's decimals > 18

Vulnerability Details

From contest details, it is assumed that protocol work with token that have any decimals.

function descaleAmount(uint256 amount, uint8 decimals) internal pure returns (uint256) {
if (decimals == 18) {
return amount;
}
unchecked {
uint256 scaleFactor = 10 ** (18 - decimals); // <---
return amount / scaleFactor;
}
}
function scaleAmount(uint256 amount, uint8 decimals) internal pure returns (uint256) {
if (decimals == 18) {
return amount;
}
unchecked {
uint256 scaleFactor = 10 ** (18 - decimals); // <---
return amount * scaleFactor;
}
}

But both descaleAmount()and **scaleAmount()**function assumed that all token will have decimals smaller than 18. When token's decimals > 18, it will make it become underflow, lead to unexpected result for protocol.

Impact

unexpected result for protocol due to underflow

Tools Used

Manual review

Recommendations

Handle when decimals > 18 and < 18 separately

Updates

Lead Judging Commences

inallhonesty Lead Judge
11 months ago
inallhonesty Lead Judge 10 months ago
Submission Judgement Published
Invalidated
Reason: Known issue
Assigned finding tags:

[Invalid] Tokens with decimals > 18

Support

FAQs

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