This repository has been archived by the owner on Oct 1, 2023. It is now read-only.
minhtrng - Inconsistent use of epochBegin could lock user funds #480
Labels
Has Duplicates
A valid issue with 1+ other issues describing the same vulnerability
Medium
A valid Medium severity issue
Reward
A payout will be made for this issue
Sponsor Confirmed
The sponsor acknowledged this issue is valid
Will Fix
The sponsor confirmed this issue will be fixed
minhtrng
medium
Inconsistent use of epochBegin could lock user funds
Summary
The epochBegin timestamp is used inconsistently and could lead to user funds being locked.
Vulnerability Detail
The function
ControllerPeggedAssetV2.triggerNullEpoch
checks for timestamp like this:The modifier
epochHasNotStarted
(used byCarousel.deposit
) checks it like this:Both functions can be called when
block.timestamp == epochBegin
. This could lead to a scenario where a deposit happens aftertriggerNullEpoch
is called (both in the same block). BecausetriggerNullEpoch
sets the value forfinalTVL
, the TVL that comes from the deposit is not accounted for. If emissions have been distributed this epoch, this will lead to the incorrect distribution of emissions and once all emissions have been claimed the remaining assets will not be claimable, due to reversion inwithdraw
when trying to send emissions:The above could also lead to revert through division by 0 if
finalTVL
is set to 0, even though the deposit after was successful.Impact
incorrect distribution, Loss of deposited funds
Code Snippet
https://github.com/sherlock-audit/2023-03-Y2K/blob/ae7f210d8fbf21b9abf09ef30edfa548f7ae1aef/Earthquake/src/v2/VaultV2.sol#L433
Tool used
Manual Review
Recommendation
The modifier
epochHasNotStarted
should use>=
as comparatorThe text was updated successfully, but these errors were encountered: