# Unlimited Nibi could be minted because evm and bank balance are not synced when staking

NibiruBankKeeper skips StateDB sync on staking delegate/undelegate, letting an EVM contract mint unlimited Nibi by desyncing EVM balance from bank balance.

- Payout: Audit contest
- Severity: high
- Program: Nibiru
- Found by: 0x007
- Disclosed: 2025-02-24
- Write-up quality: 8/10
- Original: https://github.com/code-423n4/2024-11-nibiru-findings/issues/26
- Library page: https://bugbountylibrary.com/r/c4%3A2024-11-nibiru%3AH-03
- Tags: area:web3 domain:web3 impact:funds-loss kind:contest platform:code4rena sev:high tech:evm tech:solidity technique:chained technique:source-review vuln:accounting-error vuln:business-logic

**Target:** Cosmos SDK bank keeper / EVM StateDB balance sync (bank_extension.go)
**Root cause:** SyncStateDBWithAccount is only called from some bank balance mutators; DelegateCoins/UndelegateCoins/InputOutputCoins change bank balances without updating the EVM StateDB, so StateDB holds a stale higher balance.
**Steps:**
1. Deploy a Wasm contract that performs staking delegate/undelegate and fund it with X Nibi.
2. Deploy an EVM contract that calls the Wasm precompile `execute` to reach the Wasm contract.
3. Send a dust transfer to the Wasm account so it is loaded into StateDB stateObjects with balance X.
4. Via EVM, instruct the Wasm contract to delegate Y Nibi; bank balance drops to X-Y but StateDB still shows X.
5. Trigger SetAccBalance, which mints Y to reconcile StateDB back to X.
6. Undelegate the Y Nibi to recover it, or repeat to inflate supply and take over the chain.
**How found:** Auditor enumerated every caller of bankKeeper.setBalance and cross-referenced which paths invoke SyncStateDBWithAccount, spotting DelegateCoins/UndelegateCoins/InputOutputCoins as unsynced; then traced reachability from EVM through the Wasm precompile to stakingMsgServer.
**Exploitation:** Attacker uses EVM->Wasm precompile->stakingMsgServer->DelegateCoins path to reduce bank balance without StateDB sync, then forces SetAccBalance to mint the difference; repeated cycles mint arbitrary Nibi and can capture chain consensus.
**Escalation:** Repeat the mint cycle to accumulate unlimited Nibi and potentially take over the chain via staking weight.
**Insight:** When a chain bridges two balance ledgers (Cosmos bank vs EVM StateDB), enumerate every mutation path of the underlying setBalance and check each for the sync hook; staking and multisend paths are commonly missed.

