recordStakingError() missing execution decreaseMinipoolCount() #511
Labels
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
bug
Something isn't working
duplicate-235
satisfactory
satisfies C4 submission criteria; eligible for awards
sponsor duplicate
Sponsor deemed duplicate
Lines of code
https://github.com/code-423n4/2022-12-gogopool/blob/aec9928d8bdce8a5a4efe45f54c39d4fc7313731/contracts/contract/MinipoolManager.sol#L484-L515
Vulnerability details
Impact
recordStakingError() no reduction minipoolcount resulting in no stake, and you can still get rewards
Proof of Concept
minipoolCount will be increased or decreased during state transfer
1.->Prelaunch: minipoolCount++
2.->Withdrawable: minipoolcount--
3.->Canceled: minipoolCount--
Other states do not operate on minipoolCount
However, according to the existing state transfer, the following path exists:
->Prelaunch(+1)->Launched->ERROR->Finished
If the above path is executed, minipoolCount will be increased by 1, because ERROR does not reduce minipoolcount.
minipoolCount represents how many minipools the user currently has, and when it equals 0, it will no longer be able to get rewards.
The RewardsStartTime is set to 0 when minipoolCount==0 by the following control
This will result in the minipoolCount always being greater than 0, although there is no more stake, you can still get the reward.
test code:
forge test --match testMinipoolCountError
Tools Used
Recommended Mitigation Steps
The text was updated successfully, but these errors were encountered: