code-423n4 / 2021-10-mochi-findings

0 stars 0 forks source link

Unsafe `int256` casts in `accrueDebt` #128

Closed code423n4 closed 3 years ago

code423n4 commented 3 years ago

Handle

cmichel

Vulnerability details

As MochiVault.accrueDebt function performs unsafe casts: claimable += int256(increased);.

If the unsigned values are above the maximum signed value (type(int256).max), it will be interpreted as a negative value instead.

Impact

Even though overflowing the max int256 value is unlikely, it's still recommended to use safe casts.

Recommended Mitigation Steps

Make sure the value fits into the type first by using a SafeCast library.