Skip to content
Business logic Audit finding Beginner

NFTs mintable after Auction deadline expires

The buy function in the LPDA contract did not check whether the auction's end time had passed, so a purchase could still be made after the deadline. An attacker could mint NFTs at the final price after the auction was supposed to be over.

ForkEth Follow with Ch_301, Chom and 5 others

Originally disclosed on Code4rena

Submitted by ForkEth, also found by Ch_301, Chom, minhquanym, adriro, csanuragjain, CRYP70, and Lambda

The buy function on the LPDA.sol contract is not validating if the auction is still running, allowing a purchase to be made after the stipulated time. The endtime variable used to store the end date of the auction is not used at any point to validate whether the purchase is being made within the deadline.

Proof of Concept

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.17;

import "forge-std/Test.sol";
import {EscherTest} from "./utils/EscherTest.sol";
import {LPDAFactory, LPDA} from "src/minters/LPDAFactory.sol";

contract LPDABase is EscherTest {
	LPDAFactory public lpdaSales;
	LPDA.Sale public lpdaSale;

	function setUp() public virtual override {
		super.setUp();
		lpdaSales = new LPDAFactory();
		// set up a LPDA Sale
		lpdaSale = LPDA.Sale({
			currentId: uint48(0),
			finalId: uint48(10),
			edition: address(edition),
			startPrice: uint80(uint256(1 ether)),
			finalPrice: uint80(uint256(0.1 ether)),
			dropPerSecond: uint80(uint256(0.1 ether) / 1 days),
			startTime: uint96(block.timestamp),
			saleReceiver: payable(address(69)),
			endTime: uint96(block.timestamp + 1 days)
		 });
	}
}

contract LPDATest is LPDABase {
	LPDA public sale;

	event End(LPDA.Sale _saleInfo);
	function test_Buy() public {
		sale = LPDA(lpdaSales.createLPDASale(lpdaSale));
		// authorize the lpda sale to mint tokens
		edition.grantRole(edition.MINTER_ROLE(), address(sale));
		vm.warp(block.timestamp + 3 days);
		sale.buy{value: 1 ether}(1);
		assertEq(address(sale).balance, 1 ether);
	}
}

The code above shows that even after two days after the endTime it was still possible to make the purchase.

Recommended Mitigation Steps

Our recommendation would be to introduce a require to validate if the purchase is being made within the endTime.

require(block.timestamp > sale.endTime, "TOO LATE");

The above must be placed at the beginning of the buy function.

mehtaculous (Escher) confirmed and commented:

Agree that this is Medium priority. We want to check that we are not past the endTime on the buy() function.


The original report as published on Code4rena, by ForkEth. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

The buy function did not compare the current block timestamp against the sale's endTime, so the deadline was never enforced.

Impact

A buyer could mint NFTs after the auction deadline, likely at the final low price, undermining the intended sale schedule.

What the attacker needed

An active LPDA sale; the sale contract has minting permission; the auction end time has passed

The fix

The buy function should be fixed by adding a check that the current time is not past the sale's end time before allowing a purchase.

How it was found

  1. Deploy an LPDA sale with a start time and an end time one day later.
  2. Grant the sale contract permission to mint tokens.
  3. Advance the blockchain time by three days, past the end time.
  4. Call the buy function with the required payment.
  5. Observe that the purchase succeeds and the contract balance increases.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

An auction contract is supposed to stop selling items after a set end time. Here, the code never checked that end time when someone tried to buy, so a buyer could still get the item long after the auction closed. This breaks the rules of the sale and could let someone pay the lowest price after everyone else has stopped bidding.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More from Escher contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.