fix(abstract-eth): verify inner batch calldata recipients [CGD-1319]#8771
Closed
kamleshmugdiya wants to merge 1 commit into
Closed
fix(abstract-eth): verify inner batch calldata recipients [CGD-1319]#8771kamleshmugdiya wants to merge 1 commit into
kamleshmugdiya wants to merge 1 commit into
Conversation
Decode the inner batch(address[],uint256[]) calldata embedded in txPrebuild.txHex and compare each (address, amount) pair to the user-supplied recipients. Without this check, the verifier validated only the outer batcher contract address and the total amount, so a compromised platform could swap inner recipients while preserving the outer wrapper checks and redirect batched payouts. Fails closed when txHex is missing, the outer selector is not sendMultiSig, or the inner selector is not batch(address[],uint256[]). Ticket: CGD-1319
10 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
verifyTransactionfor ETH batcher-contract sends only checked (a) the sum oftxParams.recipientsagainsttxPrebuild.recipients[0].amountand (b) that the outer recipient was the network'sbatcherContractAddress. It never decoded the innerbatch(address[],uint256[])calldata embedded intxPrebuild.txHex, andsignTransactionthen loaded thattxHexverbatim.A compromised BitGo platform could preserve both outer checks while swapping the inner
(address, amount)pairs to attacker-controlled addresses, redirecting batched payouts. This PR decodes the inner calldata during verification and compares each pair to user intent.Issue Number
CGD-1319
Type of change
What changed
modules/abstract-eth/src/lib/walletUtil.ts— exportsbatchMethodId(0xc00c4e9e),batchMethodName,batchMethodTypes.modules/abstract-eth/src/lib/iface.ts— addsBatchTransferData/BatchTransferRecipient.modules/abstract-eth/src/lib/utils.ts— addsdecodeBatchTransferData(), modeled after the existingdecode*TransferDatahelpers and reusinggetRawDecoded/getBufferedByteCode.modules/abstract-eth/src/abstractEthLikeNewCoins.ts— adds privateverifyBatchInnerRecipientswhich parsestxPrebuild.txHex, decodes the outersendMultiSig, decodes the innerbatch(address[],uint256[]), and compares each(address, amount)pair totxParams.recipients. Wired into the existing batch path inverifyTransactionfor native batches.The verifier fails closed when:
txPrebuild.txHexis missingsendMultiSigbatch(address[],uint256[])txParams.recipientsToken-batch (
txParams.tokenName) and TSS paths are out of scope per the issue; the codebase has nosendMultisigBatch-style token wrapper, and the existing token branch already expectstxPrebuild.recipients[0].amount === 0.signTransactionis unchanged — it now safely loadstxHexbecause the verifier proves inner calldata matches user intent first.ENS / non-hex
txParamsaddresses skip the address comparison but still enforce the amount check, mirroring the normal-tx path atabstractEthLikeNewCoins.ts:3340.How Has This Been Tested?
modules/abstract-eth/test/unit/utils.ts— 4 tests fordecodeBatchTransferData: hardcoded selector matches runtime-computed value, round-trip encode/decode, wrong-selector rejection, mismatched-array-length rejection.modules/sdk-coin-eth/test/unit/eth.ts— adds abuildBatchTxHexhelper and 5 newverifyTransactiontests: missingtxHex, tampered inner address, tampered inner amount (with outer total preserved), wrong inner selector, mismatched inner recipient count. Updates the existing happy-path batch test to include a validtxHex.Local runs:
yarn unit-testinmodules/abstract-eth— 77 passingyarn unit-testinmodules/sdk-coin-eth— 237 passingyarn lintin both modules — cleanChecklist: