Creditor can maliciously burn UniV3 position to permanently lock funds
A malicious lender can burn their LP NFT, causing ownerOf to revert for that token ID. Since all repayment and emergency withdrawal methods query ownerOf for every loan, the entire position becomes permanently locked.
0x52 Follow with 0xJuda, ArmedGoose and 5 others
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2023-10-real-wagmi-judging/issues/78
Found by
0x52, 0xJuda, ArmedGoose, Bauer, HHK, handsomegiraffe, mstpr-brainbot, talfao
LP NFT's are always controlled by the lender. Since they maintain control, malicious lenders have the ability to burn their NFT. Once a specific tokenID is burned the ownerOf(tokenID) call will always revert. This is problematic as all methodologies to repay (even emergency) require querying the ownerOf() every single token. Since this call would revert for the burned token, the position would be permanently locked.
Vulnerability Detail
function ownerOf(uint256 tokenId) public view virtual override returns (address) {
return _tokenOwners.get(tokenId, "ERC721: owner query for nonexistent token");
}
When querying a nonexistent token, ownerOf will revert. Now assuming the NFT is burnt we can see how every method for repayment is now lost.
LiquidityManager.sol#L306-L308
address creditor = underlyingPositionManager.ownerOf(loan.tokenId);
// Increase liquidity and transfer liquidity owner reward
_increaseLiquidity(cache.saleToken, cache.holdToken, loan, amount0, amount1);
If the user is being liquidated or repaying themselves the above lines are called for each loan. This causes all calls of this nature to revert.
LiquidityBorrowingManager.sol#L727-L732
for (uint256 i; i < loans.length; ) {
LoanInfo memory loan = loans[i];
// Get the owner address of the loan's token ID using the underlyingPositionManager contract.
address creditor = underlyingPositionManager.ownerOf(loan.tokenId);
// Check if the owner of the loan's token ID is equal to the `msg.sender`.
if (creditor == msg.sender) {
The only other option to recover funds would be for each of the other lenders to call for an emergency withdrawal. The problem is that this pathway will also always revert. It cycles through each loan causing it to query ownerOf() for each token. As we know this reverts. The final result is that once this happens, there is no way possible to close the position.
Impact
Creditor can maliciously lock all funds
Code Snippet
LiquidityBorrowingManager.sol#L532-L674
Tool used
Manual Review
Recommendation
I would recommend storing each initial creditor when a loan is opened. Add try-catch blocks to each ownerOf() call. If the call reverts then use the initial creditor, otherwise use the current owner.
Discussion
fann95
Fixed: https://github.com/RealWagmi/wagmi-leverage/commit/788c72b8242cc704e5db58cfdbfcdf8d4559d4b5
IAm0x52
Fix looks good. Burned tokens no longer cause a revert and tokens are sent to borrower as profit
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The contract relies on ownerOf for each loan without handling the case where the NFT has been burned, so a single burned token causes all repayment paths to revert.
Impact
A creditor can maliciously lock all funds in the position, preventing any repayment or emergency withdrawal.
What the attacker needed
Attacker is a lender with an LP NFT; attacker burns the NFT
The fix
The fix stores the initial creditor and uses try-catch around ownerOf calls, falling back to the stored creditor if the call reverts.
How it was found
- A lender opens a loan, retaining control of the LP NFT.
- The lender burns the LP NFT.
- Any attempt to repay or liquidate calls ownerOf on the burned token ID, which reverts.
- Emergency withdrawal also iterates over all loans and calls ownerOf, so it reverts too.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
In this lending system, the lender holds an NFT representing their liquidity position. If the lender destroys (burns) that NFT, the function that looks up the NFT's owner will fail. Because the contract checks every loan's owner during repayment, one burned NFT makes it impossible to repay or withdraw any funds.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.