fix: cosmwasm evm query path repeatable undercharged evm exec#345
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
✅ Files skipped from review due to trivial changes (1)
WalkthroughThe PR updates ERC20-related EVM query handlers to use a shared helper that passes a gas cap into internal ABI calls and charges additional SDK gas based on actual EVM work. It adds a changelog note for the fix. The test workflow also adds a wasmbinding-specific coverage run and uploads its profile to Codecov. Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Description
Fixes a gas-accounting vulnerability in the CosmWasm→EVM query bridge
(
wasmbinding/evm/queries.go). Any CosmWasm contract could call the ERC20information/balance/allowance queries against an arbitrary EVM contract, and each
sub-call was issued with
gasCap=nil. The underlying EVM helper ignores a nil capand falls back to
DefaultGasCap(25M), so an attacker-controlled ERC20 could forcelarge, repeatable internal EVM execution while the SDK gas meter was charged only the
post-refund amount — enabling sustained, undercharged validator compute.
This PR makes every internal ERC20 query sub-call pass a real gas cap bounded by the
transaction's remaining SDK gas (and
DefaultGasCap), mirroring the existingbuildEthCallRequestbehaviour used by the genericEthCallpath.Changes:
queryGasCap(ctx)helper returningmin(ctx.GasMeter().GasRemaining(), DefaultGasCap).queryGasCap(ctx)instead ofnilto all six sub-calls:decimals,name,symbol,totalSupply,balanceOf,allowance.Dependencies: full mitigation also relies on the companion
KiiChain/evmPR(
fix/wasm-repeatable-undercharged-internal-evm-exec) whereCallEVMWithDatanowhonours the gas cap and bills the SDK meter for actual pre-refund EVM work. That fork
version must be published and the
replace github.com/cosmos/evm => github.com/KiiChain/evmdirective in
go.modbumped for the fix to take full effect on-chain.Type of change
How Has This Been Tested?
go test -tags=test ./wasmbinding/evm/...— all query binding tests pass (incl. ERC20 information/balance/allowance and EthCall gas tests).go build ./wasmbinding/...— compiles cleanly.PR Checklist:
make lint-fix(golangci-lint v2.7.2, 0 issues)