Core Contracts

Regnum Aurum Acquisition Corp
HardhatReal World AssetsNFT
77,280 USDC
View results
Submission Details
Severity: high
Invalid

Lack of Balance Check Before Refund in mint Function

Summary

In the mint function in the RAACNFT.sol The contract attempts to refund excess ERC20 tokens after minting an NFT but does not check if it has enough balance before transferring. If the contract does not have enough ERC20 tokens, the transaction will fail and revert, causing users to be unable to mint NFTs, leading to a denial of service (DoS).

Affected code:

if (_amount > price) {
uint256 refundAmount = _amount - price;
token.safeTransfer(msg.sender, refundAmount);
}

Attack Scenario:

  1. A user calls mint and transfers more tokens than required.

  2. The contract attempts to refund the excess.

  3. If the contract has an insufficient ERC20 balance (due to other withdrawals or fund mismanagement), the transaction fails entirely.

  4. The NFT is not minted, and the user is stuck in an irreversible failed transaction.

Proof of Concept (PoC)

Scenario: Contract Lacks Sufficient ERC20 Tokens for Refund

// Assume user needs to pay 100 tokens for NFT
mint(1, 150);

// Contract should refund 50 tokens````// However, contract only has 30 tokens in balance````// safeTransfer fails, reverting the transaction

This means if multiple users try to mint NFTs and the contract does not have enough balance, all mint transactions fail and revert.

Vulnerability Details

Impact

if multiple users try to mint NFTs and the contract does not have enough balance, all mint transactions fail and revert.

Tools Used

manual review

Recommendations

Before refunding, check the contract’s ERC20 balance

uint256 contractBalance = token.balanceOf(address(this));if (_amount > price && contractBalance >= (_amount - price)) {token.safeTransfer(msg.sender, _amount - price);}
Updates

Lead Judging Commences

inallhonesty Lead Judge 7 months ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.

Give us feedback!