code-423n4 / 2021-12-defiprotocol-findings

0 stars 0 forks source link

divide-before-multiply #155

Closed code423n4 closed 2 years ago

code423n4 commented 2 years ago

Handle

0v3rf10w

Vulnerability details

Impact

divide-before-multiply can lead to miscalculation of fees in below function

Proof of Concept

Vulnerable Function : Basket.handleFees(uint256) (Basket.sol#133-153) :

        uint256 feePct = timeDiff * licenseFee / ONE_YEAR;
        uint256 fee = startSupply * feePct / (BASE - feePct);
        _mint(publisher, fee * (BASE - factory.ownerSplit()) / BASE);
        _mint(Ownable(address(factory)).owner(), fee * factory.ownerSplit() / BASE);

Tools Used

Manual and Slither

Recommended Mitigation Steps

Consider ordering multiplication before division to prevent miscalculation

0xleastwood commented 2 years ago

Duplicate of #60