Reproduced Exploit

AdapterVault — proposer pregen_info forces a pool buy and extracts 3002 asset

pregen_info decodes into mint_returns and spot_returns, and mint_returns > spot_returns decides whether the vault mints PT or buys it in the pool. The proposer is not a trusted role. Setting mint to 0 and spot to 1 forces the swap after the proposer has bought PT and made it expensive. The vault sp…

May 2024•Other•defi•4 min read

Chain

Other

Category

defi

Date

May 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. No backend, no live RPC.

Loading fork state…

Source & credit. Reproduction of a public audit finding curated by AuditVault — the original finding: 55659-h-01-malicious-proposer-can-use-pregen-info-to-drain-vault-a. Standalone Foundry PoC and full write-up: 55659-h-01-malicious-proposer-can-use-pregen-info-to-drain-vault-a_exp in the evm-hack-registry mirror.


Vulnerability classes: vuln/defi/sandwich-attack · vuln/logic/missing-validation

Key info#

ProtocolAdapterFi AdapterVault
Finding0x52, AuditVault 55659
Vulnerable codebalanceAdapters trusts pregen_info
HarmThe proposer spends 5000 asset, forces the vault to buy PT in that pool, and sells back for 8002. Gain is 3002. The vault that ignores the caller mints instead, and the same trades return 5001.
Chainlocal synthetic

TL;DR#

pregen_info decodes into mint_returns and spot_returns, and mint_returns > spot_returns decides whether the vault mints PT or buys it in the pool. The proposer is not a trusted role. Setting mint to 0 and spot to 1 forces the swap after the proposer has bought PT and made it expensive. The vault spends 5000 asset to receive 1667 PT. The proposer sells the PT they bought and receives 8002 asset, a gain of 3002. A vault that computes the quote itself sees mint 5000 against a spot of 1667, mints, and the proposer's round trip makes 1 from integer rounding.

The vulnerable code#

SOLIDITY
if (trustCaller && pregenInfo.length > 0) {
    (mintReturns, spotReturns) = abi.decode(pregenInfo, (uint256, uint256));
}
// @> VULN: caller mint_returns and spot_returns choose mint versus the pool swap
if (mintReturns > spotReturns) {
    ptOut = assetAmount;
} else {
    ptOut = pool.swapAssetForPt(assetAmount);
}

The report says this data must be trusted and that the balance call should be withdraw-only so a proposer cannot aim the vault at a manipulated swap.

Root cause#

The branch that chooses mint or swap reads numbers the caller supplied. Those numbers are not the pool's quote. A proposer can make the swap branch run at whatever price the pool currently has.

Preconditions#

The pool starts at 10000 PT and 10000 asset. The vault holds 5000 asset and will deploy that amount. The proposer holds 5000 asset. No admin key is used. The three steps land in one transaction here. The report spreads them across a sandwich. The prices are the same.

Attack walkthrough#

  1. Swap 5000 asset for PT. The pool becomes 6666 PT and 15000 asset. The proposer receives 3334 PT.
  2. Call balanceAdapters(5000, abi.encode(0, 1)). Mint does not win.
  3. The vault swaps and receives 1667 PT for its 5000 asset.
  4. Sell the 3334 PT. The pool pays 8002 asset. Profit is 3002.
  5. On the vault that ignores the bytes, the computed spot after the same buy is 1667, which is below the mint of 5000, so it mints 5000 PT.
  6. Selling the 3334 PT back into the untouched pool returns 5001 asset.

Diagrams#

flowchart TD A["Proposer buys PT with 5000 asset"] --> B["pregen says mint is worse than spot"] B --> C["VULN: the vault swaps in the moved pool"] C --> D["Vault receives 1667 PT for 5000 asset"] D --> E["Proposer sells PT and gains 3002"] E --> F["Ignoring pregen mints 5000 and the round trip gains 1"]

Impact#

The proposer gains 3002 asset. That asset left the pool because the vault bought PT there at the proposer's price. The vault holds 1667 PT instead of the 5000 a mint would have produced. The vault that computes its own quote does not trade, and the proposer does not extract the 3002.

Remediation#

Do not let the caller choose mint versus swap. Compute both quotes in the vault, or call the adapter with withdraw-only set so this path cannot swap.

How to reproduce#

BASH
cd 55659-h-01-malicious-proposer-can-use-pregen-info-to-drain-vault-a_exp
forge test -vv

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.