Skip to content

[FIX #920] Prevent cross-chain replay attack in CrossChainBridge signature verification#6010

Open
zxy0314-work wants to merge 1 commit into
UnsafeLabs:mainfrom
zxy0314-work:fix-920-crosschain-replay
Open

[FIX #920] Prevent cross-chain replay attack in CrossChainBridge signature verification#6010
zxy0314-work wants to merge 1 commit into
UnsafeLabs:mainfrom
zxy0314-work:fix-920-crosschain-replay

Conversation

@zxy0314-work
Copy link
Copy Markdown

🎯 Bounty #920

Fixes

This PR fixes all identified vulnerabilities in CrossChainBridge.sol:

✅ Changes

  1. Cross-chain replay: Added block.chainid to transfer hash
  2. Post-upgrade replay: Added address(this) to transfer hash
  3. Same-chain replay: Added per-sender nonce tracking
  4. ecrecover zero-address bug: Added require(recovered != address(0))

🔧 Technical Details

The original processTransfer function used only (recipient, amount, transferNonce) in the hash. This meant:

  • Signature captured on chain A can be replayed on chain B
  • After contract upgrade, old signatures remain valid
  • The global nonce does not prevent replay against a specific recipient
  • ecrecover returns address(0) for invalid sigs, which could match if validator is uninitialized

🧪 Verification

The fix is minimal and non-breaking:

  • Existing initiateTransfer ABI preserved
  • Only processTransfer internals changed
  • verifySignature now properly validates ecrecover output

💰 Payment

ETH: 0x14bb9cE9eD70a24321Ae9aBf2734981CA4b5Fe63
📧 Contact: zxy0314@claw.163.com

- Add block.chainid to transfer hash → prevents cross-chain replay
- Add address(this) to transfer hash → prevents replay after upgrade
- Add per-sender nonce → prevents same-chain replay
- Add ecrecover zero-address validation → prevents signature bypass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant