Reproduced Exploit

Ajna Protocol — PositionManager's `moveLiquidity` freezes residual LP on partial moves

1. moveLiquidity removes fromIndex from positionIndexes before calling pool.moveQuoteToken. 2. moveQuoteToken can move only part of the requested quote when deposit is the binding constraint. 3. fromPosition.lps is reduced by the partial amount but the index is already gone. 4. Residual LP is untra…

May 2023Otherdos2 min read

Chain

Other

Category

dos

Date

May 2023

Source

AuditVault

EVM Playground

Source-level debugger — step opcodes and Solidity in sync

evm-hack-analyzer

The attack is replayed in an in-browser EVM preloaded with the exact dumped fork state. The execution tree shows every call; step by Solidity line or by opcode across all depths — source, Stack, Memory, Storage, Balances (native / ERC-20 / NFT), Transient storage and Return value stay in sync. Click a tree node, opcode, or source line to jump. No backend, no live RPC.

Loading fork state…

Source & credit. Reproduction of a public audit finding curated by AuditVault — the original finding: 20069-h-01-positionmanagers-moveliquidity-can-freeze-funds-by-remo. Standalone Foundry PoC and full write-up: 20069-h-01-positionmanagers-moveliquidity-can-freeze-funds-by-remo_exp in the evm-hack-registry mirror.


Vulnerability classes: vuln/dos/frozen-funds · impact/locked-funds

Reproduction: self-contained Foundry PoC with only forge-std — no fork. Full trace: output.txt.


Key info#

ImpactHIGH — residual LP after a partial moveQuoteToken is permanently frozen
ProtocolAjna Protocol — PositionManager
Vulnerable codePositionManager.moveLiquidity — unconditional positionIndex.remove(fromIndex)
Bug classState desync: index dropped before partial LP reduction completes
FindingCode4rena — Ajna, 2023-05 · #20069 · [H-01] · reporter hyh
Reportcode4rena.com/reports/2023-05-ajna
SourceAuditVault
Compiler^0.8.24 (PoC)

TL;DR#

  1. moveLiquidity removes fromIndex from positionIndexes before calling pool.moveQuoteToken.
  2. moveQuoteToken can move only part of the requested quote when deposit is the binding constraint.
  3. fromPosition.lps is reduced by the partial amount but the index is already gone.
  4. Residual LP is untracked → redeem/move paths cannot touch it → permanent freeze.

The vulnerable code#

SOLIDITY
// remove bucket index from which liquidity is moved from tracked positions
if (!positionIndex.remove(params_.fromIndex)) revert RemovePositionFailed(); // @> VULN
// ... later ...
fromPosition.lps -= vars.lpbAmountFrom; // residual may remain > 0

Root cause#

The index set is updated as if the move were always complete. Liquidity constraints in the pool make partial moves real; the PositionManager does not re-check residual LP before dropping the index.

Attack walkthrough#

  1. Memorialized position holds 100e18 LP; bucket deposit available is only 40e18.
  2. Owner calls moveLiquidity → index removed, only 40e18 LP moved.
  3. 60e18 residual remains at fromIndex with no set membership → redeem freezes.

Diagrams#

flowchart TD A[Memorialized LP 100e18 at fromIndex] --> B[moveLiquidity] B --> C["positionIndex.remove(fromIndex)"] C --> D["moveQuoteToken: only 40e18 deposit available"] D --> E["fromPosition.lps residual = 60e18"] E --> F["fromIndex not in set - residual unredeemable"] F --> G[Permanent fund freeze]

Impact#

Permanent freeze of residual LP for the NFT beneficiary whenever a partial quote move occurs.

Sources#

Taxonomy: [[frozen-funds]] · [[locked-funds]] · severity/high · sector/lending


Sources & further analysis#

Reproductions & code

Alerts & third-party analyses

  • Web3Sec X hacked database: search.
  • Rekt leaderboard: search.
  • Solodit incident search: search.

These dashboards index community alerts tweets, post-mortems, and independent write-ups. Reach them through the protocol name above to cross-check this reproduction against other analyses.