This repository has been archived by the owner on Oct 1, 2023. It is now read-only.
Inspex - The function that has epochHasNotStarted
modifier can be called even if epoch is at the start state.
#162
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
Inspex
medium
The function that has
epochHasNotStarted
modifier can be called even if epoch is at the start state.Summary
The
epochHasNotStarted
modifier was improperly used with>
, causing the begin block to remain in a not-started state.Vulnerability Detail
The
deposit()
function is used to deposit assets into the vault for purchasing or selling insurance of stable tokens before theblock.timestamp
reaches theepochBegin
state. This is limited by theepochHasNotStarted
modifier in line 102.https://github.com/sherlock-audit/2023-03-Y2K/blob/main/Earthquake/src/v2/VaultV2.sol#L93-L115
However, if the
block.timestamp
reaches theepochBegin
state, the epoch state will still be not-started state due to the improper check in theepochHasNotStarted
modifier in line 433.https://github.com/sherlock-audit/2023-03-Y2K/blob/main/Earthquake/src/v2/VaultV2.sol#L432-L436
This results in a contradiction with other logic in both the controller and the documentation.
https://github.com/sherlock-audit/2023-03-Y2K/blob/main/Earthquake/src/v2/Controllers/ControllerPeggedAssetV2.sol#L73
https://github.com/sherlock-audit/2023-03-Y2K/blob/main/Earthquake/src/v2/Controllers/ControllerPeggedAssetV2.sol#L224
Impact
The user can call functions that have
epochHasNotStarted
modifier whenblock.timestamp
is equal theepochBegin
state.Moreover, the user can call both the
deposit()
andtriggerDepeg()
functions to receive the maximum benefit in a single transaction when the currentblock.timestamp
is equal the value in theepochBegin
state and the token has already depegged. Proof of concept as shown below.Code Snippet
https://github.com/sherlock-audit/2023-03-Y2K/blob/main/Earthquake/src/v2/VaultV2.sol#L432-L436
Tool used
Manual Review
Recommendation
We suggest changing the validation in the
epochHasNotStarted
modifier to>=
.Duplicate of #480
The text was updated successfully, but these errors were encountered: