Open code423n4 opened 2 years ago
@LilYeti : Probably severity 3 due to loss of allocation of funds for other users wrapping LP tokens.
Actually not a problem, the accrued reward is updated as time goes on and should be overridden. Follows same logic from Master chef v2 here: https://snowtrace.io/address/0xd6a4F121CA35509aF06A0Be99093d08462f53052#code
@0xtruco, are you sure of what you are saying? To me the issue seems to still exist. Could you elaborate?
@alcueca Yes you are correct this actually is an issue. I initially thought that we were harvesting rewards just like TJ when users wrapped tokens but turns out that line is not there. This is in the new version of our code but was not in the version submitted at the time of the contest. Thanks for looking into it more! Back to high risk.
Handle
kenzo
Vulnerability details
After updating user's rewards in
_userUpdate
, if the user has not claimed them, and_userUpdate
is called again (eg. on anotherwrap
), the user's unclaimed rewards will lose the previous unclaimed due to wrong calculation.Impact
Loss of yield for user.
Proof of Concept
When updating the user's unclaimedJoeReward, the function doesn't save it's previous value. (Code ref)
So for example, rewards can be lost in the following scenario. We'll mark "acc1" for the value of "accJoePerShare" at step 1.
_userUpdate
is called: unclaimedJOEReward = 0, rewardDebt = 100*acc1.Recommended Mitigation Steps
Change the unclaimed rewards calculation to: