Skip to content
This repository has been archived by the owner on Jun 2, 2024. It is now read-only.

popeye - Malicious pausing of Auction Contract via Gas Exception on Internal Mint #237

Closed
sherlock-admin2 opened this issue Dec 1, 2023 · 0 comments
Labels
Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label Medium A valid Medium severity issue Reward A payout will be made for this issue

Comments

@sherlock-admin2
Copy link
Contributor

sherlock-admin2 commented Dec 1, 2023

popeye

medium

Malicious pausing of Auction Contract via Gas Exception on Internal Mint

Summary

The settleCurrentAndCreateNewAuction() function can be used by any user to pause the Auction contract. This occurs by causing the internal _createAuction() call to fail via a child call gas limit exception during the token.mint() execution.

Vulnerability Details

The settleCurrentAndCreateNewAuction() function makes an internal call to _createAuction().

    function settleCurrentAndCreateNewAuction() external nonReentrant whenNotPaused {
        _settleAuction();
        _createAuction();
    }

Inside _createAuction(), an NFT minting occurs through token.mint()

       try token.mint() returns (uint256 tokenId) {

According to the EIP-150 call opcode can consume as most 63/64 of parrent calls' gas. That means token.mint() can fail since there will be no gas.

All in all, if token.mint() fail on gas and the rest gas is enough for pausing the contract by calling _pause in catch statement the contract will be paused.

Please note, that a bug can be exploitable if the token.mint() consume more than 1.500.000 of gas, because 1.500.000 / 64 > 20.000 that need to pause the contract. Also, the logic of token.mint() includes traversing the array up to 100 times, that's heavy enough to reach 1.500.000 gas limit.

Impact

Contract can be paused by any user by passing special amount of gas for the call of settleCurrentAndCreateNewAuction (which consists of two internal calls of _settleAuction and _createAuction functions).

Code Snippet

https://github.com/sherlock-audit/2023-09-nounsbuilder/blob/main/nouns-protocol/src/auction/Auction.sol#L238-L241
https://github.com/sherlock-audit/2023-09-nounsbuilder/blob/main/nouns-protocol/src/auction/Auction.sol#L292-L329

Tool used

Manual Review

Recommendation

To address this, the minting logic should be separated into its own private function with a passed-in gas stipend sufficient to prevent exceptions:

// @notice Mints NFT safely with sufficient gas parameters 
// @return tokenId The minted token ID 
// @dev Provides sufficient gas to prevent child call exceptions
function safeMint() private returns (uint256 tokenId){

  uint256 gas = 1500000; // approx observed mint gas cost

  try Token(token).mint(){gas: gas} returns (uint256 tokenId){
      return tokenId;
  }catch{
    revert AuctionCreationFailed(); 
  }
}

function _createAuction(){
  uint256 tokenId = safeMint();
  // additional logic
}

Duplicate of #243

@github-actions github-actions bot closed this as completed Dec 6, 2023
@github-actions github-actions bot added the Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label label Dec 6, 2023
@sherlock-admin sherlock-admin changed the title Lively Carob Monkey - Malicious pausing of Auction Contract via Gas Exception on Internal Mint popeye - Malicious pausing of Auction Contract via Gas Exception on Internal Mint Dec 13, 2023
@sherlock-admin sherlock-admin added Non-Reward This issue will not receive a payout and removed Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label labels Dec 13, 2023
@Czar102 Czar102 added the Medium A valid Medium severity issue label Dec 21, 2023
@sherlock-admin sherlock-admin added Reward A payout will be made for this issue Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label and removed Non-Reward This issue will not receive a payout labels Dec 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label Medium A valid Medium severity issue Reward A payout will be made for this issue
Projects
None yet
Development

No branches or pull requests

3 participants