startTime and endTime could be same while updating funding rate.
Proof of Concept
_updateFundingRate updates the pointer to the latest funding payment timestamp i.e; latestFundingPaymentPointer
the problem with _updateFundingRate is in if statement i.e; when latestFundingPaymentPointer is zero, it updates
latestFundingPaymentPointer to fundingRates[latestFundingPaymentPointer] = (amount * 1e18) / (endTime - startTime); without checking if the startTime and endTime are same.
Updating funding rate when latestFundingPaymentPointer is zero makes the findingrates mapping set to infinity, which should not be the case.
Lines of code
https://github.com/code-423n4/2023-08-dopex/blob/main/contracts/perp-vault/PerpetualAtlanticVault.sol#L594-L614
Vulnerability details
Impact
startTime and endTime could be same while updating funding rate.
Proof of Concept
_updateFundingRate updates the pointer to the latest funding payment timestamp i.e;
latestFundingPaymentPointer
the problem with _updateFundingRate is in if statement i.e; when latestFundingPaymentPointer is zero, it updates latestFundingPaymentPointer tofundingRates[latestFundingPaymentPointer] = (amount * 1e18) / (endTime - startTime);
without checking if the startTime and endTime are same. Updating funding rate when latestFundingPaymentPointer is zero makes the findingrates mapping set to infinity, which should not be the case.Tools Used
Manual
Recommended Mitigation Steps
check startTime and endTime should not be the same as in else statement,
if (endTime == startTime) return;
https://github.com/code-423n4/2023-08-dopex/blob/main/contracts/perp-vault/PerpetualAtlanticVault.sol#L609-L609Assessed type
Other