[WP-H2] ConvexStakingWrapper#deposit()
depositors may lose their funds when the _amount
is huge
#194
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
This issue or pull request already exists
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:The text was updated successfully, but these errors were encountered: