Closed c4-bot-5 closed 7 months ago
141345 marked the issue as insufficient quality report
the mitigation makes no diff
thereksfour marked the issue as unsatisfactory: Insufficient proof
Hi @thereksfour ,
this issue clearly states that withdrawing and claiming rewards via withdrawWithRewards()
will result in claiming more rewards as it uses the old balance of the user before he withdrew:
withdrawWithRewards
will first update used rewards based on his original balancethen the rewards will be claimed based on the old unlocked balance instead of the new unlocked balance that has been decreased as the function misses _updateRewardsForUser
before claiming rewards
Could you please have a second look an re-evaluate? Thanks!
Invalid, the added _updateRewardsForUser in the recommendation will do nothing, because userRewardPerTokenPaid has been updated in withdraw, which makes the _earned of _updateRewardsForUser in the recommendation return 0. Also, if you disagree, please provide a step-by-step POC to illustrate the issue.
Lines of code
https://github.com/code-423n4/2024-03-abracadabra-money/blob/1f4693fdbf33e9ad28132643e2d6f7635834c6c6/src/staking/LockingMultiRewards.sol#L186-L189
Vulnerability details
Impact
LockingMultiRewards.withdrawWithRewards
function enables users to withdraw an amount of their unlocked staked deposits and then claim their accumulated rewards in the same function:where first the withdrawal of the unlocked staked amount is executed, but before that the accumulated rewards of the user are updated via
_updateRewardsForUser()
, then his unlocked balance is decreased by the withdrawn amount:then after the withdrawal is executed, the
_getRewards()
function is invoked to transfer the rewards for the user.But as can be noticed, the
_getRewards()
function is invoked directly after thewithdraw()
function without updating the user rewards based on his new balance after the withdrawal, and this will result in the user claiming more rewards than he is entitled to, because his old balance before withdrawal is the one used to calculate his accumulated rewards.To assure that this is a vulnerability/missing update: the
getRewards()
function that is intended to send the accumulated rewards to the user updates the rewards of the user based on his current balance (locked and unlocked) before sending them.Proof of Concept
LockingMultiRewards.withdrawWithRewards function
Tools Used
Manual Review.
Recommended Mitigation Steps
Update
withdrawWithRewards()
function to update user's uncalimed rewards based on his current balance (similar mechanism to thegetRewards()
function):Assessed type
Context