# Randomness can be exploited in some cases

Megapot lottery derives normal and bonus balls from the same entropy seed, so when maxes are equal the bonus ball is always among the normal balls, inflating win odds.

- Payout: Contest reward
- Severity: medium
- Program: Megapot
- Credited: touristS
- Disclosed: 2026-01-05
- Write-up quality: 6/10
- Original: https://code4rena.com/reports/2025-11-megapot#m-05
- Library page: https://bugbountylibrary.com/r/c4%3A2025-11-megapot%3AM-05
- Tags: domain:web3 impact:funds-loss kind:contest platform:code4rena sev:medium tech:evm tech:solidity technique:source-review vuln:oracle-manipulation

**Target:** ScaledEntropyProvider.sol entropy callback / lottery draw
**Root cause:** entropyCallback passes the same randomNumber seed to _getScaledRandomness for both normal balls and bonus ball; when normalballMax == bonusballMax the bonus draw is drawn from the same sequence, so the bonus ball is always one of the normal balls.
**Steps:**
1. Observe entropyCallback uses single randomNumber for all setRequests including bonus ball.
2. Note bonusballMax equals normalballMax when prizePool ~2.99M-3.09M and lpEdgeTarget 30%.
3. Call FisherYates draw with same seed for 5-of-30 normals and 1-of-30 bonus; bonus value appears in normal set.
4. Compute exploited odds C(30,5)*C(5,1) ≈ 1 in 712,530 vs expected C(30,5)*C(30,1) ≈ 1 in 4,275,180.
5. Buy all 712,530 combinations to guarantee jackpot return.
**How found:** Code reading of entropyCallback revealed a single seed feeds both normal and bonus ball generation; noticed bonusballMax can equal normalballMax, then tested identical-seed draws showing bonus ball always in normal set.
**Exploitation:** Attacker enumerates all ~712,530 ticket combinations exploiting the guaranteed bonus-in-normals overlap, guaranteeing a winning ticket and positive expected return including jackpot.
**Insight:** When a lottery derives multiple independent draws from one entropy seed, check whether the ranges can coincide—if max values align, the smaller draw becomes a subset of the larger, collapsing the odds multiplicatively.
