code-423n4 / 2022-06-notional-coop-findings

1 stars 1 forks source link

Upgraded Q -> M from 104 [1656258768065] #239

Open code423n4 opened 2 years ago

code423n4 commented 2 years ago

Judge has assessed an item in Issue #104 as Medium risk. The relevant finding follows:

L01: Silent overflow of _fCashAmount

Line References

https://github.com/code-423n4/2022-06-notional-coop/blob/6f8c325f604e2576e2fe257b6b57892ca181509a/index-coop-notional-trade-module/contracts/protocol/modules/v1/NotionalTradeModule.sol#L526

Description

If a _fCashAmount value that is greater than uint88 is passed into the _mint function, downcasting it to uint88 will silently overflow.

Recommended Mitigation Steps

// Use a safe downcast function e.g. wfCashLogic::_safeUint88
function _safeUint88(uint256 x) internal pure returns (uint88) {hil
    require(x <= uint256(type(uint88).max));
    return uint88(x);
}
ckoopmann commented 2 years ago

Somehow missed this one earlier. This seems reasonable and we'll probably adopt the suggested mitigation approach.