Submitted by 0xjuan, also found by CaeraDenoir, kinda_very_good, falconhoof, 0x175, Arz, JohnSmith, alix40, stackachu, givn, wangxx2026, Ocean_Sky, 0xloscar01, SpicyMeatball, 0xAlix2, Ali-_-Y, 0rpse, iamandreiski, 0xBugSlayer, nmirchev8, nnez, ayden, and novamanbg
When liquidating a position, _cleanUpLoan() is called on the loan. This attempts to send the uniswap LP position back to the user via the following line:
This safeTransferFrom function call invokes the onERC721Received function on the owners contract. The transaction will only succeed if the owners contract returns the function selector of the standard onERC721Received function. However, the owner can design the function to return an invalid value, and this would lead to the safeTransferFrom reverting, thus being unable to liquidate the user.
This leads to bad debt accrual in the protocol which cannot be prevented, and eventually insolvency.
Below is a foundry test that proves this vulnerability. To run the PoC:
Attacker Contract:
Foundry test:
Terminal output:
One solution would be to approve the NFT to the owner and provide a way (via the front-end or another contract) for them to redeem the NFT back later on. This is a pull over push approach and ensures that the liquidation will occur.
Example:
DoS
kalinbas (Revert) confirmed
Revert mitigated:
Status: Mitigation confirmed. Full details in reports from thank_you, ktg and b0g0.
