Reproduced Exploit

Pheasant BondManager: the second withdrawal request locks the first 100

A depositor withdraws in two steps: executeWithdrawBond, then finalizeWithdrawalBond. The execute call subtracts the amount from bonds immediately and stores a single bondWithdrawal. A second execute replaces that struct. Finalize pays only the second amount. The first amount has already left bonds…

May 2023•Ethereum•untagged•3 min read

Loss

100 bond tokens stay in the contract. A 1000 deposit with requests of 100 and then 300 pays only 300

Chain

Ethereum

Category

untagged

Date

May 2023

Source

AuditVault

EVM Playground

Source-level debugger — step opcodes and Solidity in sync

evm-hack-analyzer

The attack replays in your browser. Step through it by Solidity line or by opcode.

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: 60331-relayers-bond-funds-can-be-lost-quantstamp-pheasant-network. Standalone Foundry PoC and full write-up: 60331-relayers-bond-funds-can-be-lost-quantstamp-pheasant-network_exp in the evm-hack-registry mirror.


Vulnerability classes: vuln/logic · vuln/defi

Key info#

FieldValue
Loss100 bond tokens stay in the contract. A 1000 deposit with requests of 100 and then 300 pays only 300
Vulnerable contractBondManager.executeWithdrawBond
Attacker EOA0x1111111111111111111111111111111111111111
Attack contractExploit
Attack txExploit.run()
Chain / block / dateEthereum model · block 0 · 2023-05
Compilersolc 0.8.27, cancun, via IR
Bug classOne pending-withdrawal slot is overwritten after the amount was already deducted

TL;DR#

A depositor withdraws in two steps: executeWithdrawBond, then finalizeWithdrawalBond. The execute call subtracts the amount from bonds immediately and stores a single bondWithdrawal. A second execute replaces that struct. Finalize pays only the second amount. The first amount has already left bonds and is never transferred.

The report's numbers, here in 18-decimal units: deposit 1000, request 100 (bonds = 900), request 300 (bonds = 600), finalize pays 300. The contract still holds 700. 700 − 600 = 100 has no withdrawal record.

The fixed manager rejects a new request while one is pending. Finalizing the 100 before requesting the 300 pays both. Stuck is 0, not 100.

The vulnerable code#

SOLIDITY
function executeWithdrawBond(uint256 tokenId, uint256 amount) external {
    bonds[tokenId] -= amount;
    bondWithdrawal[msg.sender] = Withdrawal(block.timestamp, tokenId, amount); // @> VULN
}

finalizeWithdrawalBond transfers bondWithdrawal.amount and nothing else.

Root cause#

The deduction and the record are not the same object. bonds is reduced on every request. The record that finalize reads can remember only one request. Replacing the record does not put the previous amount back into bonds.

Preconditions#

  • The caller has a bond balance of at least 400, so both requests succeed.
  • The caller invokes executeWithdrawBond twice before finalizeWithdrawalBond.
  • No admin key is required. Deposit and both withdrawal calls are open to the depositor.

Attack walkthrough#

  1. Deposit 1000. bonds[1] = 1000.
  2. executeWithdrawBond(1, 100). bonds[1] = 900. Pending amount is 100.
  3. executeWithdrawBond(1, 300). bonds[1] = 600. Pending amount is 300. The 100 record is gone.
  4. Finalize transfers 300.
  5. The contract holds 700 and bonds says 600. The gap of 100 is stuck.

Diagrams#

flowchart TD A["Deposit 1000"] --> B["executeWithdrawBond 100, bonds = 900"] B --> C["executeWithdrawBond 300 overwrites the pending record"] C --> D["bonds = 600, pending = 300"] D --> E["finalize pays 300"] E --> F["100 is deducted and never paid"]

Impact#

The depositor asked to withdraw 400 and can receive only 300. The other 100 remains in BondManager and is not tracked by bonds or by bondWithdrawal, so a later finalize of the remaining 600 does not return it.

How to reproduce#

BASH
cd 60331-relayers-bond-funds-can-be-lost-quantstamp-pheasant-network_exp
forge test -vv

test_run_overwrittenRequestLocks100 calls run() and checks the stuck amount is 100, the payout is 300, and bonds is 600. test_control_finalizeBetweenRequestsPaysBoth pays 400 and checks the stuck amount is 0, not 100.

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.