This repository has been archived by the owner on Aug 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
zzykxx - Stargate STG
rewards are accounted incorrectly by StakedStargateAM.sol
#38
Labels
Has Duplicates
A valid issue with 1+ other issues describing the same vulnerability
Medium
A valid Medium severity issue
Reward
A payout will be made for this issue
Sponsor Confirmed
The sponsor acknowledged this issue is valid
Will Fix
The sponsor confirmed this issue will be fixed
Comments
github-actions
bot
added
High
A valid High severity issue
Has Duplicates
A valid issue with 1+ other issues describing the same vulnerability
labels
Feb 21, 2024
This was referenced Feb 21, 2024
1 comment(s) were left on this issue during the judging contest. takarez commented:
|
Duplicate from #18 |
sherlock-admin2
added
the
Will Fix
The sponsor confirmed this issue will be fixed
label
Feb 26, 2024
nevillehuang
added
Medium
A valid Medium severity issue
and removed
High
A valid High severity issue
labels
Feb 27, 2024
The protocol team fixed this issue in PR/commit arcadia-finance/accounts-v2#170. |
sherlock-admin2
added
the
Sponsor Confirmed
The sponsor acknowledged this issue is valid
label
Feb 27, 2024
sherlock-admin2
changed the title
Square Pickle Wren - Stargate
zzykxx - Stargate Feb 28, 2024
STG
rewards are accounted incorrectly by StakedStargateAM.sol
STG
rewards are accounted incorrectly by StakedStargateAM.sol
Fix looks good. Since rewards are claimed on all withdrawals and deposits, reward per token can be calculated directly. |
The Lead Senior Watson signed off on the fix. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
Has Duplicates
A valid issue with 1+ other issues describing the same vulnerability
Medium
A valid Medium severity issue
Reward
A payout will be made for this issue
Sponsor Confirmed
The sponsor acknowledged this issue is valid
Will Fix
The sponsor confirmed this issue will be fixed
zzykxx
high
Stargate
STG
rewards are accounted incorrectly byStakedStargateAM.sol
Summary
Stargate LP_STAKING_TIME contract clears and sends rewards to the caller every time
deposit()
is called but StakedStargateAM does not take it into account.Vulnerability Detail
When either mint() or increaseLiquidity() are called the
assetState[asset].lastRewardGlobal
variable is not reset to0
even though the rewards have been transferred and accounted for on stargate side.After a call to mint() or increaseLiquidity() any subsequent call to either mint(), increaseLiquidity(), burn(), decreaseLiquidity(), claimRewards() or rewardOf(), which all internally call _getRewardBalances(), will either revert for underflow or account for less rewards than it should because
assetState_.lastRewardGlobal
has not been correctly reset to0
butcurrentRewardGlobal
(which is fetched from stargate) has:POC
To copy-paste in
USDbCPool.fork.t.sol
:Impact
Users will not be able to take any action on their positions until
currentRewardGlobal
is greater or equal toassetState_.lastRewardGlobal
. After that they will be able to perform actions but their position will account for less rewards than it should because a total amount ofassetState_.lastRewardGlobal
rewards is nullified.This will also DOS the whole lending/borrowing system if an Arcadia Stargate position is used as collateral because rewardOf(), which is called to estimate the collateral value, also reverts.
Code Snippet
Tool used
Manual Review
Recommendation
Adjust the
assetState[asset].lastRewardGlobal
correctly or since every action (mint()
,burn()
,increaseLiquidity()
,decreaseliquidity()
,claimReward()
) will have the effect of withdrawing all the current rewards it's possible to change the function _getRewardBalances() to use the amount returned by _getCurrentReward() as thedeltaReward
directly:The text was updated successfully, but these errors were encountered: