Incorrect ordering for deletion allows to flash steal rented NFT’s
The stopRent function transfers the rented NFT before verifying that the rental order exists. An attacker can call stopRent with a non-existent order, receive the NFT in a callback, use it freely, then create and fill the order so the existence check passes.
hash Follow with piyushshukla
Originally disclosed on Code4rena
Submitted by hash, also found by piyushshukla and ladboy233 (1, 2)
User’s can flash steal NFT’s circumventing any restrictions imposed on the NFT
Proof of Concept
When stopping a rental,the rented asset (ERC721/ERC1155) is transferred before the actual existance of the order is checked.
// @audit rented assets are transferred here
_reclaimRentedItems(order);
ESCRW.settlePayment(order);
// @audit this is where the existance of the order is actually verified
STORE.removeRentals(
_deriveRentalOrderHash(order),
_convertToStatic(rentalAssetUpdates)
);
Since ERC721/ERC1155 transfers invoke the onReceived functions in case of a contract receiver, it allows an attacker to create a rental order after stopping it first. This gives the attacker unrestricted access to the rented NFT.
Example Scenario
- Attacker rents a restricted NFT N.
- Attacker calls stopRent with a non-existing PAY order(pay order’s allow to stop the rent at the same block as creation) keeping the offer item as NFT N and creator as an attacker controlled contract.
- Since order existance check is done only at last, NFT N is transferred to the attacker’s contract.
- Attacker performs anything he wants to do with the NFT bypassing any restrictions imposed.
- Attacker creates the order and fills it in seaport (attacker can obtain the server signature earlier itself or replay the signature of a similar order). This will populate the orderHash in the existing orders mapping.
- The initial execution inside stopRent continues without reverting since the order is now actually a valid one.
POC Code
https://gist.github.com/10xhash/a6eb9552314900483a1cffe91243a169
Recommended Mitigation Steps
Check for the order existance initially itself in the stopRent function
Would be good to get sponsor comment here. For context see previous comment chain here.
Alec1017 (reNFT) confirmed, but disagreed with severity and commented:
Tested out the PoC. I believe it to be a valid PoC that correctly demonstrates the concept.
However, the asset cannot be “stolen” since it must be given back to the rental safe by the time the “flash steal” ends.
So, I wouldnt say it results in direct loss of funds, or even temporary freezing of funds.
I will say that this does allow the attacker to interact with the asset in any way they see fit, which directly bypasses restrictions that the lender enables via hook contracts. I could see an example where a flash stolen NFT is used with a function selector on a contract to interact with some on-chain game, which the lender may have explicitly wanted to forbid.
But I’ll leave the final decision on the severity to the judges on this.
0xean (Judge) decreased severity to Medium
The PR here - Checks if a rental order exists right away when stopping a rental. Prevents stopping of an order that doesn’t exist, only to create it during a callback in the
stopRent()execution flow.
Status: Mitigation confirmed. Full details in reports from juancito, EV_om and sin1st3r__.
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 stopRent function performs the NFT transfer before checking that the rental order exists, allowing a callback to create the order mid-execution.
Impact
The attacker can temporarily use the rented NFT in any way, bypassing lender restrictions, but must return it by the end of the transaction, so there is no direct loss of funds.
What the attacker needed
Attacker rents a restricted NFT; Attacker controls a contract to receive the NFT; Attacker can obtain or replay a valid order signature
The fix
The stopRent function should check for the order's existence at the beginning.
How it was found
- Attacker rents a restricted NFT N.
- Attacker calls stopRent with a non-existing PAY order, keeping the offer item as NFT N and creator as an attacker-controlled contract.
- The NFT N is transferred to the attacker's contract because the existence check happens last.
- Attacker performs any actions with the NFT, bypassing restrictions.
- Attacker creates and fills the order in seaport, populating the orderHash.
- The initial stopRent execution continues without reverting because the order is now valid.
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.
When you stop renting an NFT, the contract first sends the NFT back to you, and only later checks that the rental order was real. An attacker can abuse this by asking to stop a fake order, getting the NFT temporarily, doing whatever they want with it, and then quickly creating the real order before the check happens.
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.