-
Notifications
You must be signed in to change notification settings - Fork 8
hash - Division difference can result in a revert when claiming treasury yield and excess rewards to some users #190
Comments
Hello Indeed this is a real problem due the way that the invariant : And so some positions will become not claimable on the We'll correct this by computing the same way the ysTotal & ysPartial on the balanceYs & ysCheckpoint Very nice finding, it'd break the claim for the last users to claim. |
Escalate |
You've created a valid escalation! To remove the escalation from consideration: Delete your comment. You may delete or edit your escalation comment anytime before the 48-hour escalation window closes. After that, the escalation becomes final. |
|
Worst case scenario, only the last user will be unable to claim their rewards (even though I described above why it is highly unlikely). In the rare situation it happens, it can be fixed by simply sending a few wei to the contract. |
Imo, just off point 1 alone, this warrants medium severity at the least. The fact that a donation is required to fix this means there is a bug, and is not intended functionality of the function. |
I agree that this is a borderline low/med. Planning to accept the escalation and consider this a low severity issue. |
@Czar102 please consider report #132 which I submitted which allows to steal an arbitrary amount from the rewards under some conditions, which is a higher impact. My issue shares the same root cause as this one, so I did not escalate for deduplication. However if you think that this issue should be low, maybe it would be more fair to make my issue unique since the impact is sufficient. |
#132 and this #190 shares the same impact, if this is invalid, #132 should be invalid as well. Namely the following two impact:
Both examples present used involve relatively low amounts, so I'm unsure what is the exact impact Comparing this issue attack path
and #132
Comparing this issue impact
and #132
My opinion is both issues should remain valid medium severity issue based on impact highlighted in both issues. |
After some discussion with @nevillehuang, agree that issues should stay duplicated and valid
|
To summarize:
Issue should remain Low severity |
I agree that the fix of sending minor amounts of all reward tokens won't cost the team any considerable loss financially. But apart from the fix, the impact under reasonable conditions of user not being able to withdraw their rewards is certainly a major one. |
Due to the additional impact noted (thank you @CergyK) I think the loss can be sufficient to warrant a medium severity for this issue (loss of funds, but improbable assumptions are made). |
Result: |
Escalations have been resolved successfully! Escalation status:
|
This issue has been solved here : https://github.com/Cvg-Finance/sherlock-cvg/pull/4 Follow the comments : |
Fix looks good. Order of operations has been updated to consistently reflect the proper value |
hash
medium
Division difference can result in a revert when claiming treasury yield and excess rewards to some users
Summary
Different ordering of calculations are used to compute
ysTotal
in different situations. This causes the totalShares tracked to be less than the claimable amount of sharesVulnerability Detail
ysTotal
is calculated differently when adding tototalSuppliesTracking
and when computingbalanceOfYsCvgAt
.When adding to
totalSuppliesTracking
, the calculation ofysTotal
is as follows:In
balanceOfYsCvgAt
,ysTotal
is calculated as followsThis difference allows the
balanceOfYsCvgAt
to be greater than what is added tototalSuppliesTracking
POC
Calculation in
totalSuppliesTracking
gives:Calculation in
balanceOfYsCvgAt
gives:Example Scenario
Alice, Bob and Jake locks cvg for 1 TDE and obtains rounded up
balanceOfYsCvgAt
. A user who is aware of this issue can exploit this issue further by usingincreaseLockAmount
with small amount values by which the total difference difference b/w the user's calculatedbalanceOfYsCvgAt
and the accounted amount intotalSuppliesTracking
can be increased. Bob and Jake claims the reward at the end of reward cycle. When Alice attempts to claim rewards, it reverts since there is not enough reward to be sent.Impact
This breaks the shares accounting of the treasury rewards. Some user's will get more than the actual intended rewards while the last withdrawals will result in a revert
Code Snippet
totalSuppliesTracking
calculationIn
mintPosition
https://github.com/sherlock-audit/2023-11-convergence/blob/main/sherlock-cvg/contracts/Locking/LockingPositionService.sol#L261-L263
In
increaseLockAmount
https://github.com/sherlock-audit/2023-11-convergence/blob/e894be3e36614a385cf409dc7e278d5b8f16d6f2/sherlock-cvg/contracts/Locking/LockingPositionService.sol#L339-L345
In
increaseLockTimeAndAmount
https://github.com/sherlock-audit/2023-11-convergence/blob/main/sherlock-cvg/contracts/Locking/LockingPositionService.sol#L465-L470
_ysCvgCheckpoint
https://github.com/sherlock-audit/2023-11-convergence/blob/main/sherlock-cvg/contracts/Locking/LockingPositionService.sol#L577-L584
balanceOfYsCvgAt
calculationhttps://github.com/sherlock-audit/2023-11-convergence/blob/main/sherlock-cvg/contracts/Locking/LockingPositionService.sol#L673-L675
Tool used
Manual Review
Recommendation
Perform the same calculation in both places
The text was updated successfully, but these errors were encountered: