code-423n4 / 2021-07-spartan-findings

0 stars 0 forks source link

Possible divide by zero errors in `Utils` #232

Open code423n4 opened 3 years ago

code423n4 commented 3 years ago

Handle

shw

Vulnerability details

Impact

Several functions in Utils do not handle edge cases where the divisor is 0, caused mainly by no liquidity in the pool. In such cases, the transactions revert without returning a proper error message.

Proof of Concept

Referenced code: Utils.sol#L75 Utils.sol#L90 Utils.sol#L109-L110 Utils.sol#L123-L124 Utils.sol#L131 Utils.sol#L138 Utils.sol#L155 Utils.sol#L189 Utils.sol#L195 Utils.sol#L215

Recommended Mitigation Steps

Check if the divisors are 0 in the above functions to handle edge cases.