Closed code423n4 closed 1 year ago
hansfriese marked the issue as satisfactory
hansfriese marked the issue as duplicate of #304
hansfriese marked the issue as duplicate of #261
hansfriese marked the issue as not a duplicate
hansfriese marked the issue as duplicate of #304
hansfriese changed the severity to QA (Quality Assurance)
hansfriese marked the issue as grade-c
Lines of code
https://github.com/code-423n4/2023-03-neotokyo/blob/main/contracts/staking/NeoTokyoStaker.sol#L1077 https://github.com/code-423n4/2023-03-neotokyo/blob/main/contracts/staking/NeoTokyoStaker.sol#L1098 https://github.com/code-423n4/2023-03-neotokyo/blob/main/contracts/staking/NeoTokyoStaker.sol#L1155
Vulnerability details
Impact
Due to integer division, users will lose points when staking a small amount of BYTES into Citizen. The value of points affects user rewards. Users should be treated equally no matter how much they stake.
Proof of Concept
Let's take a look at the code snippet of the
_stakeBytes
function:It can be clearly seen from the code that if the
amount
is less than 2e18,bonusPoints
is equal to 0, thencitizenStatus.points
will not increased.citizenStatus.points
is the most critical parameter when calculating rewards. We can see its effect in getPoolReward.Through the comments and codes of
_BYTES_PER_POINT
, we can conclude that one point requires 2e18 BYTES. But the_stakeBytes
function does not check theamount
parameter, which leads to user losses.Tools Used
Manual Review
Recommended Mitigation Steps
We need to check the
amount
parameter to make it a multiple of 2e18.