code-423n4 / 2021-06-tracer-findings

1 stars 0 forks source link

The `averagePriceForPeriod` function may revert without proper error message returned #140

Open code423n4 opened 3 years ago

code423n4 commented 3 years ago

Handle

shw

Vulnerability details

Impact

The averagePriceForPeriod function of LibPrices does not handle the case where j equals 0 (i.e., no trades happened in the last 24 hours). The transaction reverts due to dividing by 0 without a proper error message returned.

Proof of Concept

Referenced code: LibPrices.sol#L73

Recommended Mitigation Steps

Add require(j > 0, "...") before line 73 to handle this special case.