Reproduced Exploit
RAAC BaseGauge: an unstaked veRAAC holder takes 1000 RWD
earned multiplies getUserWeight by the reward-per-token delta. getUserWeight returns the veRAAC balance and does not look at balances[account]. A second account stakes 1000 STK, which is what makes rewards accrue. The caller holds 1000 veRAAC and 0 STK, previews 1000 RWD, and getReward transfers al…
Loss
1000 RWD paid to an account whose staked balance is 0
Chain
Ethereum
Category
logic
Date
Feb 2025
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: 57156-basegauge-users-can-claim-rewards-without-staking-codehawks. Standalone Foundry PoC and full write-up: 57156-basegauge-users-can-claim-rewards-without-staking-codehawks_exp in the
evm-hack-registrymirror.
Vulnerability classes:
vuln/logic/reward-calculation·vuln/logic/missing-check
Key info#
| Field | Value |
|---|---|
| Loss | 1000 RWD paid to an account whose staked balance is 0 |
| Vulnerable contract | BaseGauge.earned |
| Attacker EOA | 0x0dc632da5faaae489f4efa12c2f27963d12c0ef9 (the ve holder) |
| Attack contract | Exploit |
| Attack tx | Exploit.run() |
| Chain / block / date | Ethereum model · block 0 · 2025-02 |
| Compiler | solc 0.8.27, cancun, via IR |
| Bug class | Reward weight is the veRAAC balance, not the staked balance |
TL;DR#
earned multiplies getUserWeight by the reward-per-token delta. getUserWeight returns the veRAAC balance and does not look at balances[account]. A second account stakes 1000 STK, which is what makes rewards accrue. The caller holds 1000 veRAAC and 0 STK, previews 1000 RWD, and getReward transfers all of it. The staker receives 0. The control returns 0 when stake is 0 and pays the 1000 RWD to the staker.
Background#
CodeHawks contest 2025-02-raac, Core Contracts, reported by 0xswahili. The gauge is supposed to pay accounts that staked. The published earned body uses getUserWeight, and that weight is derived from veToken.balanceOf. The recommended fix returns 0 when _balances[account] is 0 and otherwise multiplies by the staked balance.
The vulnerable code#
function earned(address account) public view virtual returns (uint256) {
// @> VULN: weight is the veRAAC balance, so an account with zero stake is still paid
return (getUserWeight(account) * (getRewardPerToken() - userStates[account].rewardPerTokenPaid) / 1e18)
+ userStates[account].rewards;
}
getRewardPerToken divides by totalSupply, the sum of staked balances. With rewardRate of 1000 RWD, one second, and 1000 STK staked, the per-token delta is 1e18. A ve balance of 1000 ether then earns 1000 RWD.
Root cause#
The paid weight and the balance that accrues the index are different variables. Stake creates the index. veRAAC collects it. getReward does not require a positive stake before it transfers.
Preconditions#
- Someone has staked, so
totalSupplyis not zero andrewardPerTokenmoves. - The caller holds veRAAC and has never staked.
- The gauge holds the reward tokens it is about to pay.
Attack walkthrough#
- The caller starts with 1000 veRAAC and a stake of 0.
- A staker deposits 1000 STK.
totalSupplybecomes 1000 STK. earnedfor the caller returns 1000 RWD.getRewardtransfers 1000 RWD to the caller. The gauge balance is 0.- The staker's reward balance is still 0, and their 1000 STK is still staked.
- The control pays 0 to a zero-stake ve holder and 1000 RWD to the staker.
Diagrams#
Impact#
The account that supplied the stake loses the reward that accrued against it. Any veRAAC holder can repeat the claim whenever totalSupply is non-zero. In this run the whole 1000 RWD moves in one call.
Remediation#
Return 0 from earned when the staked balance is 0, and multiply by balances[account] instead of getUserWeight(account).
How to reproduce#
cd 57156-basegauge-users-can-claim-rewards-without-staking-codehawks_exp
forge test -vv
test_exploit_unstaked_ve_holder_takes_rewards asserts the caller receives 1000 RWD with a stake of 0. test_control_zero_stake_earns_zero_and_staker_is_paid asserts the non-staker receives 0 and the staker receives 1000 RWD. Captured output is output.txt.
Sources#
- AuditVault finding: https://github.com/Auditware/AuditVault/blob/main/findings/57156-basegauge-users-can-claim-rewards-without-staking-codehawks.md
- CodeHawks submission: https://codehawks.cyfrin.io/c/2025-02-raac/s/3134
Sources & further analysis#
Reproductions & code
- Standalone PoC + full trace: 57156-basegauge-users-can-claim-rewards-without-staking-codehawks_exp (evm-hack-registry mirror).
- AuditVault finding: 57156-basegauge-users-can-claim-rewards-without-staking-codehawks.
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.