UserManager.sol#L438-L466 : getFrozenInfo could revert due to out of gas when the vouchees array size is large
The getFrozenInfo function iterates over the vouchees array and performs gas-intensive operations, which could cause it to revert due to out-of-gas when the array is large. This would affect any function that calls getFrozenInfo.
Source: https://github.com/sherlock-audit/2022-10-union-finance-judging/issues/87
Found by
ak1
Summary
The function getFrozenInfo travers the vouchees array and calculates uint256 memberTotalFrozen, uint256 memberFrozenCoinAge.
When the vouchees array is large, calling this function could revert due to out of gas.
Vulnerability Detail
The function getFrozenInfo travers the vouchees array and calculates uint256 memberTotalFrozen, uint256 memberFrozenCoinAge.
When the vouchees array is large, calling this function could revert due to out of gas.
Loading of two type of struct data in memory and math operations are done, this could be gas costly and could revert when vouchee size is large.
Impact
This affect the functions wherever the getFrozenInfo is called. https://github.com/sherlock-audit/2022-10-union-finance/blob/main/union-v2-contracts/contracts/user/UserManager.sol#L863 https://github.com/sherlock-audit/2022-10-union-finance/blob/main/union-v2-contracts/contracts/user/UserManager.sol#L881
Code Snippet
Tool used
Manual Review
Recommendation
Put cap on number of vouchee size. Do operation based on upto certain index and then do for others. Do not use for full length of array in single shot.
Discussion
dmitriia
vouchees do have cap on the length: if (voucheesLength >= maxVouchers) revert MaxVouchees() in updateTrust().
Name still needs to be corrected though to be maxVouchees.
Anyway it's fully valid for the index introduction part.
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
Root cause
Likely the function processes an unbounded array without limiting the number of iterations, leading to excessive gas consumption.
Impact
Functions that call getFrozenInfo could become unusable when the vouchees array is large, potentially causing denial of service.
What the attacker needed
Large vouchees array
The fix
The recommendation is to cap the number of vouchees processed or process the array in smaller batches to avoid out-of-gas reverts.
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, every operation costs gas, and if you run out of gas, the transaction fails. This report says a function that loops over a list of users could use too much gas if the list is long, causing it to fail. That would break other functions that rely on it.
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.