Miscalculation of stake level can impact availability of some functions of the protocol for users, change their fee discount (funds loss) or change voting power (protocol's critical functionality).
Proof of Concept
Even if the user has suprassed the threshold for a stake level, they may not be on this stake level. For example, when the user has a half of the token more than the threshold, getUserStakePower() will return the value rounded down and getUserStakeLevel() will see the number at threshold, claiming that the stake level is lower than it really is.
Tools Used
Manual analysis
Recommended Mitigation Steps
Either use getUserStakeLevel() with raw amount of tokens (token wei) or claim that the user achieved the threshold when they have at least the THRESHOLD_AMOUNT, causing the rounding not to change the result.
Potentially an off by 1 error due to rounding. This is a fair improvement consideration. Lowering risk and converting this into a QA report for the warden.
Lines of code
https://github.com/code-423n4/2022-06-infinity/blob/main/contracts/staking/InfinityStaker.sol#L226-L238 https://github.com/code-423n4/2022-06-infinity/blob/main/contracts/staking/InfinityStaker.sol#L205-L224
Vulnerability details
Impact
Miscalculation of stake level can impact availability of some functions of the protocol for users, change their fee discount (funds loss) or change voting power (protocol's critical functionality).
Proof of Concept
Even if the user has suprassed the threshold for a stake level, they may not be on this stake level. For example, when the user has a half of the token more than the threshold,
getUserStakePower()
will return the value rounded down andgetUserStakeLevel()
will see the number at threshold, claiming that the stake level is lower than it really is.Tools Used
Manual analysis
Recommended Mitigation Steps
Either use
getUserStakeLevel()
with raw amount of tokens (token wei) or claim that the user achieved the threshold when they have at least theTHRESHOLD_AMOUNT
, causing the rounding not to change the result.