A critical reentrancy vulnerability exists in the splitRewards function of the LSTRewardsSplitter.sol contract. This flaw allows malicious fee receivers to exploit the contract by re-entering the splitRewards function during external calls, leading to unauthorized manipulation of rewards distribution and potential draining of funds.
Explanation:
The _splitRewards function iterates through all fee receivers and performs external calls (lst.safeTransfer or IStakingPool(address(lst)).burn) before updating the critical state variable principalDeposits. This sequence violates the Checks-Effects-Interactions pattern, leaving the contract vulnerable to reentrancy attacks.
Explanation:
A malicious contract like MaliciousFeeReceiver can be set as a fee receiver. Upon receiving tokens, its onTokenTransfer function is triggered, which calls back into the vulnerable splitRewards function before principalDeposits is updated. This reentrancy allows the attacker to manipulate the rewards distribution.
Explanation:
When splitRewards is called, it calculates newRewards based on the current lst.balanceOf and principalDeposits. However, if a reentrant call occurs within _splitRewards, principalDeposits has not yet been updated, leading to inaccurate calculations and potential exploitation of the rewards mechanism.
An attacker controlling a fee receiver can:
Re-enter the splitRewards Function: By triggering reentrancy during external calls, the attacker can call splitRewards multiple times before principalDeposits is updated.
Manipulate Rewards Calculation: Repeated reentrant calls can allow the attacker to receive more rewards than intended, effectively draining funds from the contract.
Disrupt Reward Distribution: The inconsistent state can lead to incorrect reward distributions, undermining the integrity and reliability of the staking platform.
Potential Consequences:
Financial Losses: Significant funds could be siphoned off, impacting all stakers and the overall platform's financial health.
Erosion of Trust: Such vulnerabilities can erode user trust, leading to decreased participation and potential abandonment of the platform.
Manual Review
Solution:
Integrate OpenZeppelin's ReentrancyGuard to prevent reentrant calls.
Explanation:
The nonReentrant modifier ensures that the splitRewards function cannot be called while it is already in execution, effectively blocking reentrancy attempts.
Solution:
Rearrange the _splitRewards function to update state variables before making external calls.
Explanation:
By updating principalDeposits before any external interactions, the contract ensures that its state remains consistent, mitigating the risk of reentrancy attacks.
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.