Open code423n4 opened 3 years ago
nTokenBalance is int256 on the stack but cannot be stored as a negative number. There does not appear to be away to actually generate an overflow this way. https://github.com/code-423n4/2021-08-notional/blob/main/contracts/internal/balances/BalanceHandler.sol#L379
per sponsor comment, making this a best practice recommendation ergo non-critical
Handle
Omik
Vulnerability details
Impact
in the https://github.com/code-423n4/2021-08-notional/blob/main/contracts/internal/balances/Incentives.sol#L84 When doing claim incentive, it reads from the storedntokenbalance, and change it from int to uint, it works as expected when the storedntokenbalance is positive, but when the value of the storedntokenbalance become negative, the negative value of int, would be change to uint unsafely, and can make storedntokenbalance extremely high when claiming incentives.
Proof of Concept
https://github.com/code-423n4/2021-08-notional/blob/main/contracts/internal/balances/Incentives.sol#L84
Recommended Mitigation Steps
use openzepplin safecast