# BaseRewardPool's rewardPerTokenStored can be inflated and rewards can be stolen

First staker depositing 1 wei inflates rewardPerTokenStored via totalSupply division, letting early depositors capture disproportionate reward share in BaseRewardPool.

- Payout: Contest reward
- Severity: medium
- Program: veToken Finance
- Credited: sorrynotsorry
- Disclosed: 2022-10-25
- Write-up quality: 6/10
- Original: https://github.com/code-423n4/2022-05-vetoken-findings/issues/201
- Library page: https://bugbountylibrary.com/r/c4%3A2022-05-vetoken%3AM-23
- Tags: domain:web3 impact:funds-loss kind:contest platform:code4rena sev:medium tech:evm tech:solidity technique:source-review vuln:accounting-error vuln:reward-distribution

**Target:** BaseRewardPool staking/reward contract (Solidity)
**Root cause:** rewardPerToken() divides by totalSupply(); when totalSupply is 1 wei, the reward-per-token accumulator is inflated astronomically, and userRewardPerTokenPaid snapshots that inflated value for the early staker.
**Steps:**
1. Attacker calls `stake(1)` first, setting totalSupply=1 wei and snapshotting userRewardPerTokenPaid.
2. Rewards are queued via `queueNewRewards(1e18)`.
3. Time passes; rewardPerToken() computes rewardRate*dt*1e18/1, inflating rewardPerTokenStored.
4. Attacker calls `withdraw(1, false)` / `getReward()` to claim rewards computed against inflated accumulator.
5. Judge's POC: early 1-wei staker received ~333e15 vs later 10-wei staker ~666e15; 1-wei deposit earned ~3x the per-unit rewards of a 1e18 deposit.
**How found:** Code reading of rewardPerToken()'s division by totalSupply() and the updateReward modifier snapshotting userRewardPerTokenPaid; hypothesis that a 1-wei first deposit inflates the accumulator.
**Exploitation:** Attacker front-runs reward funding by staking 1 wei, then withdraws after rewards accrue, capturing a disproportionate share of the reward pool due to the inflated per-token accumulator; judge's coded POC showed ~3x unfair reward gain, not full drain.
**Insight:** In Synthetix-style staking pools, the first-depositor / low-totalSupply window lets a 1-wei stake inflate rewardPerTokenStored; check whether the pool enforces a minimum initial deposit or seeds totalSupply before rewards start.
