Reproduced Exploit

Valantis STEX deposit mints extra shares off a stale pending withdrawal

Share minting uses reserve1 + amountToken0PendingUnstaking - amountToken1PendingLPWithdrawal. The pending LP withdrawal is left at 12 after 6 of native token1 has arrived, while pending unstaking is already 6.

Mar 2025•Ethereum•logic•2 min read

Loss

A deposit of 18 mints 27 shares. With the pending LP withdrawal updated, the same deposit mints 18

Chain

Ethereum

Category

logic

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: 56682-vlts3-5-the-calculation-of-shares-in-stexamm-is-incorrect-be. Standalone Foundry PoC and full write-up: 56682-vlts3-5-the-calculation-of-shares-in-stexamm-is-incorrect-be_exp in the evm-hack-registry mirror.


Vulnerability classes: vuln/logic/share-calculation · vuln/arithmetic/stale-accounting

Key info#

FieldValue
LossA deposit of 18 mints 27 shares. With the pending LP withdrawal updated, the same deposit mints 18
Vulnerable contractAMM.deposit
Attacker EOA0x1111111111111111111111111111111111111111
Attack contractExploit at 0x15452ec016c4dc8c549e7fe6ff4b26324ea8b7a4
Attack txExploit.run()
Chain / block / dateEthereum model · block 0 · 2025-03
Compilersolc 0.8.27, cancun, via IR
Bug classamountToken1PendingLPWithdrawal stays 12 after 6 of token1 has arrived
flowchart TD A["reserve1 is 18, pending unstaking is 6, pending LP withdrawal is still 12"] --> B["Deposit of 18 reads total assets as 18 plus 6 minus 12"] B --> C["VULN the denominator is 12"] C --> D["18 times 18 over 12 mints 27 shares"] B --> E["Control uses the updated pending withdrawal of 6"] E --> F["The denominator is 18 and the deposit mints 18"]

TL;DR#

Share minting uses reserve1 + amountToken0PendingUnstaking - amountToken1PendingLPWithdrawal. The pending LP withdrawal is left at 12 after 6 of native token1 has arrived, while pending unstaking is already 6.

Reserves are 18 and supply is 18. The stale denominator is 18 + 6 - 12 = 12. A deposit of 18 mints 18 * 18 / 12 = 27 shares. Updating the pending withdrawal to 6 makes the denominator 18 and mints 18. The extra mint is 9 shares.

The vulnerable code#

SOLIDITY
uint256 total = reserve1Pool + pending0 - pending1; // @> VULN: pendingLP is still 12, so total assets are 12 instead of 18
shares = amount * supply / total;

Impact#

The depositor is credited 27 shares against a pool that should have credited 18. The 9 extra shares claim more of the pool than the 18 deposited.

How to reproduce#

BASH
cd 56682-vlts3-5-the-calculation-of-shares-in-stexamm-is-incorrect-be_exp
forge test -vv

test_exploit_stale_pending_mints_27 asserts 27 shares. test_control_updated_pending_mints_18 asserts 18.

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.