While calling createEscrow in WildcatMarketBase and WildcatMarketWithdrawl wrong order of inputs is passed instead of the correct signature of the createEscrowFunction which leads to setting the escrow address against the lender in sanctionOverrides instead of the borrower and also the deployed address is different from what it should have been due to wrong salt.
Proof of Concept
Lets look at the function signature of the the createEscrow
We can see the first argument is borrower, second is lender and third one and last is the asset being lent.
But the problem is this function is called at two places and in both places first two arguments are switched and in one case third argument is passed as the calling contract instead of the asset in scope.
So passing the arguments in wrong order, firstly deploys at the wrong address which is not desired by the protocol, and secondly to prevent the escrow contract we are using the sanctionOverride mapping which set the escrow contract for the borrower to true to prevent permanent locking of funds in case the oracle gets manipulated or shuts down.
But in this case instead of setting the escrow address for the borrower it is set for the lender(account) which is not intended behaviour.
Lines of code
https://github.com/code-423n4/2023-10-wildcat/blob/c5df665f0bc2ca5df6f06938d66494b11e7bdada/src/market/WildcatMarketBase.sol#L163-L187 https://github.com/code-423n4/2023-10-wildcat/blob/c5df665f0bc2ca5df6f06938d66494b11e7bdada/src/market/WildcatMarketWithdrawals.sol#L137-L188 https://github.com/code-423n4/2023-10-wildcat/blob/c5df665f0bc2ca5df6f06938d66494b11e7bdada/src/WildcatSanctionsSentinel.sol#L95-L120
Vulnerability details
Impact
While calling
createEscrow
inWildcatMarketBase
andWildcatMarketWithdrawl
wrong order of inputs is passed instead of the correct signature of thecreateEscrowFunction
which leads to setting the escrow address against the lender insanctionOverrides
instead of the borrower and also the deployed address is different from what it should have been due to wrong salt.Proof of Concept
Lets look at the function signature of the the
createEscrow
We can see the first argument is borrower, second is lender and third one and last is the asset being lent.
But the problem is this function is called at two places and in both places first two arguments are switched and in one case third argument is passed as the calling contract instead of the asset in scope.
First in the
WildcatMarketBase.sol
Here we can clearly see the arguments are messed up
Second in the
WildcatMarketWithdrawl.sol
So passing the arguments in wrong order, firstly deploys at the wrong address which is not desired by the protocol, and secondly to prevent the escrow contract we are using the
sanctionOverride
mapping which set the escrow contract for the borrower to true to prevent permanent locking of funds in case the oracle gets manipulated or shuts down.But in this case instead of setting the escrow address for the borrower it is set for the lender(account) which is not intended behaviour.
Tools Used
Manual review
Recommended Mitigation Steps
Simply pass the arguments in right order.
Assessed type
Other