Repository navigation
Description
Summary
V2 inbound parsing in x/crosschain/types/inbound_parsing.go does not carry event.gasFee or event.protocolFlatFee from Withdrawn / WithdrawnAndCalled into MsgVoteInbound. CCTXGatewayObservers.InitiateOutbound recomputes UserGasFeePaid from the node-side median gas price (x/crosschain/keeper/cctx_gateway_observers.go:77) instead of trusting the amount the contract actually burned.
In production the two bases stay matched. MsgVoteGasPrice writes the crosschain-keeper store and the SystemContract gasPriceByChainId inside a single message handler (x/crosschain/keeper/msg_server_vote_gas_price.go:91-104), so any gateway.withdraw() within a block reads consistent values on both sides. Under matching prices the node value is gasPrice * gasLimit while the contract burns gasPrice * gasLimit + PROTOCOL_FLAT_FEE, so UserGasFeePaid is always <= the user-paid amount and refunds cannot exceed what was paid. Reported as HackenProof ZCNode-254 (report).
This issue tracks the defense-in-depth fix: persist the event-paid gasFee on the CCTX and clamp refundable gas-token credit at min(UserGasFeePaid, event.GasFee). Makes the protocol resilient against any future code path that updates the SystemContract independently of the node-side median.
Branch impact
release/v36(mainnet): not affected. The refund path (feat: refund a portion of remaining unused tokens to user #3734) is not deployed there.release/zetacore/v37(testnet): same accounting model as main. Same atomic gas-price update protects against the PoC's divergence today. Defense-in-depth fix still worth applying.main: same as v37.
Suggested fix
- Add optional
event_gas_fee/event_protocol_flat_feefields toMsgVoteInbound(treated as absent on legacy CCTXs). - Carry the values from the parsed event in
NewWithdrawalInboundandNewWithdrawAndCallInbound(x/crosschain/types/inbound_parsing.go:99-148, 203-249).Calleddoes not carry agasFeefield, so this only applies to withdrawal flows. - Persist on
OutboundParamsand use as a hard cap inrefundUnusedGas(x/crosschain/keeper/msg_server_vote_outbound.go:144-251):usableRemainingFees = 95% * (min(UserGasFeePaid, EventGasFee) - outboundTxFeePaid).
Optional field, no state migration needed.
Related
- Sui inbound observer rejects valid Gateway events with EventIndex != 0 and advances cursor past them #4584 (or whichever issue tracks ZCNode-221) — the mid-flight repricing accounting gap covers the only realistic over-credit path today, and the fix there (track stability-pool contributions on the CCTX) addresses the same end state. Apply this issue's clamp on top of that fix.
- HackenProof ZCNode-254
Activity
kingpinXD commentedon May 25, 2026
HackenProof ZCNode-274 also reports this same root issue, framed from the refund side. The reporter traces the recomputed
UserGasFeePaidintorefundUnusedGas(x/crosschain/keeper/msg_server_vote_outbound.go:174-251) and observes that the resulting mint into the gas stability pool (and optionally the user wallet atStabilityPoolPercentage < 100) is not capped against the Gateway-burnedgasfee.Same in-production safety guarantee (atomic
voteGasPricewrites keep the node-side median and SystemContractgasPriceByChainIdmatched atInitiateOutboundtime, since the V2 inbound is processed synchronously inside the EVM tx that emits the event). Same defense-in-depth fix scope as outlined above — onceevent_gas_feeis persisted on the CCTX, clamp refunds atmin(UserGasFeePaid, event.GasFee)covers both the original ZCNode-254 inbound-side framing and the ZCNode-274 refund-side framing.Marked as duplicate on HackenProof (
dup-254label, stateDuplicate).hackeproof/analysis/blockchain/report_ZCNode-274.md