Description
-
Auction mechanisms should be resistant to MEV (Maximal Extractable Value) exploitation where sophisticated actors can extract value through transaction timing.
-
The predictable auction extension timing allows MEV bots to exploit the system by placing bids at precisely calculated moments to maximize their chances of winning.
uint256 timeLeft = 0;
if (listing.auctionEnd > block.timestamp) {
timeLeft = listing.auctionEnd - block.timestamp;
}
@> if (timeLeft < S_AUCTION_EXTENSION_DURATION) {
listing.auctionEnd = listing.auctionEnd + S_AUCTION_EXTENSION_DURATION;
emit AuctionExtended(tokenId, listing.auctionEnd);
}
Risk
Likelihood:
Impact:
Proof of Concept
function test_LOW_MEVBidTiming() public {
uint256 tokenId = _mintAndListNFT(ALICE, MIN_PRICE, 0);
vm.prank(BOB);
market.placeBid{value: MIN_PRICE + 0.1 ether}(tokenId);
uint256 auctionEnd = market.getListing(tokenId).auctionEnd;
vm.warp(auctionEnd - 1);
vm.prank(ATTACKER);
market.placeBid{value: MIN_PRICE + 0.2 ether}(tokenId);
assertTrue(
block.timestamp < market.getListing(tokenId).auctionEnd,
"Auction should be extended"
);
}
Recommended Mitigation
+ // Add randomness to extension timing
+ uint256 randomExtension = S_AUCTION_EXTENSION_DURATION +
+ (uint256(keccak256(abi.encodePacked(block.timestamp, tokenId))) % (5 minutes));
if (timeLeft < S_AUCTION_EXTENSION_DURATION) {
- listing.auctionEnd = listing.auctionEnd + S_AUCTION_EXTENSION_DURATION;
+ listing.auctionEnd = listing.auctionEnd + randomExtension;
emit AuctionExtended(tokenId, listing.auctionEnd);
}