# Inconsistent fee denomination handling in transaction validation and building

Nibiru EVM used wei-denominated tx fees directly as unibi in validation and tx building, mispricing fees by 10^12.

- Payout: Audit contest
- Severity: medium
- Program: Nibiru
- Found by: 0x41
- Disclosed: 2025-02-24
- Write-up quality: 6/10
- Original: https://github.com/code-423n4/2024-11-nibiru-findings/issues/44
- Library page: https://bugbountylibrary.com/r/c4%3A2024-11-nibiru%3AM-05
- Tags: area:web3 domain:web3 impact:funds-loss kind:contest platform:code4rena sev:medium tech:evm tech:go technique:source-review vuln:accounting-error vuln:fee-bypass

**Target:** Cosmos SDK EVM module fee validation and tx builder (evmante_validate_basic.go, msg.go)
**Root cause:** txData.Fee() returns wei (1e18) but is wrapped directly as an EVMBankDenom (unibi, 1e6) coin without WeiToNative conversion, so fee amounts are off by 10^12.
**Steps:**
1. Read `evmante_validate_basic.go#L128`: `txFee.Add(sdk.Coin{Denom: evm.EVMBankDenom, Amount: sdkmath.NewIntFromBigInt(txData.Fee())})`
2. Read `msg.go#L367`: `fees = append(fees, sdk.NewCoin(evmDenom, feeAmt))` with `feeAmt = txData.Fee()`
3. Confirm `LegacyTx.Fee()` returns `priceTimesGas` in wei
4. Observe gas price 1 wei * 21000 gas = 21000 wei should be 0.000021 unibi but is recorded as 21000 unibi
**How found:** Code review of fee handling paths in the EVM ante handler and tx builder, spotting that Fee() (wei) was used where unibi was expected without conversion.
**Exploitation:** Not demonstrated; developer noted 1 wei gas price is impossible since smallest transferable unit is 10^12 wei (1 unibi), limiting practical underpayment.
**Insight:** When a chain has two denomination scales (wei vs native micro-denom), audit every boundary where an EVM big.Int fee crosses into Cosmos sdk.Coin; check both validation and tx-building paths for missing WeiToNative conversion.

## Proof of concept (copied exactly from the original report)

**Fee validation using wei amount directly**

```
txFee = txFee.Add(
    sdk.Coin{
        Denom:  evm.EVMBankDenom,
        Amount: sdkmath.NewIntFromBigInt(txData.Fee()), // Fee() returns wei amount
    },
)
```

**BuildTx fee using wei amount directly**

```
feeAmt := sdkmath.NewIntFromBigInt(txData.Fee())
if feeAmt.Sign() > 0 {
    fees = append(fees, sdk.NewCoin(evmDenom, feeAmt)) // Fee() returns wei amount
}
```

