Submitted by nnez, also found by Ch_301
This vulnerability allows malicious actors to steal tokens on sell with auto-approve enabled without payment to sellers.
The bug arises from an oversight in the token approval management within the bidding and cancellation process. When a seller sets auto_approve to true for their token, a bidder is granted approval upon calling the setbidtobuy function. This approval is intended to allow the buyer to call the transfer_nft function themselves to complete the trade.
The transfer_nft function performs the following actions:
However, a flaw exists in the bid cancellation process. When a buyer cancels their bid by calling setbidtobuy again, the function removes their bid and returns the deposited funds, but it fails to revoke the previously granted approval.
This oversight allows a malicious buyer to exploit the system through the following steps:
This bug effectively allows the attacker to steal the token from the seller without providing any payment to seller.
The severity is set as high because the token (property) listing for sell must have an intrinsic monetary value or else it would not make sense to list it for sale. For example, it could be a property that already has a long-term renter and is receiving a stable income from said renter.
The following test demonstrates the described scenario:
Boilerplate for PoC here.
Revoke approval of bidder when they cancel the bid.
Context
blockchainstar12 (Coded Estate) disputed
Note: For full discussion, see here.
