TempleGold

TempleDAO
Foundry
25,000 USDC
View results
Submission Details
Severity: low
Invalid

two auctions can be started with less than auctionsTimeDiff time difference

Summary

In DaiGoldAuction, it is possible to start two auctions with less than config.auctionsTimeDifftime difference.

Vulnerability Details

function recoverTokenis used to recover the templeTokenfor auction which is in cooldown. The amount is specified which is to be recovered and remaining is added in next auction. The function also deletes the data for that epochId which means that auction doesn't exist anymore.

https://github.com/Cyfrin/2024-07-templegold/blob/main/protocol/contracts/templegold/DaiGoldAuction.sol#L284

delete epochs[epochId];

Due to this deletion, it is possible to start an auction even if config.auctionsTimeDifftime hasn't passed. The startAuctionfunction has following checks:

https://github.com/Cyfrin/2024-07-templegold/blob/main/protocol/contracts/templegold/DaiGoldAuction.sol#L105-L111

EpochInfo storage prevAuctionInfo = epochs[_currentEpochId];
if (!prevAuctionInfo.hasEnded()) { revert CannotStartAuction(); }
AuctionConfig storage config = auctionConfig;
/// @notice last auction end time plus wait period
if (_currentEpochId > 0 && (prevAuctionInfo.endTime + config.auctionsTimeDiff > block.timestamp)) {
revert CannotStartAuction();
}

As _currentEpochIdis not updated in recoverTokenand the epochInfodata corresponding to it is deleted, prevAuctionInfo.endTimewill be 0. So, the condition prevAuctionInfo.endTime + config.auctionsTimeDiff > block.timestampwill always pass because config.auctionsTimeDiffwill generally be 1 weeks or 2 weeks. Due to this, it will be possible to start an auction as soon as recoverTokenis called.

Impact

New auction can be started with less difference of auctionsTimeDiff.

Tools Used

Manual review

Recommendations

Do not delete whole epochInfoin recoverToken.

Updates

Lead Judging Commences

inallhonesty Lead Judge 12 months ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement
Assigned finding tags:

two auctions can be started with less than auctionsTimeDiff time difference due to recoverToken deleting the epochs[epochId]

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.