The Wildcat Protocol - Jiamin'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: 53/131

Findings: 2

Award: $91.30

🌟 Selected for report: 0

🚀 Solo Findings: 0

Lines of code

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

Vulnerability details

Impact

closeMarket() in WildcatMarket contract can not be from called from WildcatMarketController, and market can not be closed.

Proof of Concept

closeMarket() in WildcatMarket is defined to be called to close market:

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); } else if (currentlyHeld > totalDebts) { // Transfer excess assets to borrower asset.safeTransfer(borrower, currentlyHeld - totalDebts); } _writeState(state); emit MarketClosed(block.timestamp); }

and this function is expected to be called from WildcatMarketController, however, there is no such function in WildcatMarketController that calls closeMarket(), so user cannot close a market.

Tools Used

Manual Review

Please consider to add function in WildcatMarketController to call closeMarket() function so that market can be closed.

Assessed type

Access Control

#0 - c4-pre-sort

2023-10-27T07:13:01Z

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:02:17Z

MarioPoneder marked the issue as partial-50

#3 - c4-judge

2023-11-07T14:16:53Z

MarioPoneder changed the severity to 3 (High Risk)

Findings Information

🌟 Selected for report: osmanozdemir1

Also found by: 0xCiphky, 0xStalin, HChang26, Infect3d, Jiamin, Juntao, QiuhaoLi, circlelooper, crunch, rvierdiiev

Labels

bug
2 (Med Risk)
downgraded by judge
satisfactory
edited-by-warden
duplicate-550

Awards

91.2409 USDC - $91.24

External Links

Lines of code

https://github.com/code-423n4/2023-10-wildcat/blob/c5df665f0bc2ca5df6f06938d66494b11e7bdada/src/market/WildcatMarketBase.sol#L170-L186

Vulnerability details

Impact

A blocked lender's supply is not deducted from market's total supply and will continue to accrue interest.

Proof of Concept

When a lender is blocked, if the lender's scaledBalance is bigger than 0 then it will be set to 0.

if (scaledBalance > 0) { account.scaledBalance = 0; address escrow = IWildcatSanctionsSentinel(sentinel).createEscrow( accountAddress, borrower, address(this) ); emit Transfer(accountAddress, escrow, state.normalizeAmount(scaledBalance)); _accounts[escrow].scaledBalance += scaledBalance; emit SanctionedAccountAssetsSentToEscrow( accountAddress, escrow, state.normalizeAmount(scaledBalance) ); } _accounts[accountAddress] = account; }

However, the scaledBalance is not deducted from market's scaledTotalSupply, so this amount of asset is still accruing interests and borrower will have to pay more interest than expected.

Tools Used

Manual Review

Please consider to deduct a blocked lender's scaledBalance from market.

Assessed type

Math

#0 - c4-pre-sort

2023-10-28T11:39:16Z

minhquanym marked the issue as duplicate of #123

#1 - c4-judge

2023-11-07T18:14:26Z

MarioPoneder changed the severity to 2 (Med Risk)

#2 - c4-judge

2023-11-07T18:17:50Z

MarioPoneder marked the issue as satisfactory

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