Skip to content
DoS Audit finding Intermediate

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.

ak1 Follow

Originally disclosed on Sherlock

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

https://github.com/sherlock-audit/2022-10-union-finance/blob/main/union-v2-contracts/contracts/user/UserManager.sol#L438-L466

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

https://github.com/sherlock-audit/2022-10-union-finance/blob/main/union-v2-contracts/contracts/user/UserManager.sol#L889

Code Snippet

https://github.com/sherlock-audit/2022-10-union-finance/blob/main/union-v2-contracts/contracts/user/UserManager.sol#L438-L466

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.

https://github.com/sherlock-audit/2022-10-union-finance/blob/main/union-v2-contracts/contracts/user/UserManager.sol#L548

Anyway it's fully valid for the index introduction part.

The original report as published on Sherlock, by ak1. Images and videos are our own copies; raw HTML is shown as text. View it on Sherlock.

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.

More by ak1

View all

6 more disclosed reports, best first.

More from Union Finance

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.