Liquid Staking

Stakelink
DeFiHardhatOracle
50,000 USDC
View results
Submission Details
Severity: medium
Invalid

Inconsistent Integer Type Declarations Leading to Potential Arithmetic Errors

Summary

The getDepositChange function in the smart contract uses implicit integer type declarations (int and uint) instead of explicit types (int256 and uint256). This inconsistency can lead to potential arithmetic errors, especially when interacting with other parts of the contract or external contracts that expect specific integer sizes.

Vulnerability Details

The vulnerability arises from the use of implicit integer types in the getDepositChange function. The function uses int and uint without specifying their sizes, which can lead to inconsistencies and potential errors.

https://github.com/Cyfrin/2024-09-stakelink/blob/f5824f9ad67058b24a2c08494e51ddd7efdbb90b/contracts/linkStaking/base/VaultControllerStrategy.sol#L494-L500

function getDepositChange() public view virtual returns (int) {
@=> uint256 totalBalance = token.balanceOf(address(this));
@=> for (uint256 i = 0; i < vaults.length; ++i) {
totalBalance += vaults[i].getTotalDeposits();
}
@=> return int(totalBalance) - int(totalDeposits);
}

Impact

  • Implicit type declarations can lead to overflow or underflow issues, especially if the contract logic assumes a specific integer size.

  • When interacting with other contracts or systems that expect specific integer sizes, the use of implicit types can lead to unexpected behavior or errors.

Tools Used

Manual review

Recommendations

Update the getDepositChange function to use explicit integer types.

- function getDepositChange() public view virtual returns (int) {
+ function getDepositChange() public view returns (int256) {
uint256 totalBalance = token.balanceOf(address(this));
for (uint256 i = 0; i < vaults.length; ++i) {
totalBalance += vaults[i].getTotalDeposits();
}
- return int(totalBalance) - int(totalDeposits);
+ return int256(totalBalance) - int256(totalDeposits);
}
Updates

Lead Judging Commences

inallhonesty Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

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