Skip to content
Business logic Audit finding Intermediate

processAuction() in VaultAdmin.sol can be called multiple times by keeper if the auction is canceled

ctf_sec Follow

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2022-09-knox-judging/issues/26

Found by

ctf_sec

Summary

processAuction() in VaultAdmin.sol can be called multiple times by keeper if the auction is canceled.

Vulnerability Detail

processAuction() in VaultAdmin.sol can be called multiple times by keeper, the code below would execute more than one times if the auction is canceled.

https://github.com/sherlock-audit/2022-09-knox/blob/main/knox-contracts/contracts/vault/VaultAdmin.sol#L259-L280

because it is the line of code inside the function processAuction in VaultAdmin.sol below that can change the auction status to PROCESSED.

https://github.com/sherlock-audit/2022-09-knox/blob/main/knox-contracts/contracts/vault/VaultAdmin.sol#L326

this code only runs when the auction is finalized, it not finalized, the auction is in Canceled State and

Solidity
   bool cancelled = l.Auction.isCancelled(lastEpoch);
        bool finalized = l.Auction.isFinalized(lastEpoch);

        require(
            (!finalized && cancelled) || (finalized && !cancelled),
            "auction is not finalized nor cancelled"
        );

would always pass because the auction is in cancel state.

Impact

Why the processAuction should not be called multiple times?

In the first time it is called, the withdrawal lock is released so user can withdraw fund,

Solidity
 // deactivates withdrawal lock
  l.auctionProcessed = true;

then if we called again, the lastTotalAssets can be updated multiple times.

Solidity
        // stores the last total asset amount, this is effectively the amount of assets held
        // in the vault at the start of the auction
        l.lastTotalAssets = _totalAssets();

the total asset can be lower and lower because people are withdrawing their fund.

then when _collectPerformanceFee is called, the performance may still be collected

https://github.com/sherlock-audit/2022-09-knox/blob/main/knox-contracts/contracts/vault/VaultInternal.sol#L513-L530

Code Snippet

Tool used

Manual Review

Recommendation

We recommend the project lock the epoch and make it impossible for keeper to call the processAuction again.

Discussion

0xCourtney

The Keeper is an EOA owned/controlled by the protocol team and therefore considered trusted.

Evert0x

@0xCourtney as there are require statements based on the auction state, is it a valid use case that processAuction() get's called multiple times (by the keeper)? If not I can see the argument for the missing check.

0xCourtney

No, this function should only be called once. We'll add a guard to prevent multiple calls.

0xCourtney

https://github.com/KnoxFinance/knox-contracts/pull/89

rcstanciu

Reply from @arbitrary-CodeBeholder


looks good

The original report as published on Sherlock, by ctf_sec. Images and videos are our own copies; raw HTML is shown as text. View it on Sherlock.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

What is known

A medium-severity business logic bug in Knox Finance. Sherlock made it public on 13 October 2022. Found in the 4 audit contest (finding M-7).

About Business logic

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More by ctf_sec

View all

25 more disclosed reports, best first.

More from Knox Finance

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.