You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Aug 18, 2024. It is now read-only.
sherlock-admin opened this issue
Feb 16, 2024
· 0 comments
Labels
DuplicateA valid issue that is a duplicate of an issue with `Has Duplicates` labelMediumA valid Medium severity issueRewardA payout will be made for this issue
assetState_.lastRewardGlobal is not cleared during deposit
Summary
When new deposit is done to the stargate, then all earned rewards are sent to the caller. Because assetState_.lastRewardGlobal is not reset to 0 as it's done for other functions that work with balance, then rewards distribution becomes incorrect and broken.
Vulnerability Detail
User can claim rewards using burn, decreaseLiquidity and claimReward functions. All of them then set assetState_.lastRewardGlobal to 0. This variable tracks the increase of earned rewards fro the contract between rewards claiming. Once rewards are claimed, then it should be cleared.
AbstractStakingAM contract incorrectly assumes, that only withdrawing from LP_STAKING_TIME claims rewards. This is not true and when deposit occurs, then rewards are claimed as well.
When user deposits to AbstractStakingAM then rewards are claimed, but assetState_.lastRewardGlobal is not set to 0. As result, rewards distribution will be incorrect. Also for some time _getRewardBalances function will revert because of underflow as _getCurrentReward will likely return smaller value than assetState_.lastRewardGlobal. After some time function will continue working again.
Impact
Rewards accounting is corrupted, contract can be dosed for some time.
Code Snippet
Provided above
Tool used
Manual Review
Recommendation
As deposit also claims rewards, then you need to clear assetState_.lastRewardGlobal variable.
sherlock-admin2
changed the title
Furry Midnight Unicorn - assetState_.lastRewardGlobal is not cleared during deposit
rvierdiiev - assetState_.lastRewardGlobal is not cleared during deposit
Feb 28, 2024
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
DuplicateA valid issue that is a duplicate of an issue with `Has Duplicates` labelMediumA valid Medium severity issueRewardA payout will be made for this issue
rvierdiiev
high
assetState_.lastRewardGlobal is not cleared during deposit
Summary
When new deposit is done to the stargate, then all earned rewards are sent to the caller. Because
assetState_.lastRewardGlobal
is not reset to 0 as it's done for other functions that work with balance, then rewards distribution becomes incorrect and broken.Vulnerability Detail
User can claim rewards using
burn
,decreaseLiquidity
andclaimReward
functions. All of them then setassetState_.lastRewardGlobal
to 0. This variable tracks the increase of earned rewards fro the contract between rewards claiming. Once rewards are claimed, then it should be cleared.AbstractStakingAM contract incorrectly assumes, that only withdrawing from
LP_STAKING_TIME
claims rewards. This is not true and when deposit occurs, then rewards are claimed as well.When user deposits to
AbstractStakingAM
then rewards are claimed, butassetState_.lastRewardGlobal
is not set to 0. As result, rewards distribution will be incorrect. Also for some time_getRewardBalances
function will revert because of underflow as_getCurrentReward
will likely return smaller value thanassetState_.lastRewardGlobal
. After some time function will continue working again.Impact
Rewards accounting is corrupted, contract can be dosed for some time.
Code Snippet
Provided above
Tool used
Manual Review
Recommendation
As deposit also claims rewards, then you need to clear
assetState_.lastRewardGlobal
variable.Duplicate of #38
The text was updated successfully, but these errors were encountered: