The Wildcat Protocol - erictee's results

Banking, but worse - a protocol for fixed-rate, undercollateralised credit facilities.

General Information

Platform: Code4rena

Start Date: 16/10/2023

Pot Size: $60,500 USDC

Total HM: 16

Participants: 131

Period: 10 days

Judge: 0xTheC0der

Total Solo HM: 3

Id: 296

League: ETH

Wildcat Protocol

Findings Distribution

Researcher Performance

Rank: 121/131

Findings: 1

Award: $0.06

🌟 Selected for report: 0

🚀 Solo Findings: 0

Lines of code

https://github.com/code-423n4/2023-10-wildcat/blob/main/src/market/WildcatMarket.sol#L142

Vulnerability details

Impact

The function closeMarket() in WildcatMarket.sol:

function closeMarket() external onlyController nonReentrant {
    MarketState memory state = _getUpdatedState();
    state.annualInterestBips = 0;
    state.isClosed = true;
    state.reserveRatioBips = 0;
    if (_withdrawalData.unpaidBatches.length() > 0) {
      revert CloseMarketWithUnpaidWithdrawals();
    }
    uint256 currentlyHeld = totalAssets();
    uint256 totalDebts = state.totalDebts();
    if (currentlyHeld < totalDebts) {
      // Transfer remaining debts from borrower 
      asset.safeTransferFrom(borrower, address(this), totalDebts - currentlyHeld);//@audit no approve before?? will this function revert?
    } else if (currentlyHeld > totalDebts) {
      // Transfer excess assets to borrower
      asset.safeTransfer(borrower, currentlyHeld - totalDebts); //@audit need to double check the calculation here, might have critical finding here.
    }
    _writeState(state);
    emit MarketClosed(block.timestamp);
  }
}

Notice that there is onlyController modifier which indicates this function can only be called from WildcatMarketController.sol contract.

However, this function is not implemented anywhere in WildcatMarketController.sol, making this function completely unusable. Borrowers who try to call this function directly from WildcatMarket.sol will get reverted with NotController() error message.

As a result, funds will be lost as both protocol cannot claim remaining debts from borrower if market is not fully collateralized and borrowers cannot reclaim any assets in excess of debts.

Proof of Concept

https://github.com/code-423n4/2023-10-wildcat/blob/main/src/market/WildcatMarket.sol#L142

Tools Used

Manual analysis

Implement closemarket() function in WildcatMarketController.sol and make sure access control is set appropriately.

Assessed type

Other

#0 - c4-pre-sort

2023-10-27T07:31:17Z

minhquanym marked the issue as duplicate of #147

#1 - c4-judge

2023-11-07T13:53:20Z

MarioPoneder changed the severity to 2 (Med Risk)

#2 - c4-judge

2023-11-07T14:08:23Z

MarioPoneder marked the issue as partial-50

AuditHub

A portfolio for auditors, a security profile for protocols, a hub for web3 security.

Built bymalatrax © 2024

Auditors

Browse

Contests

Browse

Get in touch

ContactTwitter