Reproduced Exploit

Peapods — self-lending rewards are swapped to the borrow token and never become fTokens

For a self-lending pod the paired LP token is an fToken. IS_PAIRED_LENDING_PAIR therefore swaps rewards into the lending pair's borrow token, with the intention of depositing that token for fTokens.

Nov 2024•Other•logic•3 min read

Chain

Other

Category

logic

Date

Nov 2024

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. Query opens a search over the trace: previous and next writes, balance changes and calls, breakpoints, and a diff of everything that changed between two steps. No backend, no live RPC.

Loading fork state…

Source & credit. Reproduction of a public audit finding curated by AuditVault — the original finding: 45984-c-02-for-self-lending-pairs-rewards-will-be-stuck-pashov-aud. Standalone Foundry PoC and full write-up: 45984-c-02-for-self-lending-pairs-rewards-will-be-stuck-pashov-aud_exp in the evm-hack-registry mirror.


Vulnerability classes: vuln/logic/reward-calculation · vuln/dos/frozen-funds

Reproduction: a self-contained Foundry PoC that compiles and runs offline with only forge-std — no fork and no RPC. Trace: output.txt. PoC: test/45984-c-02-for-self-lending-pairs-rewards-will-be-stuck-pashov-aud_exp.sol.


Key info#

ImpactHIGH — 1,000 reward tokens become borrow-token underlying and stay stuck; stakers receive 0 pod LP
ProtocolPeapods AutoCompoundingPodLp._tokenToPairedLpToken
Vulnerable codethe token != lpRewardsToken branch returns the swap output and does not deposit into the lending pair
Bug classSelf-lending compounder never converts underlying into the paired fToken
FindingPashov C-02 — Peapods, 16 Nov 2024 · id 45984
ReportPeapods security review
SourceAuditVault finding
Compilersolc 0.8.27, cancun, via IR

TL;DR#

For a self-lending pod the paired LP token is an fToken. IS_PAIRED_LENDING_PAIR therefore swaps rewards into the lending pair's borrow token, with the intention of depositing that token for fTokens.

That deposit happens only when the reward token equals lpRewardsToken. When it does not, _tokenToPairedLpToken returns the underlying amount. The later swap wants fTokens, reverts, and is swallowed by try/catch. The underlying sits in the compounder. compounded stays 0.

The fixed path deposits the underlying into the pair and mints 1,000 pod LP to the staker.

The vulnerable code#

SOLIDITY
if (address(token) != address(lpRewardsToken)) {
    amountOut = _swap(token, swapOutput, amountIn);
    return amountOut; // @> VULN: underlying is returned, never deposited for fTokens
}
DIFF
 if (address(token) != address(lpRewardsToken)) {
     amountOut = _swap(token, swapOutput, amountIn);
-    return amountOut;
+    swapOutput.approve(address(pairedLp), amountOut);
+    return pairedLp.deposit(amountOut, address(this));
 }

Attack walkthrough#

  1. The compounder holds 1,000 reward tokens. The reward token is not the pod LP reward token, and the pod is self-lending.
  2. processRewards swaps those tokens 1:1 into the borrow token.
  3. The function returns that amount instead of calling deposit.
  4. _swapPairedToPod requires an fToken balance, reverts, and the try/catch keeps going.
  5. The compounder holds 1,000 underlying, 0 fToken, and stakers hold 0 pod LP.

Diagrams#

flowchart TD A["Harvest swaps the reward into the borrow token"] --> B["Branch returns that underlying"] B --> C["No deposit into the lending pair"] C --> D["fToken swap reverts and is caught"] D --> E["Underlying is stuck and stakers get 0 pod LP"]

Impact#

Reward value that should have compounded into pod LP is frozen as the lending pair's underlying inside the aspTKN-style compounder. Stakers receive none of it. A later redemption of the pod does not see those tokens.

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.