Skip to content
DoS Audit finding Intermediate

Possible DOS when withdrawing liquidity from Solana Lockbox

The withdraw function requires callers to pass specific Solana accounts that depend on mutable state, so if another user withdraws first, the required accounts change and the transaction reverts. An attacker could repeatedly withdraw to cause denial of service for other users' withdrawals.

hash Follow

Originally disclosed on Code4rena

Submitted by hash

Possible DOS when withdrawing liquidity from Lockbox.

Proof of Concept

When withdrawing it is required to pass all the associated accounts in the transaction. But among these (position,pdaPositionAccount and positionMint) are dependent on the current modifiable-state of the account ie. if another withdrawal occurs, the required accounts to be passed to the function call might change resulting in a revert.

https://github.com/code-423n4/2023-12-autonolas/blob/2a095eb1f8359be349d23af67089795fb0be4ed1/lockbox-solana/solidity/liquidity_lockbox.sol#L194-L214

    @mutableAccount(pool)
    @account(tokenProgramId)
    @mutableAccount(position)
    @mutableAccount(userBridgedTokenAccount)
    @mutableAccount(pdaBridgedTokenAccount)
    @mutableAccount(userWallet)
    @mutableAccount(bridgedTokenMint)
    @mutableAccount(pdaPositionAccount)
    @mutableAccount(userTokenAccountA)
    @mutableAccount(userTokenAccountB)
    @mutableAccount(tokenVaultA)
    @mutableAccount(tokenVaultB)
    @mutableAccount(tickArrayLower)
    @mutableAccount(tickArrayUpper)
    @mutableAccount(positionMint)
    @signer(sig)
    function withdraw(uint64 amount) external {
        address positionAddress = positionAccounts[firstAvailablePositionAccountIndex];
        if (positionAddress != tx.accounts.position.key) {
            revert("Wrong liquidity token account");
        }

The DOS for a withdrawal can be caused by another user withdrawing before the user’s transaction. Due to the possibility to steal fees, attackers would be motivated to frequently call the withdraw method making such a scenario likely.

Recommended Mitigation Steps

To mitigate this it would require a redesign on how the lockbox accepts liquidity. Instead of adding new positions, the lockbox can keep its liquidity in a single position continuously increasing its liquidity for deposits.

mariapiamo (Olas) confirmed


The original report as published on Code4rena, by hash. 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 withdraw function relies on account addresses derived from mutable state (the first available position account index), so concurrent withdrawals invalidate the account list required by pending transactions.

Impact

An attacker could cause a denial of service for other users' withdrawals by front-running with their own withdrawal, and the report notes attackers are motivated to withdraw frequently to steal fees.

What the attacker needed

Attacker can call withdraw; victim's transaction is pending

The fix

The lockbox should be redesigned to hold liquidity in a single position that grows with deposits, rather than adding new positions.

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.

In Solana, a transaction must list every account it will touch, and those accounts must match what the program expects. Here, the expected accounts change whenever someone else withdraws, so a user's pre-built transaction can fail if another withdrawal happens first. An attacker can exploit this by withdrawing often to block others.

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 hash

View all

27 more disclosed reports, best first.

More from Olas

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.