The vulnerability in the LSTRewardsSplitter
contract allows a malicious fee receiver to manipulate the contract's balance during the reward distribution process. By setting the lst
token contract as a fee receiver with a high fee percentage, the attacker can mint new tokens to the LSTRewardsSplitter
contract, causing the principalDeposits
variable to be updated with an incorrect value.
The _splitRewards
function is responsible for distributing rewards to fee receivers based on their configured fee percentages. After distributing the rewards, the function updates the principalDeposits
variable by setting it to the current balance of the contract using lst.balanceOf(address(this))
. However, if one of the fee receivers is the lst
token contract itself, it can manipulate the contract's balance during the reward distribution process.
The vulnerable code is located in the _splitRewards
function of the LSTRewardsSplitter.sol
contract: https://github.com/Cyfrin/2024-09-stakelink/blob/f5824f9ad67058b24a2c08494e51ddd7efdbb90b/contracts/core/lstRewardsSplitter/LSTRewardsSplitter.sol#L173-L187
The lst
token contract, acting as a fee receiver, can mint new tokens to the LSTRewardsSplitter
contract, artificially inflating its balance. As a result, the principalDeposits
variable is updated with an incorrect value, leading to inconsistencies in the contract's state.
Consider this:
The LSTRewardsSplitter
contract with the lst
token contract as one of the fee receivers, configured with a high fee percentage (e.g., 100%).
Deposit a certain amount of tokens into the LSTRewardsSplitter
contract using the deposit
function.
Call the splitRewards
function to trigger the reward distribution process.
During the execution of _splitRewards
, the lst
token contract (acting as a fee receiver) mints a large number of tokens to the LSTRewardsSplitter
contract.
The principalDeposits
variable is updated with the manipulated balance, which includes the newly minted tokens.
The contract's state is now inconsistent, and users may receive incorrect rewards or lose funds.
Test case that simulates the above steps and verifies that the contract's balance and principalDeposits
variable are manipulated by the malicious fee receiver.
Users may receive incorrect rewards or lose funds due to the inconsistent state of the contract.
Manual Review
Instead of updating the principalDeposits
variable based on the contract's balance, track the total rewards distributed and subtract them from the principalDeposits
. This ensures that the principalDeposits
variable accurately reflects the principal deposits made by users.
Consider adding slippage parameter maxRewards
that sets an upper limit on the number of rewards that can be distributed in a single call to _splitRewards
. This helps prevent excessive rewards from being distributed due to balance manipulation.
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.