This repository has been archived by the owner on Oct 1, 2023. It is now read-only.
0xRobocop - Lack of a null epoch check on the triggerEndEpoch function could cause a loss of funds #143
Labels
Duplicate
A valid issue that is a duplicate of an issue with `Has Duplicates` label
Escalation Resolved
This issue's escalations have been approved/rejected
Medium
A valid Medium severity issue
Reward
A payout will be made for this issue
0xRobocop
medium
Lack of a null epoch check on the triggerEndEpoch function could cause a loss of funds
Summary
The function
triggerEndEpoch()
at theControllerPeggedAssetV2.sol
contract lacks a check for a null epoch (collateral or premium vault did not received deposits). This means that even if the epoch should have been marked as null, thetriggerEndEpoch()
function can be executed causing loss of funds in the case where the premium vault received deposits and the collateral vault did not.Vulnerability Detail
When the end of an epoch is triggered (no depeg occured), the TVL of the premium vault is sent to the collateral vault (minus fees):
In the case where the premium vault received deposits but the collateral vault did not, means that all the TVL (minus fees) from the premium vault will be sent to the collateral vault, but since nobody minted on the collateral vault, the tokens will get stucked on the collateral vault contract.
Impact
The funds cannot be recovered by changing the
controller
and callingsendTokens
, this is becausesendTokens
can only send a total amount up tofinalTVL[epochId]
, since the collateral vault did not received deposits this value is zero:The scenario is very unlikely because
triggerEndEpoch()
can only be executed afterepochEnd
, meanwhiletriggerNullEpoch()
can be executed right afterepochBegin
. However, when the solution for a black swan event takes 3-5 lines of code the risk must be unacceptable.Code Snippet
https://github.com/sherlock-audit/2023-03-Y2K/blob/main/Earthquake/src/v2/Controllers/ControllerPeggedAssetV2.sol#L81
Tool used
Manual Review
Recommendation
Add the following to the
triggerEndEpoch()
function:Duplicate of #108
The text was updated successfully, but these errors were encountered: