The producer can list their Martenitsa token for sale through MartenitsaMarketplace::listMartenitsaForSale
, but they do not approve their token to the MartenitsaMarketplace
contract atomically in the function. When a buyer wants to buy the token through MartenitsaMarketplace::listMartenitsaForSale
, the transaction will fail due to insufficient token approval, leading to denial of service issue.
Consider the following process of listing and buying Martenitsa token.
Chasy is one of the producer and create a Martenitsa token through martenitsaToken::createMartenitsa
.
Chasy then list the token for sale through MartenitsaMarketplace::listMartenitsaForSale
, but does not approve the token to the MartenitsaMarketplace
contract.
Another user, Bob, notices the listing token and buys the token through MartenitsaMarketplace::buyMartenitsa
The transaction will revert since the MartenitsaMarketplace
does not have the token approval and thus not able to execute safeTransferFrom, from Chasy to Bob.
Add the following proof-of-concept in MartenitsaMarketplace.t.sol
, and execute the command forge test --mt testDenialOfServiceWhenTokenNotApproveInListing
. It will succeed, indicating no user is able to buy the token although it is currently for sale due to insufficient approval.
The proof-of-concept:
Reverts in the safeTransferFrom function due to insufficient approval:
The buyers are unable to buy martenitsaToken although the token is for sale, and the operation will waste their gas.
Manual Review, Foundry testing
When seller wants to list their token for sale, they should also approve their token. This feature can be updated in the MartenitsaMarketplace::listMartenitsaForSale
function.
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.