MartenitsaMarketplace::buyMartenitsa
function sends the funds to the seller through an external call to seller i.e seller.call{value: salePrice}("")
if the seller is a contract with an unbounded loop in seller::fallback
function the transaction reverts it costs the user a lot of gas
User can potentially lose a lot of funds in terms of gas fee is he tries to buy a token from a malicious seller
Add the given state variables in BaseTest.t.sol
Add the given piece of code in BaseTest.t.sol
's BaseTest::setUp
function below the martenitsaEvent
variable initialisation
Add the given contract code in BaseTest.t.sol
after the BaseTest
contract ends
Import {console} in MartenitsaMarketplace.t.sol
import {console} from "forge-std/Test.sol";
Add the PoC below in MartenitsaMarketplace.t.sol
change the value of limit
in GasAttack::fallback
the more the limit
value the more the gas consumed,alternatively changing the while loop condition to while(true)
will show the full scope of the gas attack
For payments pulling is always better than pushing hence instead of user directly sending funds to the seller by making an arbitrary call adding a MartenitsaMarketplacewithdraw
function where a seller can withdraw
his funds and users can send funds to MartenitsaMarketplace
contract itself is a better design choice , also make sure that the new function follows the Checks-Effects-Interactions(CEI) pattern and has necessary guards in place like OpenZeppelinReentrancyGuard
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.