# X7Finance X7Pioneer: empty-array claimRewards inflates rewards and drains pool

X7Pioneer's claimRewards() re-counts the same unaccounted ETH delta into totalRewards on empty-array calls, inflating per-token reward so one NFT drains the pool for ~6.78 ETH.

- Payout: Real-world hack
- Severity: high
- Program: X7Finance
- Analysis by: DeFiHackLabs
- Disclosed: 2026-10-08
- Write-up quality: 8/10
- Original: https://github.com/SunWeb3Sec/DeFiHackLabs/blob/main/src/test/2026-10/X7Finance_exp.sol
- Library page: https://bugbountylibrary.com/r/dhl%3A20261008-x7finance
- Tags: area:web3 domain:web3 impact:funds-loss kind:incident platform:defihacklabs sev:high tech:evm tech:solidity technique:chained technique:source-review vuln:business-logic vuln:flash-loan vuln:reward-distribution

**Target:** X7Pioneer NFT reward contract claimRewards() on Ethereum
**Root cause:** claimRewards() unconditionally adds (balance - lastETHBalance) to totalRewards on every call, but only refreshes lastETHBalance inside the claimable>0 branch; an empty tokenIds array makes claimable==0 so the same delta is re-counted repeatedly.
**Steps:**
1. Fork Ethereum at block 26146921 (parent of attack tx 0xc98056d6...).
2. Acquire one X7Pioneer NFT (id 300) and a ~26.96 ETH donation via Aave V3 WETH flash loan.
3. Send the donation ETH into X7Pioneer's receive() to create a balance delta over lastETHBalance.
4. Repeatedly call `claimRewards([])` (empty array) to re-add the same delta into totalRewards while lastETHBalance stays stale.
5. Call `claimRewards([300])` to claim totalRewards/totalSupply for the single owned NFT, paying out 33.756919822234785023 ETH.
6. Repay the flash-loan principal; net ~6.78 ETH profit.
**How found:** Read verified X7Pioneer source and noticed the totalRewards bump is unconditional while the lastETHBalance refresh is gated by claimable>0; realized caller-supplied tokenIds lets an empty array reach the bump with claimable==0, re-counting the same delta.
**Exploitation:** Permissionless: plain EOA owning NFT 300 donates flash-loaned ETH to create the delta, loops empty claimRewards([]) calls to inflate totalRewards, then a single claimRewards([300]) drains 33.75 ETH; principal repaid same tx leaving ~6.78 ETH net.
**Insight:** When an accumulator is bumped on every entry but its baseline is only refreshed on the payout path, look for caller-controlled inputs (empty arrays, zero amounts) that reach the bump while skipping the refresh — the same delta gets double-counted each call.

## Proof of concept (copied exactly from the original report)

**Empty-array claimRewards inflation loop**

```
uint256 before = X7P.totalRewards();
        uint256 calls;
        while (((X7P.totalRewards() + 2 * delta) / supply) - alreadyClaimed < poolBalance) {
            uint256[] memory none = new uint256[](0);
            X
```

