Reproduced Exploit

ParaSpace — [H-03] Interest rates are incorrect on Liquidation

1. _burnDebtTokens safeTransferFroms the repayment into the xToken, then calls updateInterestRates(liquidityAdded). 2. calculateInterestRates does balanceOf(xToken) + liquidityAdded, but the balance already includes the repayment. 3. Available liquidity is too high → utilization and liquidity rate…

Nov 2022Otherlogic2 min read

Chain

Other

Category

logic

Date

Nov 2022

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: 15976-h-03-interest-rates-are-incorrect-on-liquidation-code4rena-p. Standalone Foundry PoC and full write-up: 15976-h-03-interest-rates-are-incorrect-on-liquidation-code4rena-p_exp in the evm-hack-registry mirror.


Vulnerability classes: vuln/logic/liquidation-logic · genome/liquidation-logic · genome/variant

Reproduction: self-contained Foundry PoC with only forge-std — no fork. Full trace: output.txt. PoC: test/15976-h-03-interest-rates-are-incorrect-on-liquidation-code4rena-p_exp.sol.

AuditVault taxonomy: lang/solidity · platform/code4rena · has/github · has/poc · severity/high · sector/lending · genome: liquidation-logic · variant · data-corruption/price-manipulation · liquidation-underwater


Key info#

ImpactHIGH — every liquidation double-counts repaid liquidity and understates currentLiquidityRate
ProtocolParaSpace
Vulnerable codeLiquidationLogic._burnDebtTokens — transfer before updateInterestRates
Bug classIncorrect interest-rate accounting on liquidation
FindingCode4rena 2022-11-paraspace · #15976 (H-03) · reporter csanuragjain
Report2022-11-paraspace
SourceAuditVault
Compiler^0.8.24 (PoC)

TL;DR#

  1. _burnDebtTokens safeTransferFroms the repayment into the xToken, then calls updateInterestRates(liquidityAdded).
  2. calculateInterestRates does balanceOf(xToken) + liquidityAdded, but the balance already includes the repayment.
  3. Available liquidity is too high → utilization and liquidity rate are understated after every liquidation.

The vulnerable code#

SOLIDITY
// Transfers the debt asset being repaid to the xToken, where the liquidity is kept
debtAsset.transferFrom(payer, xToken, actualLiquidationAmount); // @> VULN: transfer BEFORE rates
// FIX: updateInterestRates first, then transferFrom

Root cause#

Interest-rate strategy assumes liquidityAdded has not yet hit the xToken balance. Liquidation transfers first, so the same amount is counted twice.


Preconditions#

  • A liquidation that repays variable debt and calls _burnDebtTokens with liquidityAdded > 0.

Attack walkthrough#

  1. xToken holds 100; total variable debt 100; liquidator repays 50.
  2. Buggy path: transfer then rates → availableLiquidity = (100+50)+50 = 200.
  3. Correct path: rates then transfer → availableLiquidity = 100+50 = 150.
  4. Buggy liquidity rate is strictly lower than the correct rate.

Diagrams#

flowchart TD A["Liquidator repays debt asset"] --> B["safeTransferFrom into xToken"] B --> C["updateInterestRates liquidityAdded"] C --> D["balanceOf xToken + liquidityAdded"] D --> E["Double-counted availableLiquidity"] E --> F["Understated currentLiquidityRate"]

Impact#

Protocol interest rates after liquidations are systematically wrong (liquidity rate too low), distorting supply/borrow incentives and reserve accounting.

Remediation#

Transfer the debt asset after updateInterestRates, matching the non-liquidation repay path.

Sources#


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.