removeValidator() and removeMinter() may fail due to exceeding gas limit
The removeValidator and removeMinter functions use unbounded loops over arrays that can grow large, so calling them may fail if the array size makes the transaction exceed the block gas limit. An attacker could potentially cause these functions to become unusable by increasing the array size, though the report does not demonstrate a concrete attack.
Submitted by oyc_109, also found by 0x4non, Chom, ladboy233, Lambda, lukris02, pashov, Respx, and V_B
Vulnerability Details
removeValidator() and removeMinter() may fail due to exceeding gas limit
for (uint256 i = 0; i < original_validators.length; ++i) {
if (i != remove_idx) {
validators.push(original_validators[i]);
}
}
for (uint i = 0; i < minters_array.length; i++){
if (minters_array[i] == minter_address) {
minters_array[i] = address(0); // This will leave a null in the array and keep the indices the same
break;
}
}
The removeValidator() is used to remove a validator from the array validators.
There is an unbounded loop in removeValidator() such that if the validators array gets sufficiently large, this function call will fail due to exceeding the gas limit.
The same issue exists in the removeMinter() function. If minters_array gets large, the function call will fail.
FortisFortuna (Frax) commented:
Technically correct, but in practice, the number of minters will always remain low. If it becomes an issue, we can designate one minter as a “pre-minter” that has a batch of tokens minted to it beforehand, then auxiliary contracts can connect to that instead of ERC20PermitPermissionedMint.sol instead.
I think Medium is appropriate here, given this could impact the functionality of the protocol.
Wouldn’t call this a risk to the functionality of the protocol, because sender can always send enough gas, and validator array gets truncated every time on is popped for use.
Unbounded for-loops should be handled with care but not sure a realistic impact can be demonstrated here to qualify for Medium.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Impact
The functions removeValidator and removeMinter could become uncallable if the arrays grow large, potentially disrupting the protocol's ability to remove validators or minters, though the report notes that in practice the number of minters is expected to remain low.
What the attacker needed
Arrays grow large enough to exceed gas limit
The fix
The functions should be redesigned to avoid unbounded loops, for example by using a mapping or by limiting the array size, so that removal operations do not depend on the total number of entries.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
In blockchain smart contracts, every operation costs 'gas', and there is a maximum amount of gas allowed per transaction. If a function loops over a list that can grow very long, the gas cost can exceed that maximum, causing the function to always fail. This report points out that two functions that remove items from lists have this problem, so they might become unusable if the lists get too big.
What is DoS?
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.