Closed sherlock-admin4 closed 6 months ago
Not valid
1 comment(s) were left on this issue during the judging contest.
panprog commented:
invalid, staking for a short time does nothing, since reward for staking is accumulated over time, not instantly.
Bauer
high
distributeYield()
may be front-run by bad actors to steal rewardSummary
In the
distributeYield()
function, the protocol deposits rewards into the corresponding contract and then updates therewardRate
. Malicious users can front-run to steal rewards from itVulnerability Detail
The function
distributeYield()
is responsible for distributing available yield within this contract to appropriate entities. Within this function, the protocol callsdepositReward()
to update the value ofrewardData[_rewardsToken].rewardRate
. The issue here is that malicious users can front-rundistributeYield()
. A bad actor monitors transactions in the transaction pool and, upon detectingdistributeYield()
in the pool, first callsstake()
to stake tokens. Then, afterdistributeYield()
executes, they callgetRewards()
to profit.Impact
Front-running to profit, causing reduced rewards for other users
Code Snippet
https://github.com/sherlock-audit/2024-03-zivoe/blob/main/zivoe-core-foundry/src/ZivoeYDL.sol#L213-L310
Tool used
Manual Review
Recommendation