Possible DoS on vestingRecipients due to lack of disposal mechanism
The smart contract stores vesting recipient addresses in an array that only grows, with no way to remove entries. As more recipients are added, the function that returns the whole array will eventually require more gas than a block allows, so it will fail and the data becomes unreadable on-chain.
Originally disclosed on Code4rena
Submitted by fatherOfBlocks, also found by wagmi
VTVLVesting.sol#L224 VTVLVesting.sol#L245 VTVLVesting.sol#L302 VTVLVesting.sol#L317
When the smart contracts start to be used, the variable in storage vestingRecipients will start to be filled with addresses, as there is no mechanism to eliminate elements, this will cause the allVestingRecipients() function to generate a DoS yes has many addressess.
Recommended Mitigation Steps
In the withdraw() function you could remove the element from vestingRecipients that no longer has vesting. This would make the variable not grow without reducing elements.
On the fence on this one. I agree with the warden, but in the current implementation
allVestingRecipientsis unused and assumed to be for external, off chain uses so the impact is hard to determine. Going to leave as Medium, pending sponsor review.
lawrencehui (VTVL) confirmed and commented:
I would agree with the warden on the lack of control for an ever-growing array size could be an issue. I will tag this as an enhancement.
On the side, I want to check what is the allowed max size of the array in this case?
2**256 -1? but theoretically calling a large array would exceed the the block gas limit when retrieving it?
@lawrencehui - Yes retrieval will eventually fail, long before you populate the array fully. You could pass in an index range to retrieve portions of the array to avoid this failure mode.
And yes
2**256 -1is my understanding of the theoretical limit.
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 contract appends to a storage array without ever removing entries, so the array grows without bound and reading it all exceeds the block gas limit.
Impact
The function that returns all recipients will eventually fail when called on-chain, making the data inaccessible through the contract; the judge noted the function is currently unused and intended for off-chain use, so the practical impact is uncertain.
What the attacker needed
Many recipients added over time; calling the full-array read function
The fix
The withdraw function should remove the recipient from the array once their vesting is finished, or the read function should accept an index range to return only part of the array.
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.
A smart contract keeps a list of everyone who has a vesting schedule. The list can only get longer, never shorter. Eventually the list is so long that trying to read it all at once costs more gas than a block can hold, so the read fails.
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.