Lucene search

K
code423n4Code4renaCODE423N4:2023-09-RESERVE-MITIGATION-FINDINGS-ISSUES-13
HistorySep 27, 2023 - 12:00 a.m.

M-05 MitigationConfirmed

2023-09-2700:00:00
Code4rena
github.com
7
stakingcontract vulnerability
mitigation resolved
emergency withdraw

AI Score

7.2

Confidence

High

Lines of code

Vulnerability details

In the previous implementation
when stakingContract.totalAllocPoint = 0
stakingContract.withdraw() and stakingContract.deposit() will div 0 , revert
This results in StargateRewardableWrapper no longer being able to execute StargateRewardableWrapper.withdraw()
The user’s token is locked

Mitigation

PR 896
Add determine if poolInfo.allocPoint is equal to 0.
If equal to 0, use stakingContract.emergencyWithdraw() instead of stakingContract.deposit() to avoid revert
the mitigation resolved the original issue.

Suggestion

Since allocPoint==0 is used instead of totalAllocPoint==0
there may be a case where allocPoint == 0 but totalAllocPoint> 0.
But the modified version still uses stakingContract.emergencyWithdraw(), which discards all rewards.
It is recommended that if totalAllocPoint> 0 ,we can execute the
stakingContract.deposit(0) to retrieve the reward first, then execute stakingContract.emergencyWithdraw().


The text was updated successfully, but these errors were encountered:

All reactions

AI Score

7.2

Confidence

High