Skip to content
DoS Audit finding Intermediate

Permanent DOS in liquidity_lockbox for under $10

The liquidity_lockbox contract uses a fixed-size Program Derived Address (PDA) as a data account, and each deposit adds entries to three mappings, consuming storage. After about 625 deposits, the PDA runs out of space, preventing any further deposits and causing a permanent denial of service at a very low cost.

EV_om Follow

Originally disclosed on Code4rena

Submitted by EV_om

https://github.com/code-423n4/2023-12-autonolas/blob/main/lockbox-solana/solidity/liquidity_lockbox.sol#L54 https://github.com/code-423n4/2023-12-autonolas/blob/main/lockbox-solana/solidity/liquidity_lockbox.sol#L181-L184

The liquidity_lockbox contract in the lockbox-solana project is vulnerable to permanent DOS due to its storage limitations. The contract uses a Program Derived Address (PDA) as a data account, which is created with a maximum size limit of 10 KB.

Every time the deposit() function is called, a new element is added to positionAccounts, mapPositionAccountPdaAta, and mapPositionAccountLiquidity, which decreases the available storage by 64 + 32 + 32 = 128 bits. This means that the contract will run out of space after at most 80000 / 128 = 625 deposits.

Once the storage limit is reached, no further deposits can be made, effectively causing a permanent DoS condition. This could be exploited by an attacker to block the contract’s functionality at a very small cost.

Proof of Concept

An attacker can cause a permanent DoS of the contract by calling deposit() with the minimum position size only 625 times. This will fill up the storage limit of the PDA, preventing any further deposits from being made.

Since neither the contract nor seemingly Orca’s pool contracts impose a limitation on the minimum position size, this can be achieved at a very low cost of 625 * dust * transaction fees:

Recommended Mitigation Steps

The maximum size of a PDA is 10 KiB on creation, only slightly larger than the current allocated space of 10 KB. The Solana SDK does provide a method to resize a data account (source), but this functionality isn’t currently implemented in Solang (source).

A potential solution to this issue is to use an externally created account as a data account, which can have a size limit of up to 10 MiB, as explained in this StackExchange post.

Alternatively, free up space by clearing the aforementioned variables in storage for withdrawn positions.

However, a more prudent security recommendation would be to leverage the Solana SDK directly, despite the potential need for contract reimplementation and the learning curve associated with Rust. The Solana SDK offers greater flexibility and is less likely to introduce unforeseen vulnerabilities. Solang, while a valuable tool, is still under active development and will usually lag behind the SDK, which could inadvertently introduce complexity and potential vulnerabilities due to compiler discrepancies.

kupermind (Olas) confirmed


The original report as published on Code4rena, by EV_om. 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

The contract uses a fixed-size PDA for storage and never frees space when positions are withdrawn, so repeated deposits exhaust the available space.

Impact

An attacker could permanently block all deposits to the contract at a very low cost, denying service to legitimate users.

What the attacker needed

Ability to call deposit with minimum position size; no minimum position size enforced

The fix

The contract should be redesigned to use an externally created account with a larger size limit, or to clear storage for withdrawn positions, or to be reimplemented using the Solana SDK directly.

How it was found

  1. Call the deposit function with the minimum position size repeatedly.
  2. Each deposit adds entries to three mappings, consuming storage.
  3. After about 625 deposits, the PDA storage limit is reached.
  4. Further deposits fail, causing a permanent denial of service.

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 on Solana stores data in an account with a fixed maximum size. Each time someone deposits, the contract saves a little more data, and after enough deposits the account is full. Then no one can deposit anymore, and the contract is stuck.

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 EV_om

View all

23 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.