This repository has been archived by the owner on Oct 1, 2023. It is now read-only.
roguereddwarf - ControllerPeggedAssetV2: triggerEndEpoch
function can be called even if epoch is null epoch leading to loss of funds
#108
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
roguereddwarf
medium
ControllerPeggedAssetV2:
triggerEndEpoch
function can be called even if epoch is null epoch leading to loss of fundsSummary
An epoch can be resolved in three ways which correspond to the three functions available in the Controller:
triggerDepeg
,triggerEndEpoch
,triggerNullEpoch
.The issue is that
triggerEndEpoch
can be called even thoughtriggerNullEpoch
should be called."Null epoch" means that any of the two vaults does not have funds deposited. In this case the epoch should be resolved with
triggerNullEpoch
such that funds are not transferred from the premium vault to the collateral vault.So in
triggerEndEpoch
is should be checked whether the conditions for a null epoch apply. If that's the case, thetriggerEndEpoch
function should revert.Vulnerability Detail
The assumption the code makes is that if the null epoch applies,
triggerNullEpoch
will be called before the end timestamp of the epoch which is whentriggerEndEpoch
can be called.This is not necessarily true.
triggerNullEpoch
might not be called in time (e.g. because the epoch duration is very short or simply nobody calls it) and then thetriggerEndEpoch
function can be called which sends the funds from the premium vault into the collateral vault:https://github.com/sherlock-audit/2023-03-Y2K/blob/main/Earthquake/src/v2/Controllers/ControllerPeggedAssetV2.sol#L172-L192
If the premium vault is the vault which has funds and the collateral vault does not, then the funds sent to the collateral vault are lost.
Impact
Loss of funds for users that have deposited into the premium vault.
Code Snippet
https://github.com/sherlock-audit/2023-03-Y2K/blob/main/Earthquake/src/v2/Controllers/ControllerPeggedAssetV2.sol#L144-L202
Tool used
Manual Review
Recommendation
triggerEndEpoch
should only be callable when the conditions for a null epoch don't apply:The text was updated successfully, but these errors were encountered: