# Crafted smart contract can take 8 minutes to execute due to bug in modexp precompile.

Crafted EVM bytecode calling the modexp precompile with pathological operands stalls RSK node execution for ~8 minutes, enabling network DoS.

- Payout: hidden
- Severity: high
- Program: Rootstock Labs
- Found by: guido
- Disclosed: 2025-06-13
- Write-up quality: 7/10
- Original: https://hackerone.com/reports/2412583
- Library page: https://bugbountylibrary.com/r/h1%3A2412583
- Tags: area:web3 domain:web3 impact:dos kind:bounty platform:hackerone sev:high tech:evm tech:solidity technique:source-review vuln:dos

**Target:** EVM modexp precompile in rskj node
**Root cause:** The modexp precompile performs expensive big-integer exponentiation on attacker-controlled operand lengths/values without adequate gas scaling, so a small-gas call triggers disproportionate CPU work.
**Steps:**
1. Build rskj with JDK 11 via `./configure.sh`
2. Add PoC test `co.rsk.vm.Poc` that loads crafted bytecode `3332335b...30303030` and steps the VM 250 times with 5M gas
3. Run `./gradlew test --tests co.rsk.vm.Poc.testPoc`; observe OutOfMemoryError at default heap
4. Raise heap to `Xmx10G` in `rskj-core/build.gradle` and rerun
5. Observe execution takes ~8m23s real time for a single test
**How found:** Researcher inspected the modexp precompile implementation and hypothesized that large exponent/modulus operands would cause disproportionate big-integer work relative to gas charged, then built a VM-level PoC to measure wall-clock time.
**Exploitation:** Deploy/craft a smart contract whose bytecode invokes the modexp precompile with operands that maximize computation; submitting it as a transaction causes the node to spend minutes of CPU on one call, stalling block processing.
**Insight:** Precompile gas schedules often under-price big-integer operations; test modexp/ecpairing-style precompiles with maximal operand sizes and measure wall-clock vs gas to find underpriced CPU DoS.
