Open code423n4 opened 2 years ago
Assets are not a direct risk if it is the first user disrupting the contract. We would need to redeploy better code, but that's it. I suggest this is reported as medium, as merits for a DoS attack.
As suggested elsewhere, the right solution if uint128 is to be used in storage, is to cast up to uint256 for calculations, and then back to uint128 to store again.
The warden identified a way an early depositor can grief the system, I believe the finding to be valid, and because:
I believe medium severity to be appropriate
Handle
WatchPug
Vulnerability details
https://github.com/code-423n4/2022-01-yield/blob/e946f40239b33812e54fafc700eb2298df1a2579/contracts/ConvexStakingWrapper.sol#L206-L224
reward.reward_integral
isuint128
, if a early user mint (wrap) just1
Wei ofconvexToken
, and make_supply == 1
, and then tranferring5e18
ofreward_token
to the contract.As a result,
reward.reward_integral
can exceedtype(uint128).max
and overflow, causing the rewards distribution to be disrupted.Recommendation
Consider
wrap
a certain amount of initial totalSupply, e.g.1e8
, and never burn it. And consider using uint256 instead of uint128 forreward.reward_integral
. Also, consdier lower1e20
down to1e12
.