Sending batch withdrawal requests can possibly DoS
The batch withdrawal function loops over an unbounded list of contracts, so if many contracts are added, the transaction can exceed the block gas limit and fail. An attacker could potentially cause a denial of service by making the list too large, though only the owner can add contracts.
Originally disclosed on Code4rena
Submitted by berndartmueller
The function BatchRequests.sendWithdrawalRequests allows calling the sendWithdrawalRequests function on all of the Yieldy contracts at once. However, due to the unbounded for loop, if many Yieldy contracts are added to contracts, this function can potentially DoS due to reaching the block gas limit.
Proof of Concept
BatchRequests.sendWithdrawalRequests
function sendWithdrawalRequests() external {
uint256 contractsLength = contracts.length;
for (uint256 i; i < contractsLength; ) {
if (
contracts[i] != address(0) &&
IStaking(contracts[i]).canBatchTransactions()
) {
IStaking(contracts[i]).sendWithdrawalRequests();
}
unchecked {
++i;
}
}
}
Recommended mitigation steps
Add offset and limit function parameters to implement a “paginated” for loop.
toshiSat (Yieldy) acknowledged and commented:
Only the owner of the contract can add addresses to the contract.
Hmm, would consider making this Low. But keeping it medium highlights the importance to be aware of this.
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 batch withdrawal function could become unusable if the list of contracts grows too large, but only the contract owner can add contracts, limiting the attack surface.
What the attacker needed
Owner adds many contracts
The fix
The function should be fixed by adding offset and limit parameters to process the list in smaller batches.
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.
This contract has a function that tries to send withdrawal requests to every contract in a list, one by one. If the list gets very long, the function might use more gas than a block allows, so it always fails. That means the function becomes unusable, which is a denial of service.
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.