Beginner FriendlyFoundryNFT
100 EXP
View results
Submission Details
Severity: medium
Valid

Lack of withdraw function in `payable` mint macro, funds can stuck in contract forever

Summary

There is a potential vulnerability in the Mint function of the HorseStore.huff, denoted by the macro _MINT(). The issue arises from the comment indicating that the Mint function is payable without a corresponding withdraw function, leading to a situation where Ether (ETH) sent to the contract can become stuck indefinitely.

Vulnerability Details

The vulnerability is associated with the Mint function, as defined by the macro _MINT(). Specifically, the function lacks a mechanism to withdraw Ether (ETH) from the contract after it has been received. Without a withdraw function, any Ether sent to the contract through the Mint function will remain trapped within the contract, creating a potential loss of funds for users.

/// @notice Mint
/// @notice Mints a new token
/// @dev The Mint function is payable
#define macro _MINT() = takes (2) returns (0) {
// ... (function implementation)
}

Impact

The absence of a withdraw function in the Mint operation means that any Ether sent to the contract through this function cannot be retrieved. As a result, users who mint tokens and send Ether along with the transaction may face a loss of funds, as there is no mechanism to extract the trapped Ether from the contract.

Tools Used

Manual review.

Recommendations

To address the identified vulnerability, the following recommendations are provided:

Add a Withdraw Function: Implement a withdraw function that allows the contract owner or users to retrieve any Ether stuck in the contract.

OR another alternative is:

Make Mint Function Non-Payable: Consider making the Mint function non-payable if there is no intended functionality requiring Ether to be sent along with token minting. This can prevent users from inadvertently sending Ether to the contract and facing potential loss.

Updates

Lead Judging Commences

inallhonesty Lead Judge over 1 year ago
Submission Judgement Published
Validated
Assigned finding tags:

HUFF functions are payable when they shouldn't be

Support

FAQs

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