Reproduced Exploit

DIA — updateRewardRatePerDay accrues 20 where the old rate accrued 100000

updateRewardRatePerDay stores the new rate, then accrues the elapsed days with that new rate, and divides by 10,000. The claim divides by 10,000 again.

Jun 2025•Other•logic•3 min read

Chain

Other

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. No backend, no live RPC.

Loading fork state…

Source & credit. Reproduction of a public audit finding curated by AuditVault — the original finding: 57924-incorrect-calculation-of-accrued-rewards-in-updaterewardrate. Standalone Foundry PoC and full write-up: 57924-incorrect-calculation-of-accrued-rewards-in-updaterewardrate_exp in the evm-hack-registry mirror.


Vulnerability classes: vuln/logic/reward-calculation · vuln/arithmetic/precision-loss

Reproduction: a self-contained Foundry PoC that compiles and runs offline with only forge-std — no fork and no RPC. Trace: output.txt. PoC: test/57924-incorrect-calculation-of-accrued-rewards-in-updaterewardrate_exp.sol.


Key info#

ImpactHIGH — a 10,000 principal is paid 20 WDIA instead of 100,000
ProtocolDIA DIARewardsDistribution
Vulnerable coderewardsAccrued = (rewardRatePerDay * daysElapsed) / 10000
Bug classAccrual uses the new rate and divides by 10,000 too early
FindingMixBytes — DIA Lumina Staking, June 2025 · id 57924
ReportLumina Staking
SourceAuditVault finding
Compilersolc 0.8.27, cancun, via IR

TL;DR#

updateRewardRatePerDay stores the new rate, then accrues the elapsed days with that new rate, and divides by 10,000. The claim divides by 10,000 again.

Here 100 days already elapsed at rate 1,000. The fair accumulator delta is 1000 * 100 = 100000. The function sets the rate to 2,000 first, then adds (2000 * 100) / 10000 = 20. A 10,000 principal is paid 20 * 10000 ether / 10000 = 20 ether. 99,980 WDIA stays in the distributor.

rewardLastUpdateTime is set 100 days before this block in the constructor. run() does not warp. The replay block is timestamp 8,640,001.

The vulnerable code#

SOLIDITY
rewardRatePerDay = newRewardRate;
uint256 daysElapsed = (block.timestamp - rewardLastUpdateTime) / SECONDS_IN_A_DAY;
// @> VULN: rewardsAccrued = (rewardRatePerDay * daysElapsed) / 10000 uses the new rate and divides twice
uint256 rewardsAccrued = (rewardRatePerDay * daysElapsed) / 10000;
rewardAccumulator += rewardsAccrued;

The claim then does stakerReward = (stakerDelta * principal) / 10000, which is the second division the report describes.

Root cause#

Two mistakes stack. The elapsed period is priced at the rate that was not in force, and the per-day index is scaled down by 10,000 before a second 10,000 scale is applied at claim time. For any realistic rate the first division collapses the index.

Preconditions#

  • 100 days separate rewardLastUpdateTime from this block.
  • The rate in force was 1,000. The update sets 2,000.
  • The staker's index is 0 and the principal is 10,000 ether.
  • The distributor holds 100,000 WDIA.

Attack walkthrough#

  1. Call updateRewardRatePerDay(2000).
  2. The accumulator becomes 20.
  3. Claim. The user receives 20 WDIA.
  4. The distributor still holds 99,980.

Control: accrue oldRewardRate * daysElapsed with no extra division, then set the new rate. The claim pays 100,000 and the distributor balance is 0.

Diagrams#

flowchart TD A["100 days at rate 1000"] --> B["Rate is overwritten with 2000"] B --> C["Accrue 2000 times 100 divided by 10000"] C --> D["Index becomes 20"] D --> E["Claim pays 20 and 99980 stays"]

Impact#

The staker is underpaid by 99,980 WDIA on a single 10,000 principal. Every stake whose index was last updated before this call shares the same collapsed delta. The reward tokens remain in the distributor instead of being paid.

Remediation#

Accrue with oldRewardRate * daysElapsed before writing rewardRatePerDay, and do not divide the accumulator by 10,000. Leave that scale to the claim, which already divides by 10,000.

Sources#

Taxonomy#

  • vuln/logic/reward-calculation · vuln/arithmetic/precision-loss

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.