MartenitsaMarketplace::buyMartenitsa
lets users to send more ETH
to the contract than the price of the Martenitsa they intend to buy. These extra funds are not returned to the buyer but are kept in the contract which has no method for withdrawing ETH
.
MartenitsaMarketplace::buyMartenitsa
is designed to enable users to buy listed Martenitsa NFTs. When calling the function, users are supposed to send an ETH
amount with the transaction to cover the price of the selected NFT.
MartenitsaMarketplace::buyMartenitsa
accepts amounts higher than the NFT price, but is not prepared to handle the extra funds: nor does it refund the buyer, neither does it have a mechanism for withdrawing such funds.
The code below demonstrates that the contract accepts amounts higher than the NFT price.
Financial loss: Users who overpay for an NFT will lose the excess Ether they sent, as there is no mechanism to refund it. Note that sending more Ether than the price of the NFT is not necessarily a sign of the buyer's mistake or unawareness than can be easily avoided. Consider the following scenario
-- buyer submits the transaction to buy an NFT. At this point, the transaction value matches the NFT price.
-- seller submits a transaction to lower the price of the NFT. This happens about the same time when the buyer submits its transaction.
-- if the seller's transaction is added the blockchain earlier than the buyer's, the buyer will unavoidably overpay compared to the reduced price.
Unrecoverable Ether: extra funds send to the contract are stuck in the contract forever.
Manual review, Foundry.
There are a few possible solutions, including:
modify MartenitsaMarketplace::buyMartenitsa
to reject payments that exceed the NFT price, or
send back the extra funds to the buyer, or
implement a withdraw function that enables the contract owner or any other predefined, trusted address to withdraw Ether from the contract.
For simplicity and fairness, consider implementing the first option by introducing the following modification:
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.