Reproduced Exploit

Valantis surplus is spent as the caller's swap payment

update wraps a native surplus and safeTransfers the wrapped token straight to the pool. A swap that sets isSwapCallback measures token.balanceOf(pool) after the callback and treats any increase as the caller's payment.

Mar 2025•Ethereum•reentrancy•3 min read

Loss

The caller receives 100 stHYPE. The 100 of token1 that pays for it comes from the module's surplus, not from…

Chain

Ethereum

Category

reentrancy

Date

Mar 2025

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: 56683-vlts3-13-direct-theft-of-surplus-balance-when-unstaking-sthy. Standalone Foundry PoC and full write-up: 56683-vlts3-13-direct-theft-of-surplus-balance-when-unstaking-sthy_exp in the evm-hack-registry mirror.


Vulnerability classes: vuln/reentrancy/callback-payment · vuln/defi/surplus-theft

Key info#

FieldValue
LossThe caller receives 100 stHYPE. The 100 of token1 that pays for it comes from the module's surplus, not from the caller
Vulnerable contractPool.swap
Attacker EOA0x1111111111111111111111111111111111111111
Attack contractExploit at 0x15452ec016c4dc8c549e7fe6ff4b26324ea8b7a4
Attack txExploit.run() with value 100, forwarded to the module
Chain / block / dateEthereum model · block 0 · 2025-03
Compilersolc 0.8.27, cancun, via IR
Bug classupdate transfers surplus token1 into the pool during a swap callback, and the pool counts that balance increase as payment
flowchart TD A["The module holds 100 of surplus and the pool holds 100 token0"] --> B["swap is called with the callback flag and no token1"] B --> C["The callback calls update"] C --> D["update wraps the 100 and transfers it to the pool"] D --> E["VULN the pool measures a balance increase of 100"] E --> F["The caller receives 100 token0"] B --> G["Control reverts update while the pool is inside swap"] G --> H["A normal swap pays its own 100 and the surplus stays"]

TL;DR#

update wraps a native surplus and safeTransfers the wrapped token straight to the pool. A swap that sets isSwapCallback measures token.balanceOf(pool) after the callback and treats any increase as the caller's payment.

The module holds 100. The pool holds 100 token0. The caller has no token1. During the callback, update moves the 100 into the pool. The pool records a payment of 100 and sends 100 token0 to the caller.

The fixed update reverts while pool.inSwap() is true, so the callback cannot spend the surplus. A swap with the callback flag off pulls 100 of the caller's own token1, and the module still holds its 100.

The vulnerable code#

SOLIDITY
uint256 got = token1.balanceOf(address(this)) - pre;
received = got; // @> VULN: token1 sent by update() during the callback counts as the caller's payment
require(got >= amountOut, "unpaid");

update is the quoted donor:

SOLIDITY
token1.deposit{value: surplus}();
token1.transfer(address(pool), surplus);

Impact#

The module's 100 surplus pays for the caller's swap. The caller holds 100 stHYPE and spent none of their own token1.

How to reproduce#

BASH
cd 56683-vlts3-13-direct-theft-of-surplus-balance-when-unstaking-sthy_exp
forge test -vv

test_exploit_surplus_pays_for_the_swap asserts the attacker holds 100 token0 and the module balance is 0. test_control_swap_cannot_spend_the_surplus asserts the callback reverts and a paid swap leaves the 100 surplus in the module.

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.