After the buyOrder is completed, the order creator does not receive the NFT
When a seller completes a buy order by selling an NFT, the NFT is transferred to the buy order contract instead of the order creator. The order creator loses the NFT, while the seller receives the buy token.
0x37 Follow with 0xPhantom2, 4lifemen and 28 others
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2024-10-debita-judging/issues/890
Found by
0x37, 0xPhantom2, 4lifemen, Audinarey, BengalCatBalu, CL001, Cybrid, DenTonylifer, Greed, Greese, IzuMan, KiroBrejka, KungFuPanda, Pro_King, Valy001, alexbabits, araj, dhank, dimulski, durov, kazan, lanrebayode77, merlin, newspacexyz, nikhilx0111, pashap9990, shaflow01, t.aksoy, utsav, xiaoming90, ydlee
Summary
After sellNFT is completed, the NFT should be transferred to the order creator, but this is not done.
Root Cause
After the buyOrder is completed, the order creator does not receive the NFT, and the NFT is sent directly to buyOrderContract
The latter only emits an event and deletes the order, but does not transfer the NFT to the order creator
Internal pre-conditions
External pre-conditions
- User A create buyOrder.
- User B sellNFT.
Attack Path
Impact
The buyOrder creator will lose the NFT
PoC
Path: test/fork/BuyOrders/BuyOrder.t.sol
function testpoc() public{
vm.startPrank(seller);
receiptContract.approve(address(buyOrderContract), receiptID);
uint balanceBeforeAero = AEROContract.balanceOf(seller);
address owner = receiptContract.ownerOf(receiptID);
console.log("receipt owner before sell",owner);
buyOrderContract.sellNFT(receiptID);
address owner1 = receiptContract.ownerOf(receiptID);
console.log("receipt owner after sell",owner1);
//owner = buyOrderContract
assertEq(owner1,address(buyOrderContract));
vm.stopPrank();
}
[PASS] testpoc() (gas: 242138) Logs: receipt owner before sell 0x81B2c95353d69580875a7aFF5E8f018F1761b7D1 receipt owner after sell 0xffD4505B3452Dc22f8473616d50503bA9E1710Ac
Mitigation
After the buyOrder is completed,the NFT should be transferred to the order creator
Discussion
sherlock-admin2
The protocol team fixed this issue in the following PRs/commits: https://github.com/DebitaFinance/Debita-V3-Contracts/commit/d6f3b76c256713f0aa132a015ced6eb60ec389cb
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 buy order contract's sellNFT function transfers the NFT to itself but does not forward it to the order creator.
Impact
The buy order creator loses the NFT, which is stuck in the contract.
What the attacker needed
User A creates a buy order; User B sells an NFT into that order
The fix
The buy order contract should transfer the NFT to the order creator after the sale is completed; the text states the protocol team fixed this issue.
How it was found
- User A creates a buy order.
- User B sells an NFT into that buy order.
- User B receives the buy token.
- The NFT remains in the buy order contract, and the order creator does not receive it.
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.
A buy order is like a request to buy an NFT at a set price. When someone sells into that order, the NFT should go to the person who placed the order. Instead, the NFT gets stuck in the buy order contract, so the buyer never gets it.
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.