The LSTRewardsSplitter contract has a vulnerability in how it manages principal deposits. Specifically, the contract allows negative rewards to be deducted directly from principalDeposits, which can cause confusion and potential issues with the contract's balance. If principalDeposits falls below its actual value, it may lead to incorrect reward calculations or unintended withdrawals.
In the performUpkeep and splitRewards functions, the contract calculates the difference between the current token balance and the stored principalDeposits. This difference is considered "new rewards." If the calculated difference is negative (i.e., if there are fewer tokens than the principalDeposits), the contract reduces the value of principalDeposits by the negative difference. This reduction blurs the distinction between principal and rewards, potentially causing confusion and making it difficult to accurately track user deposits versus the rewards generated by the system.
A specific concern arises when negative rewards are encountered. Reducing the principalDeposits in this manner can make it unclear what portion of the contract’s balance is principal (the original deposit) and what portion is rewards (additional tokens). Over time, this can lead to inaccuracies in tracking the correct amount that should be withdrawn or distributed to users. Furthermore, if the principal becomes incorrect, users may withdraw more tokens than intended or lose some of their rightful deposits.
The following Hardhat test simulates the scenario where negative rewards lead to a decrease in principal:
The vulnerability in principal management can lead to incorrect tracking of deposits and rewards, which may allow:
Users to withdraw more tokens than they have deposited, causing financial loss to the contract.
The contract balance to be misrepresented, leading to an imbalance in rewards distribution.
Over time, as more rewards are distributed, the principal deposit amount could become severely corrupted, leading to significant losses or unintended withdrawals.
Manual review.
To mitigate this issue, the contract should clearly separate the management of principal deposits and rewards:
Ensure that principal deposits are always tracked independently from rewards, and do not allow negative rewards to modify principalDeposits.
If negative rewards are detected, do not allow the principal to be adjusted beyond the actual deposit amount.
Add checks to ensure that principalDeposits always accurately reflects the original deposit amounts and that any reduction is handled explicitly.
If the balance is reduced externally (outside of user withdrawals), the contract should handle this event as an error instead of modifying the principal.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.