Beginner FriendlyFoundryNFT
100 EXP
View results
Submission Details
Severity: low
Invalid

Lack of Gas Limit Check in Loops

Summary

The codebase contains loops without gas limit checks, potentially leading to out-of-gas situations during contract execution. It is crucial to implement gas limit checks within loops to prevent excessive gas consumption, ensuring the stability and reliability of the smart contract.

Impact

The absence of gas limit checks in loops can result in out-of-gas situations during contract execution. This may lead to transaction failures or unexpected behavior, negatively impacting the reliability and availability of the smart contract.

Vulnerability Details

POC

// In the HorseStore.huff file
// Example:
macro MINT_HORSE() = takes (0) returns (0) {
[TOTAL_SUPPLY] // [TOTAL_SUPPLY]
caller // [msg.sender, TOTAL_SUPPLY]
_MINT() // []
stop // []
}

Tools Used

  • Manual code analysis

Recommendations

To address the lack of gas limit checks in loops, the following recommendation is provided:

  1. Gas Limit Check Logic:
    Insert gas limit check logic at the beginning of relevant loops to ensure that the execution does not exceed a predefined gas limit. If the gas consumption approaches the limit, gracefully exit the loop.

// Updated loop with gas limit check
#define macro MINT_HORSE() = takes (0) returns (0) {
gas 10000 lt exit // Exit loop if gas is below 10000
[TOTAL_SUPPLY] // [TOTAL_SUPPLY]
caller // [msg.sender, TOTAL_SUPPLY]
_MINT() // []
stop // []
}
Updates

Lead Judging Commences

inallhonesty Lead Judge over 1 year ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

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