No lender is able to exit even after the market is closed #52
Labels
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
bug
Something isn't working
M-06
primary issue
Highest quality submission among a set of duplicates
🤖_12_group
AI based duplicate group recommendation
satisfactory
satisfies C4 submission criteria; eligible for awards
selected for report
This submission will be included/highlighted in the audit report
sponsor confirmed
Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
sufficient quality report
This report is of sufficient quality
Lines of code
https://github.com/code-423n4/2024-08-wildcat/blob/main/src/access/FixedTermLoanHooks.sol#L848-L868
https://github.com/code-423n4/2024-08-wildcat/blob/main/src/access/FixedTermLoanHooks.sol#L943-L946
Vulnerability details
Impact
Lenders might not be able to exit even after the market is closed
Proof of Concept
When a borrower creates a market hooked by a fixed-term hook, all lenders are prohibited from withdrawing their assets from the market before the fixed-term time has elapsed.
The borrower can close the market at any time. However,
fixedTermEndTime
of the market is not updated, preventing lenders from withdrawing their assets iffixedTermEndTime
has not yet elapsed.Copy below codes to WildcatMarket.t.sol and run forge test --match-test test_closeMarket_BeforeFixedTermExpired:
Tools Used
Manual review
Recommended Mitigation Steps
When a market hooked by a fixed-term hook is closed,
fixedTermEndTime
should be set toblock.timestamp
if it has not yet elapsed:constructor(address _deployer, bytes memory /* args */) IHooks() { borrower = _deployer; // Allow deployer to grant roles with no expiry _roleProviders[_deployer] = encodeRoleProvider( type(uint32).max, _deployer, NotPullProviderIndex ); HooksConfig optionalFlags = encodeHooksConfig({ hooksAddress: address(0), useOnDeposit: true, useOnQueueWithdrawal: false, useOnExecuteWithdrawal: false, useOnTransfer: true, useOnBorrow: false, useOnRepay: false, useOnCloseMarket: false, useOnNukeFromOrbit: false, useOnSetMaxTotalSupply: false, useOnSetAnnualInterestAndReserveRatioBips: false, useOnSetProtocolFeeBips: false }); HooksConfig requiredFlags = EmptyHooksConfig .setFlag(Bit_Enabled_SetAnnualInterestAndReserveRatioBips) + .setFlag(Bit_Enabled_CloseMarket); .setFlag(Bit_Enabled_QueueWithdrawal); config = encodeHooksDeploymentConfig(optionalFlags, requiredFlags); }
Assessed type
Timing
The text was updated successfully, but these errors were encountered: