# Gas is not consumed when precompile method fail, allowing resource consumption related DOS

Nibiru EVM precompiles returned errors before consuming gas, letting attackers trigger cheap failures that burned node resources and could DoS the chain.

- Payout: Audit contest
- Severity: high
- Program: Nibiru
- Found by: 0x007
- Disclosed: 2025-02-24
- Write-up quality: 7/10
- Original: https://github.com/code-423n4/2024-11-nibiru-findings/issues/25
- Library page: https://bugbountylibrary.com/r/c4%3A2024-11-nibiru%3AH-04
- Tags: area:web3 domain:web3 impact:dos kind:contest platform:code4rena sev:high tech:evm tech:go technique:incomplete-fix technique:source-review vuln:dos

**Target:** EVM precompiles (FunToken, Wasm, Oracle) in Nibiru chain
**Root cause:** Precompile methods return early on error before calling contract.UseGas with the local gas meter's consumed amount, so failed executions don't charge gas.
**Steps:**
1. Deploy a wasm contract whose execute entrypoint consumes gas then reverts (e.g., `WasteGas` returns `Err(StdError::generic_err("arbitrary revert"))`).
2. Deploy an EVM contract that calls `wasm.execute` on that contract up to `maxMultistoreCacheCount` (10) times.
3. Send a tx with a large gas limit calling the EVM contract; the wasm call reverts after consuming gas.
4. Observe the tx consumes far less gas than the wasm execution used, because the precompile returns before `contract.UseGas`.
5. Repeat to fill blocks with cheap failed precompile executions, exhausting node resources.
**How found:** Code review of precompile error paths noticed `return nil, err` precedes `contract.UseGas(...GasConsumed())`, meaning failed calls skip gas accounting; confirmed by building a wasm contract that wastes gas then reverts and comparing gas receipts.
**Exploitation:** Attacker repeatedly invokes a reverting wasm contract via the EVM wasm precompile; each failure consumes wasm execution resources but the precompile returns before charging the local gas meter, so the attacker pays only the small requiredGas, enabling resource exhaustion and potential chain DoS.
**Escalation:** Repeating the cheap failing calls across many transactions can fill block gas limits and degrade or halt the chain.
**Insight:** In EVM precompile wrappers, always charge the local gas meter before returning an error; a revert path that bypasses UseGas lets attackers burn real execution resources for only the fixed requiredGas.

