Lucene search

K
code423n4Code4renaCODE423N4:2022-09-TRIBE-FINDINGS-ISSUES-113
HistorySep 12, 2022 - 12:00 a.m.

Deniel of service with block gas limit.

2022-09-1200:00:00
Code4rena
github.com
6
deniel of service
block gas limit
array size
smart contract
mitigation steps
ethereum

Lines of code
<https://github.com/code-423n4/2022-09-tribe/blob/769b0586b4975270b669d7d1581aa5672d6999d5/contracts/shutdown/redeem/TribeRedeemer.sol#L20&gt;

Vulnerability details

Impact

An array of unknown size can lead to Deniel of service with block gas limit.
<https://github.com/code-423n4/2022-09-tribe/blob/769b0586b4975270b669d7d1581aa5672d6999d5/contracts/shutdown/redeem/TribeRedeemer.sol#L20&gt;
<https://github.com/code-423n4/2022-09-tribe/blob/main/contracts/shutdown/redeem/TribeRedeemer.sol#L44-L61&gt;

Proof of Concept

When smart contracts are deployed or functions inside them are called, the execution of these actions always requires a certain amount of gas, based of how much computation is needed to complete them. The Ethereum network specifies a block gas limit and the sum of all transactions included in a block can not exceed the threshold.

In the case of the contract TribeRedeemer, an array of addresses is used to contain all the addresses which received tokens. This way the array gets bigger everytime the function previewRedeem() is triggered.

Programming patterns that are harmless in centralized applications can lead to Denial of Service conditions in smart contracts when the cost of executing a function exceeds the block gas limit. Modifying an array of unknown size, that increases in size over time, can lead to such a Denial of Service condition.

Tools Used

Manual review.

Recommended Mitigation Steps

Caution is advised when you expect to have large arrays that grow over time. Actions that require looping across the entire data structure should be avoided. If you absolutely must loop over an array of unknown size, then you should plan for it to potentially take multiple blocks, and therefore require multiple transactions.


The text was updated successfully, but these errors were encountered:

All reactions