Skip to content
DoS Audit finding Intermediate

Calls inside loops that may address DoS

The contract makes external calls inside loops, which could cause a denial of service if one call reverts or runs out of gas. An attacker could exploit this with a malicious token to block batch operations.

sorrynotsorry Follow

Originally disclosed on Code4rena

Submitted by sorrynotsorry

Calls to external contracts inside a loop are dangerous (especially if the loop index can be user-controlled) because it could lead to DoS if one of the calls reverts or execution runs out of gas. Reference

Gravity.sol#L453-L456

Gravity.sol#L568-L573

Gravity.sol#L579-L581

Recommended Mitigation Steps

Avoid combining multiple calls in a single transaction, especially when calls are executed as part of a loop. Always assume that external calls can fail. Implement the contract logic to handle failed calls.

mlukanova (Cudos) acknowledged

Albert Chon (judge) commented:

Would really only happen for malicious/non-standard ERC-20 tokens which could then just be ignored by the orchestrator. No way of getting around doing the transfers for each token.


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

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 does not handle failed external calls inside loops, so a single revert aborts the entire batch.

Impact

A malicious or non-standard token could cause a denial of service for batch transfers, though the judge noted such tokens could be ignored by the orchestrator.

What the attacker needed

Malicious or non-standard ERC-20 token

The fix

The contract should handle failed external calls, for example by catching errors or avoiding multiple calls in one transaction.

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 sometimes sends tokens to many addresses in one go using a loop. If one of those transfers fails, the whole batch fails, so the operation stops working. This is a denial of service: an attacker could make one transfer fail on purpose to block everyone else.

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 sorrynotsorry

View all

4 more disclosed reports, best first.

More from Cudos contest

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.