Reproduced Exploit

Megapot — Unoptimized subset matches counting exceeds Base tx gas limit

_countSubsetMatches regenerates subsets for every bonusball. At bonusballMax=129 the settlement callback measures ~25.8M gas and exceeds Base's 25M per-tx limit, so Pyth cannot settle the drawing.

Nov 2025Otheruntagged2 min read

Chain

Other

Category

untagged

Date

Nov 2025

Source

AuditVault

EVM Playground

Source-level debugger — step opcodes and Solidity in sync

evm-hack-analyzer

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. No backend, no live RPC.

Loading fork state…

Source & credit. Reproduction of a public audit finding curated by AuditVault — the original finding: 64141-h-02-unoptimized-subset-matches-counting-implementation-will. Standalone Foundry PoC and full write-up: 64141-h-02-unoptimized-subset-matches-counting-implementation-will_exp in the evm-hack-registry mirror.


Reproduction: self-contained Foundry PoC (forge-std only) — no fork. Full trace: output.txt.

AuditVault taxonomy: lang/solidity · platform/code4rena · severity/high · sector/gaming · genome: gas-limit · permanent


Key info#

ImpactHIGH — entropy callback exceeds Base 25M tx gas → drawing never settles
ProtocolMegapot
Bug classUncached generateSubsets inside bonusballMax × normalTiers nested loops
FindingCode4rena 2025-11-megapot H-02 · #64141
Reporthttps://code4rena.com/reports/2025-11-megapot
SourceAuditVault
StatusAudit finding — sample+extrapolate gas PoC
Compiler^0.8.24 (PoC)

TL;DR#

_countSubsetMatches regenerates subsets for every bonusball. At bonusballMax=129 the settlement callback measures ~25.8M gas and exceeds Base's 25M per-tx limit, so Pyth cannot settle the drawing.

HARM: extrapolated settlement gas at real bonusballMax exceeds Base tx gas limit → permanent drawing DoS.


Root cause#

Uncached combinatorial subset generation inside nested settlement loops.

Preconditions#

Large pool → high bonusballMax (e.g. 129 at 16M USDC cap).

Attack walkthrough#

Sample gas at small bonusballMax, extrapolate linearly to 129, require > 25_000_000.

Diagrams#

flowchart TD A["scaledEntropyCallback"] --> B["_countSubsetMatches"] B --> C["for i in 1..bonusballMax"] C --> D["for k in 1..normalTiers"] D --> E["generateSubsets uncached"] E --> F{"gas > 25M Base limit?"} F -->|Yes| G["callback fails - drawing stuck"]

Impact#

Drawings at high bonusballMax cannot be settled; jackpot liveness fails.

Sources#


Sources & further analysis#

Reproductions & code

Alerts & third-party analyses

  • Web3Sec X hacked database: search.
  • Rekt leaderboard: search.
  • Solodit incident search: search.

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.