The purchase function in BuyerAgent is responsible for purchasing all assets for a buyer. It does so by looping through all the assets in the best response by the oracale. However, the function will fail if a malicious seller revokes approval to Swan for the assets before purchase is called, since the SwanAsset does not override ERC721 functions.
Add this to the Swan.test.ts file:
The buyer will not be able to purchase any asset.
Manual Review
There can be a few possible ways to mitigate this issue:
Transfer the asset to Swan when the item is listed. Although this will require a change in the current architecture.
Instead of purchasing all assets at once, purchase them one by one. This way, if a malicious seller revokes approval for an asset, the purchase of that asset will fail, but the purchase of other assets will succeed.
Override the ERC721 functions in SwanAsset to prevent the malicious seller from revoking approval or transferring to any other address than Swan.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.