Open code423n4 opened 2 years ago
duplicated with https://github.com/code-423n4/2022-02-concur-findings/issues/224
The warden has shown how casting without safe checks can cause the accounting to break and cause end users to loose deposited tokens.
While the finding has merit I believe that because this applies to niche situations, and is conditional on specific inputs, that Medium Severity is more appropriate
Lines of code
https://github.com/code-423n4/2022-02-concur/blob/72b5216bfeaa7c52983060ebfc56e72e0aa8e3b0/contracts/ConvexStakingWrapper.sol#L228-L250
Vulnerability details
When the value of
_amount
is larger thantype(uint192).max
, due to unsafe type casting, the recorded deposited amount can be much smaller than their invested amount.https://github.com/code-423n4/2022-02-concur/blob/72b5216bfeaa7c52983060ebfc56e72e0aa8e3b0/contracts/ConvexStakingWrapper.sol#L228-L250
PoC
When
_amount
=uint256(type(uint192).max) + 1
:uint192(_amount)
=0
,deposits[_pid][msg.sender].amount
=0
;uint256(type(uint192).max) + 1
will be transferFrommsg.sender
.Expected results:
deposits[_pid][msg.sender].amount
==uint256(type(uint192).max) + 1
;Actual results:
deposits[_pid][msg.sender].amount
=0
.The depositor loses all their invested funds.
Recommendation
Consider adding a upper limit for the
_amount
parameter: