Skip to content
DoS Audit finding Intermediate

Unbounded liquidation history can DoS helper liquidation paths

The contract stores each borrower's liquidation history as a single unbounded vector that is fully rewritten on every new record. An attacker could repeatedly trigger small liquidations to inflate this history until the helper's liquidation path reverts during bookkeeping, disabling it for that borrower.

v12 Follow

Originally disclosed on Code4rena

Submitted by v12

Found by V12

  • contracts/liquidation-engine/src/storage.rs #L100
  • contracts/liquidation-engine/src/contract.rs #L49
  • contracts/liquidation-engine/src/storage.rs #L169

Targets

  • LiquidationEngineContract::addliquidationrecord
  • LiquidationEngineContract::execute_liquidation
  • LiquidationEngineContract::getuserliquidation_ids

Affected Locations

  • LiquidationEngineContract.addliquidationrecord: Loads the borrower’s full user_liquidations Vec<u32>, appends one liquidation_id, and rewrites the entire vector with no cap, chunking, or pruning.
  • LiquidationEngineContract.execute_liquidation: Calls the router liquidation flow and then unconditionally records the liquidation, so oversized history can cause the whole helper-mediated liquidation to fail during post-liquidation bookkeeping.
  • LiquidationEngineContract.getuserliquidation_ids: Returns the entire per-user liquidation history in one shot and is also used by the append path, amplifying the cost of both reads and writes as history grows.

Description

The contract stores each borrower’s liquidation history as a single persistent Vec<u32> and rewrites that entire collection every time a new record is added. add_liquidation_record first retrieves the full history through get_user_liquidation_ids, appends one more ID, and writes the whole vector back without any cap, pagination, chunking, or archival strategy. Because execute_liquidation always performs this bookkeeping after a successful router liquidation, the helper’s state-changing path inherits a cost that grows linearly with the user’s historical liquidation count. Since liquidations are permissionless and findings note that an attacker can use very small liquidations over time, a target borrower’s history can be inflated until serialization, memory, or execution limits are exceeded. The same unbounded design also makes the public history read path increasingly expensive and eventually unusable for that borrower.

Root Cause

Per-user liquidation history is kept in one ever-growing Vec<u32> that add_liquidation_record and get_user_liquidation_ids process monolithically instead of using bounded or paginated storage.

Impact

An attacker can grief an undercollateralized borrower by repeatedly appending liquidation records until execute_liquidation through the helper reverts during history maintenance. This disables the helper contract’s liquidation and history-query path for the affected user and can force integrators to bypass the helper and use the router directly, while the oversized state remains stuck on-chain.

Proof of Concept

See original finding for full Proof of Concept

Remediation

Replace the per-user monolithic liquidation-id vector with fixed-size paged storage. execute_liquidation now appends to only one bounded page plus a per-user count, preserving record ordering and legacy reads while removing the unbounded read-modify-write that let liquidation history growth exhaust budget on helper liquidations.

See original finding for detailed patch

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

Per-user liquidation history is stored in one ever-growing vector that is processed monolithically without pagination or bounds.

Impact

An attacker could grief an undercollateralized borrower by inflating their liquidation history until the helper's execute_liquidation reverts, disabling the helper's liquidation and history-query path for that user.

What the attacker needed

Permissionless liquidations; attacker can trigger many small liquidations

The fix

The per-user monolithic vector should be replaced with fixed-size paged storage so that appends touch only one bounded page plus a count.

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 every liquidation a borrower has had. Each time a new liquidation happens, the whole list is read and written back. Because anyone can trigger liquidations, an attacker can make the list very long, so the contract runs out of resources and fails when trying to update it.

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 v12

View all

37 more disclosed reports, best first.

More from K2

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.