The tokens in in SpiceAuction is expected to be recovered by the SpiceAuction::recoverToken
function for the last but not started auction. For the case when the startAuction
is called for an auction and it is currently in cooldown, the function reverts with a message to call RemoveAuctionConfig
function.
But removeAuctionConfig
just removes the config of the auction and doesn't perform any recovery of the token, as a result of which calling removeAuctionConfig
will remove config and tokens that were expected to be recovered will be stuck in the contract and as _totalAuctionTokenAllocation
has the value of the token that was expected to be recovered, and the contract evaluate tokens in there as tokens that are allocated to the auction and now there is no possible way to perform recovery after calling removeAuctionConfig
, thus resulting in stuck funds.
The vulnerability is present in the recoverToken
function of the SpiceAuction
contract, where it reverts with a message to call the removeAuctionConfig
for the case when an auction is in cooldown and yet to be started.
It was expected for the tokens allocated for an auction currently in cooldown to be recovered via recoverToken
, but due to incorrect implementation there is no way to perform recover tokens operation due to above discussed issue, as remove auction config just removes the config and does nothing else.
As removeAuctionConfig
performs a reset operation on the epochs and auctionConfigs mapping but as startAuction
function was already called so the funds were already allocated in _totalAuctionTokenAllocation mapping as a result of which there is no way for those tokens to be recovered and removeAuctionConfig
doesn't perform any updations related to _totalAuctionTokenAllocation
.
Tokens cannot be recovered for the case when the auction is in cooldown and is not started yet.
Add the below coded PoC in the SpiceAuctionTest
contract in the file: test/forge/templegold/SpiceAuction.t.sol
Run the test:
Manual Review, Unit Test in Foundry
Updation 1
Update the recoverToken
function to perform the recovery of the tokens for the auction that is in cooldown and yet to be started. Instead of performing a revert for this case recover the tokens to the recipient.
Perform the following recover operation in the recoverToken
function for the case when auction is in cooldown:
Updation 2
In removeAuctionConfig
update the _totalAuctionTokenAllocation
mapping to remove the tokens allocated for the auction that is being removed.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.