# Pythia staking: reward logic flaw drains 21 ETH

Pythia staking reward logic flaw let attacker repeatedly stake/claim via helper contracts to drain 21 ETH of rewards.

- Payout: Real-world hack
- Severity: high
- Program: Pythia
- Credited: DeFiHackLabs
- Disclosed: 2024-09-02
- Write-up quality: 6/10
- Original: https://github.com/SunWeb3Sec/DeFiHackLabs/blob/main/src/test/2024-09/Pythia_exp.sol
- Library page: https://bugbountylibrary.com/r/dhl%3A20240902-pythia
- Tags: domain:web3 impact:funds-loss kind:incident platform:defihacklabs sev:high tech:evm tech:solidity technique:chained vuln:accounting-error vuln:business-logic vuln:reward-distribution

**Target:** Pythia staking contract on Ethereum mainnet
**Root cause:** Staking reward accounting is flawed, allowing rewards to be claimed repeatedly by cycling stake balance through fresh helper contracts without proper reward reset or time weighting.
**Steps:**
1. Fund attack contract with 1 ETH; swap 0.5 ETH to PYTHIA via Uniswap V2 router `swapExactETHForTokensSupportingFeeOnTransferTokens`.
2. Approve and `stake(bal)` PYTHIA into staking contract `0xe291...7461`.
3. Loop 30 times: read `spythia.balanceOf(this)`, deploy fresh `Helper`, `spythia.transfer(helper, stakeBal)`.
4. In Helper: call `spythia.claimRewards()`, transfer claimed PYTHIA and staked balance back to attacker contract.
5. Attacker contract re-stakes received PYTHIA (`spythia.stake(bal)`) to repeat.
6. After loop, transfer all sPYTHIA to attacker EOA.
**Exploitation:** Attacker staked PYTHIA, then repeatedly moved the staked position into fresh helper contracts that each called claimRewards, harvesting rewards each cycle while returning principal, compounding until 21 ETH of rewards were extracted.
**Escalation:** Looping 30 iterations with fresh helper contracts to multiply reward claims.
**Insight:** When auditing staking/reward contracts, check whether claimRewards depends on per-address state that resets on transfer; cycling stake through fresh addresses can re-trigger rewards if accounting isn't tied to time or global emission.
