Reproduced Exploit

Regnum Aurum: harvest books 0.1 yield on a 0.095 share position and takes 0.005 of principal

_harvestYield multiplies totalDeposits by the share-price increase. totalDeposits stores the 1e18 assets deposited, not the 0.95e18 shares received. A 0.1e18 price increase books 0.1e18 of yield. The shares earned 0.095e18. The extra 0.005e18 is depositor principal withdrawn to the lending pool.

Jun 2025•Ethereum•logic•3 min read

Loss

The lending pool receives 0.1 asset. Fair yield is 0.095. Vault principal falls from 0.95 to 0.945

Chain

Ethereum

Category

logic

Date

Jun 2025

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. 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: 66503-h-02-harvestyield-incorrectly-uses-total-deposits-when-calc. Standalone Foundry PoC and full write-up: 66503-h-02-harvestyield-incorrectly-uses-total-deposits-when-calc_exp in the evm-hack-registry mirror.


Vulnerability classes: vuln/logic/reward-calculation · vuln/logic/state-update

Key info#

FieldValue
LossThe lending pool receives 0.1 asset. Fair yield is 0.095. Vault principal falls from 0.95 to 0.945
Vulnerable contractVaultYield.harvest
Attacker EOA0x1111111111111111111111111111111111111111
Attack contractExploit
Attack txExploit.run()
Chain / block / dateEthereum model · block 0 · 2025-06
Compilersolc 0.8.27, cancun, via IR
Bug classYield is priced on assets deposited instead of shares minted

TL;DR#

_harvestYield multiplies totalDeposits by the share-price increase. totalDeposits stores the 1e18 assets deposited, not the 0.95e18 shares received. A 0.1e18 price increase books 0.1e18 of yield. The shares earned 0.095e18. The extra 0.005e18 is depositor principal withdrawn to the lending pool.

The vulnerable code#

SOLIDITY
uint256 priceDifference = currentSharePrice - lastSharePrice;
// @> VULN: totalDeposits is assets deposited, not the shares that earn the price
uint256 totalYield = (totalDeposits * priceDifference) / 1e18;

The finding's numbers: 1e18 * 0.1e18 / 1e18 = 0.1e18, against 0.95e18 * 0.1e18 / 1e18 = 0.095e18.

Root cause#

The deposit path records assets in totalDeposits and mints fewer shares. Harvest then treats that asset figure as if it were the share balance.

Preconditions#

  • 1 asset deposited, 0.95 shares minted, lastSharePrice recorded as 1.
  • Vault assets later stand at 1.045, so the share price is 1.1.

Attack walkthrough#

  1. Read the share price. It is 1.1, so the difference from the recorded price is 0.1.
  2. Harvest books 1 * 0.1 = 0.1 and transfers 0.1 to the lending pool.
  3. Vault assets fall to 0.945. Principal at the old price was 0.95.
  4. The control stores 0.95 in totalDeposits, books 0.095, and leaves 0.95 in the vault.

Diagrams#

flowchart TD A["1 asset deposited and 0.95 shares minted"] --> B["Share price rises by 0.1"] B --> C["VULN multiplies the 1 asset deposit by 0.1"] C --> D["Harvest withdraws 0.1 to the lending pool"] D --> E["Vault assets fall to 0.945"] B --> F["Share base of 0.95 books 0.095 and leaves 0.95"]

Impact#

Depositors' principal is 0.005 asset smaller, and unclaimedRewards is overstated by that amount. The lending pool's reserve is the account that received the extra withdrawal.

Remediation#

Store the minted shares in totalDeposits, which is what the finding recommends. Yield is then shares * priceDifference / 1e18.

How to reproduce#

BASH
cd 66503-h-02-harvestyield-incorrectly-uses-total-deposits-when-calc_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.