Liquid Staking

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

Underflow in _withdrawRewards Function

Summary
_withdrawRewards function in the OperatorVault contract
https://github.com/Cyfrin/2024-09-stakelink/blob/f5824f9ad67058b24a2c08494e51ddd7efdbb90b/contracts/linkStaking/OperatorVault.sol#L272

In the _withdrawRewards function, the calculation rewards - balance result in an underflow if the balance is greater than rewards. This is because subtracting a larger number (balance) from a smaller number (rewards).

Vulnerability Details

  1. The transaction will revert due to an underflow caused by the subtraction rewards - balance.

Example: If rewards = 100 and balance = 150, the subtraction 100 - 150 results in -50, which is invalid for uint256.

Impact

The underflow will revert the entire transaction, preventing any further operations from being executed. It could disrupt the correct distribution of rewards and block functionality for other users.

Tools Used

manual review

Recommendations

Before performing the subtraction, add a check to ensure that balance is not greater than rewards:

require(rewards >= balance, "Balance exceeds rewards");
Updates

Lead Judging Commences

inallhonesty Lead Judge
about 1 year ago
inallhonesty Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

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