Reproduced Exploit
Nexus: a withdrawal pays 100 ETH of a position that is backed by 150
DepositETH prices deposits and L2 withdrawals with a stored sharePrice and does not recompute it when Lido yield arrives. A user deposits 100 ETH at a 1:1 price and receives 100 shares. 50 ETH of yield then lands in the contract. sharePrice is still 1e18. The withdrawal pays shares * BASE / sharePr…
Loss
50 ETH of yield stuck in DepositETH. The withdrawer is paid 100 instead of about 150
Chain
Ethereum
Category
logic
Date
Nov 2024
Source
AuditVault
EVM Playground
Source-level debugger — step opcodes and Solidity in sync
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.
Source & credit. Reproduction of a public audit finding curated by AuditVault — the original finding: 44984-h-04-stale-share-price-usage-leading-to-fund-loss-and-unfair. Standalone Foundry PoC and full write-up: 44984-h-04-stale-share-price-usage-leading-to-fund-loss-and-unfair_exp in the
evm-hack-registrymirror.
Vulnerability classes:
vuln/logic/state-update·vuln/logic/price-calculation
Key info#
| Field | Value |
|---|---|
| Loss | 50 ETH of yield stuck in DepositETH. The withdrawer is paid 100 instead of about 150 |
| Vulnerable contract | DepositETH.messageReceivedL2 |
| Attacker EOA | 0x1111111111111111111111111111111111111111 (the depositor) |
| Attack contract | Exploit |
| Attack tx | Exploit.run() |
| Chain / block / date | Ethereum model · block 0 · 2024-11 |
| Compiler | solc 0.8.27, cancun, via IR |
| Bug class | sharePrice is not refreshed after yield, and the withdrawal divides by that stale value |
TL;DR#
DepositETH prices deposits and L2 withdrawals with a stored sharePrice and does not recompute it when Lido yield arrives. A user deposits 100 ETH at a 1:1 price and receives 100 shares. 50 ETH of yield then lands in the contract. sharePrice is still 1e18. The withdrawal pays shares * BASE / sharePrice, which is 100 ETH. The contract still holds 50 ETH, and the user has no shares left to claim it. Refreshing sharePrice before the withdrawal pays about 150 ETH.
Background#
Pashov Audit Group's 29 November 2024 Nexus review, finding H-04. DepositETH and DepositUSD convert deposits and withdrawals with sharePrice, which is meant to track Lido and sDAI yield. The report shows _depositETH and messageReceivedL2 both reading the stored price. Between a withdrawal request and its execution, rewards can accrue. The execution then uses the old price and the user receives less than the backing of their shares.
The vulnerable code#
function _depositETH(address receiver, uint256 _value) internal {
uint256 nETHShares = (sharePrice * _value) / BASE_POINT; // @> VULN: deposit mints shares from the stale sharePrice
ethDeposited += _value;
nETHMinted += nETHShares;
shares[receiver] += nETHShares;
}
if (_id == 3) {
uint256 _valueUSDCWithdraw = _value * BASE_POINT / sharePrice; // @> VULN: withdrawal pays the stale share price
_withdrawFunds(_receiver, _value, _valueUSDCWithdraw);
}
sharePrice here is a shares-per-asset index. It starts at BASE_POINT. Yield should lower it so each share pays more assets. The withdrawal divides by the old, higher index and underpays.
Refreshing before the payout is the report's recommendation:
function messageReceivedL2(uint256 _id, address _receiver, uint256 _value) external {
if (_id == 3) {
+ sharePrice = nETHMinted * BASE_POINT / asset.balanceOf(address(this));
uint256 _valueUSDCWithdraw = _value * BASE_POINT / sharePrice;
Root cause#
Yield changes the asset balance and nothing writes sharePrice. Both the deposit formula and the withdrawal formula trust the stored index. On the way out, a stale high index pays fewer assets than the shares are backed by. Burning the shares at the same time removes the user's claim on what was skipped.
Preconditions#
sharePriceis1e18andBASE_POINTis1e18.- The user deposits 100 ETH and receives 100 shares.
- 50 ETH of yield is transferred in before the L2 withdrawal, and no one calls the price update.
Attack walkthrough#
- Deposit 100 ETH.
nETHShares = 1e18 * 100 ETH / 1e18, so the user holds 100 shares. The vault holds 100 ETH. - 50 ETH of yield arrives. The vault holds 150 ETH.
sharePriceis still1e18. messageReceivedL2with id 3 prices the 100 shares:100 ETH * 1e18 / 1e18 = 100 ETH.- The user is paid 100 ETH.
sharesandnETHMintedgo to 0. The vault still holds 50 ETH. - The control calls
updateSharePriceafter the yield.sharePricefalls below1e18, and the same withdrawal pays more than 150 ETH aside from a few wei of inverse rounding.
Diagrams#
Impact#
The depositor is paid 100 ETH for shares backed by 150 ETH. The 50 ETH of yield stays in DepositETH. Because the withdrawal burns the shares, the user has no remaining balance to claim it, and the stored price will keep underpaying anyone else who exits before an update. The refreshed-price control pays the yield back.
Remediation#
Recompute sharePrice from nETHMinted and the current asset balance at the start of every deposit, withdrawal, and fee quote. That is the change the report asks for. Do not burn shares against a price that has not seen the yield.
How to reproduce#
cd 44984-h-04-stale-share-price-usage-leading-to-fund-loss-and-unfair_exp
forge test -vv
test_exploit_withdrawal_leaves_50_ether_stuck asserts the price is still 1:1, the user is paid 100 ETH, and 50 ETH remains with zero shares outstanding. test_control_refreshed_price_pays_the_yield asserts a refreshed price pays more than 150 ETH. Captured output is output.txt.
Sources#
- AuditVault finding: https://github.com/Auditware/AuditVault/blob/main/findings/44984-h-04-stale-share-price-usage-leading-to-fund-loss-and-unfair.md
- Pashov report: https://github.com/pashov/audits/blob/master/team/md/Nexus-security-review_2024-11-29.md
- Vulnerable lines: the
_depositETHandmessageReceivedL2snippets quoted in that report. The finding does not name an audited commit.
Sources & further analysis#
Reproductions & code
- Standalone PoC + full trace: 44984-h-04-stale-share-price-usage-leading-to-fund-loss-and-unfair_exp (evm-hack-registry mirror).
- AuditVault finding: 44984-h-04-stale-share-price-usage-leading-to-fund-loss-and-unfair.
Alerts & third-party analyses
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.