AddToInTxTracker doens’t allow permissionless tx validation for Bitcoin chain, InTxTracker permissionless tx validation for Bitcoin chain will always fail
The AddToInTxTracker function only handles EVM chains and returns an error for Bitcoin, so permissionless inbound transaction validation for Bitcoin always fails. An attacker cannot exploit this, but legitimate users are blocked from using the permissionless flow for Bitcoin.
Permissionless tx validation for EVM and Bitcoin chain should be supported based on audit doc→ The system is currently implemented for Ethereum/BSC and Bitcoin. However, currently permissionless tx validation for EVM and Bitcoin chain are only supported in AddToOutTxTracker, but not supported in AddToInTxTracker. Permissionless validation for InTx for bitcoin chain will always fail.
Proof of Concept
In AddToInTxTracker() from msgserveraddtointx_tracker.go, chain is incorrectly diverted. The bitcoin chain is missing and will return an error.
//x/crosschain/keeper/msg_server_add_to_intx_tracker.go
func (k msgServer) AddToInTxTracker(goCtx context.Context, msg *types.MsgAddToInTxTracker) (*types.MsgAddToInTxTrackerResponse, error) {
...
if common.IsEVMChain(msg.ChainId) {
err = k.VerifyEVMInTxBody(ctx, msg, txBytes)
if err != nil {
return nil, types.ErrTxBodyVerificationFail.Wrapf(err.Error())
}
} else {
//@audit when ChainId is bitCoin chain, this will return an error
|> return nil, types.ErrTxBodyVerificationFail.Wrapf(fmt.Sprintf("cannot verify inTx body for chain %d", msg.ChainId))
}
(1) According to doc, both AddToInTxTracker and AddToOutTxTracker are supported for permissionless validation and both should support bitcoin chain and EVM chain. So IMO, the lookout’s quote supports the validity of this report.
An inbound/outbound tx can be sent by anyone with a proof. The proof is checked against the header of the chain to validate it → The system is currently only used to validate txs to be added in the tracker through MsgAddToInTxTracker and MsgAddToOutTxTracker and not to validate txs to be observed as part of the ZetaChain cross-chain tx workflow → The system is currently implemented for Ethereum/BSC and Bitcoin
Note that this issue concerns only MsgAddToInTxTracker and MsgAddToOutTxTracker, and doens’t concern validate txs to be observed as part of the ZetaChain cross-chain tx workflow. The latter is part of keeper -> voteinboundtx / voteoutboundtx flow, which is irrelevant to this discussion.
(2)This report argues that AddToInTxTracker() is flawed because it currently will revert when the chain is Bitcoin. For reference, AddToOutTxTracker() currently correctly supports both Bitcoin chain and EVM chain. This means AddToInTxTracker() needs to be fixed to support both chains.
a) AddToInTxTracker() : This reverts when the chain is Bitcoin
//x/crosschain/keeper/msg_server_add_to_intx_tracker.go
func (k msgServer) AddToInTxTracker(goCtx context.Context, msg *types.MsgAddToInTxTracker) (*types.MsgAddToInTxTrackerResponse, error) {
...
if common.IsEVMChain(msg.ChainId) {
err = k.VerifyEVMInTxBody(ctx, msg, txBytes)
...
} else {
//@audit when ChainId is bitCoin chain, this will return an error
|> return nil, types.ErrTxBodyVerificationFail.Wrapf(fmt.Sprintf("cannot verify inTx body for chain %d", msg.ChainId))
}
@oakcobalt - Thanks for raising this. I agree it’s not handled correctly for BTC on the input flow AND it does state that it should in the audit docs. There is of course a work around (using the permissioned flow). That being said since the sponsor call out this new flow as being important, I think it probably warrants M. Lets get @lumtis to provide an opinion here on severity before we finalize it all.
The original report as published on Code4rena, by oakcobalt. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
Generating the AI write-up for this report.
This usually takes about 30 seconds. You can read the original meanwhile; this page updates itself.
Writing the technical write-up
Writing the version for beginners
Checking every passage against the original
How it worked
Root cause
The AddToInTxTracker function checks only for EVM chains and lacks a branch for Bitcoin, unlike AddToOutTxTracker which handles both.
Impact
Permissionless inbound transaction validation for Bitcoin always fails, though a permissioned flow exists as a workaround.
What the attacker needed
None
The fix
Add a check for Bitcoin chain IDs in AddToInTxTracker so that Bitcoin transactions are verified correctly.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
Generating the AI write-up for this report.
This usually takes about 30 seconds. You can read the original meanwhile; this page updates itself.
Writing the technical write-up
Writing the version for beginners
Checking every passage against the original
This is a bug in a blockchain bridge's code. The function that lets anyone submit proof of an incoming Bitcoin transaction only knows how to check Ethereum-style chains, so it rejects every Bitcoin transaction. As a result, a feature that is supposed to work without special permissions simply does not work for Bitcoin.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.