You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 28, 2024. It is now read-only.
sherlock-admin opened this issue
Oct 23, 2023
· 0 comments
Labels
DuplicateA valid issue that is a duplicate of an issue with `Has Duplicates` labelHighA valid High severity issueRewardA payout will be made for this issue
Malicious liquidity provider can prevent liquidation of loan and loss of funds to other liquidity providers
Summary
By supplying a loan and burning the Univswap V3 position after, a malicious liquidity provider can cause DOS to real wagmi and prevent liquidation of loan(s) and loss of funds to other liquidity providers.
Vulnerability Detail
A malicious liquidity provider could approve real wagmi to use his position for loans. After supplying the loan, the malicious actor could then burn their Uniswap V3 position NFT. This prevents repayment or liquidation of a loan, even through the emergency mode.
In the regular repayment/liquidation process, when _upRestoreLiquidityCache() is called, this external call : underlyingPositionManager.positions(loan.tokenId); reverts with 'Invalid Token Id".
In the emergency process, when _calculateEmergencyLoanClosure() is called, this external call : address creditor = underlyingPositionManager.ownerOf(loan.tokenId);reverts with 'ERC721: owner query for nonexistent token'.
Proof of Concept
In WagmiLeverageTests.ts, bob provides a WETH_USDT loan with tokenId 512099. As all liquidity is used for loans, by inserting await nonfungiblePositionManager.connect(bob).burn(nftpos[1].tokenId); before repay is called, these tests will fail :
it("emergency repay will be successful for PosManNFT owner if the collateral is depleted") (L990)
it("Loan liquidation will be successful for anyone if the collateral is depleted") (L1071)
Impact
As a result of the DOS,
Liquidation of the loan not possible, significant funds loss/stuck
Honest liquidity providers are unable to recover funds supplied to the loan (up to 7 per position)
An honest borrower is unable to repay, close the loan and recover collateral
Suggest to wrap external calls to underlyingPositionManager in try/catch and handle reverts by writing off loan from that specific liquidity position which has been burned.
sherlock-admin
changed the title
Orbiting Tweed Caterpillar - Malicious liquidity provider can prevent liquidation of loan and loss of funds to other liquidity providers
handsomegiraffe - Malicious liquidity provider can prevent liquidation of loan and loss of funds to other liquidity providers
Oct 30, 2023
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
DuplicateA valid issue that is a duplicate of an issue with `Has Duplicates` labelHighA valid High severity issueRewardA payout will be made for this issue
handsomegiraffe
high
Malicious liquidity provider can prevent liquidation of loan and loss of funds to other liquidity providers
Summary
By supplying a loan and burning the Univswap V3 position after, a malicious liquidity provider can cause DOS to real wagmi and prevent liquidation of loan(s) and loss of funds to other liquidity providers.
Vulnerability Detail
A malicious liquidity provider could approve real wagmi to use his position for loans. After supplying the loan, the malicious actor could then burn their Uniswap V3 position NFT. This prevents repayment or liquidation of a loan, even through the emergency mode.
In the regular repayment/liquidation process, when
_upRestoreLiquidityCache()
is called, this external call :underlyingPositionManager.positions(loan.tokenId);
reverts with 'Invalid Token Id".In the emergency process, when
_calculateEmergencyLoanClosure()
is called, this external call :address creditor = underlyingPositionManager.ownerOf(loan.tokenId);
reverts with 'ERC721: owner query for nonexistent token'.Proof of Concept
In
WagmiLeverageTests.ts
, bob provides a WETH_USDT loan with tokenId 512099. As all liquidity is used for loans, by insertingawait nonfungiblePositionManager.connect(bob).burn(nftpos[1].tokenId);
beforerepay
is called, these tests will fail :Impact
As a result of the DOS,
Code Snippet
https://github.com/sherlock-audit/2023-10-real-wagmi/blob/main/wagmi-leverage/contracts/abstract/LiquidityManager.sol#L494
https://github.com/sherlock-audit/2023-10-real-wagmi/blob/main/wagmi-leverage/contracts/abstract/LiquidityManager.sol#L494
Tool used
Manual Review
Recommendation
Suggest to wrap external calls to underlyingPositionManager in try/catch and handle reverts by writing off loan from that specific liquidity position which has been burned.
Duplicate of #78
The text was updated successfully, but these errors were encountered: