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

djanerch - Functions can reach block gas-limit via unbounded operations #32

Closed
sherlock-admin opened this issue Nov 25, 2023 · 1 comment
Labels
Excluded Excluded by the judge without consulting the protocol or the senior Non-Reward This issue will not receive a payout

Comments

@sherlock-admin
Copy link
Contributor

sherlock-admin commented Nov 25, 2023

djanerch

medium

Functions can reach block gas-limit via unbounded operations

Summary

Smart contract vulnerabilities, particularly related to gas limit issues, can have severe consequences. One critical vulnerability arises when functions demand more gas than the block limit allows, commonly occurring in loops that iterate over dynamic data structures.

Vulnerability Detail

Certain smart contract functions are at risk due to inadequate size validation of arrays, particularly in loops iterating over dynamic data structures. Neglecting to check input array sizes before execution can lead to computational requirements exceeding the block gas limit, resulting in transaction failures and state rollback. This vulnerability is especially crucial in decentralized finance (DeFi) applications where precise function execution is vital.

Impact

Gas limit vulnerabilities extend beyond transaction failures, potentially causing funds locking, contract freezing, operational disruptions, and broader economic consequences for users and the ecosystem.

  1. Funds Locking: Users may struggle to access or withdraw funds, leading to financial losses and trust erosion.

  2. Contract Freezing: Gas limit failures can freeze the contract's state, affecting DApps relying on its functionality.

  3. Operational Disruption: Disruptions in DeFi protocols may inconvenience users and harm the project's reputation.

  4. Economic Consequences: Gas-related failures can have economic repercussions for users, investors, and the ecosystem.

Code Snippet

Tool Used

Manual Review

Recommendation

To strengthen smart contracts against gas limit vulnerabilities and mitigate their impact, consider implementing the following measures:

  1. Check Array Length:

    • Validate array lengths using the require statement before iterating to prevent exhaustion.
    function executeDepositTrades(uint256[] memory amounts) external {
        require(amounts.length <= MAX_ARRAY_LENGTH, "Array length exceeds maximum");
        // rest of the function
    }
  2. Limit Iteration:

    • Utilize a for loop with proper indexing to iterate over array elements, ensuring bounds are respected.
    function executeRedemptionTrades(uint256[] memory exitBalances) external {
        require(exitBalances.length <= MAX_ARRAY_LENGTH, "Inner array length exceeds maximum");
        // rest of the loop body
    }
  3. Gas Limit Consideration:

    • Be aware of gas limits for each Ethereum block. For extensive computations, consider breaking down tasks into smaller transactions.
@github-actions github-actions bot added Has Duplicates A valid issue with 1+ other issues describing the same vulnerability Excluded Excluded by the judge without consulting the protocol or the senior labels Nov 27, 2023
@nevillehuang
Copy link
Collaborator

Invalid, lack of proof to show how this is possible and also impractical usage of parameters to reach OOG based on sherlock rules.

Exception: In case the array length is controlled by the trusted admin/owner or the issue describes an impractical usage of parameters to reach OOG state then these submissions would be considered as low.

@sherlock-admin2 sherlock-admin2 changed the title Wonderful Mulberry Orangutan - Functions can reach block gas-limit via unbounded operations djanerch - Functions can reach block gas-limit via unbounded operations Dec 4, 2023
@sherlock-admin2 sherlock-admin2 added Non-Reward This issue will not receive a payout and removed Has Duplicates A valid issue with 1+ other issues describing the same vulnerability labels Dec 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Excluded Excluded by the judge without consulting the protocol or the senior Non-Reward This issue will not receive a payout
Projects
None yet
Development

No branches or pull requests

3 participants