Skip to content
DoS Audit finding Intermediate

activeTransactionBlocks are vulnerable to DDoS attacks

The smart contract's `activeTransactionBlocks` array can grow without limit, and the function that removes entries iterates over the entire array. An attacker can repeatedly call `prepare` with zero amount to push useless entries for any user, eventually making removal impossible and blocking legitimate transactions.

gpersoon Follow

Originally disclosed on Code4rena

Submitted by gpersoon, also found by pauliax and shw

There is a potential issue in function removeUserActiveBlocks and the for loop inside it. I assume you are aware of block gas limits (they may be less relevant on other chains but still needs to be accounted for), so as there is no limit for activeTransactionBlocks, it may grow so large that the for loop may never finish. You should consider introducing an upper limit for activeTransactionBlocks. Also, a malicious actor may block any account (DDOS) by just calling prepare again and again with 0 amount acting as a router. This will push activeTransactionBlocks to the specified user until it is no longer possible to remove them from the array.

This is also a gas issue, as function removeUserActiveBlocks iterating and assigning large dynamic arrays is very gas-consuming. Consider optimizing the algorithm, e.g. finding the first occurrence, then swap it with the last item, pop the array, and break. Or maybe even using an EnumerableMap, so you can find and remove elements in O(1).

The best solution depends on what the usual number of activeTransactionBlocks is. If it is expected to be low (e.g. less than 5), then the current approach will work. But with larger arrays, I expect EnumerableMap would be more efficient.

Because an upper limit will not fully mitigate this issue, as a malicious actor can still DDOS the user by pushing useless txs until this limit is reached and a valid router may not be able to submit new txs. And, because you need to improve both the security and performance of removeUserActiveBlocks; EnumerableMap may be a go-to solution.

LayneHaber (Connext) confirmed:

https://github.com/connext/nxtp/pull/24

The original report as published on Code4rena, by gpersoon. 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 lack of an upper bound on the `activeTransactionBlocks` array combined with an O(n) removal loop allows an attacker to bloat the array and cause out-of-gas errors.

Impact

A malicious actor could block any account from submitting or removing transactions, causing a denial of service.

What the attacker needed

Ability to call the `prepare` function; no cost or limit on zero-amount calls

The fix

The issue was fixed by introducing an upper limit and optimising the removal algorithm, as confirmed by the project.

How it was found

  1. Attacker calls `prepare` repeatedly with zero amount, specifying the victim's address as the router.
  2. Each call adds an entry to the victim's `activeTransactionBlocks` array.
  3. The array grows until it exceeds the block gas limit, making `removeUserActiveBlocks` fail.

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 pending transactions for each user. If the list gets too long, the code that cleans it up can run out of gas and fail. An attacker can make the list very long for any user by sending many tiny transactions, effectively locking that user out.

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 gpersoon

View all

47 more disclosed reports, best first.

More from Connext Amarok 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.