From be7524ee5f806b47f8844870ccb3d4b33b00afa3 Mon Sep 17 00:00:00 2001 From: Matthew Slipper Date: Sun, 12 Feb 2023 10:35:56 -0700 Subject: [PATCH] op-chain-ops: Ignore messages from sources other than the L2XDM The `relayMessage` function on the message passer is public. To guard against spoofed withdrawals, we need to check the message's source to ensure that only messages from the L2XDM are included in the withdrawals migration. Fixes CLI-3337 Fixes CLI-3331 --- op-chain-ops/genesis/migration/types.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/op-chain-ops/genesis/migration/types.go b/op-chain-ops/genesis/migration/types.go index cd830403ad56..91b65b3a227c 100644 --- a/op-chain-ops/genesis/migration/types.go +++ b/op-chain-ops/genesis/migration/types.go @@ -5,6 +5,8 @@ import ( "fmt" "os" + "github.com/ethereum-optimism/optimism/op-bindings/predeploys" + "github.com/ethereum-optimism/optimism/op-chain-ops/crossdomain" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" @@ -120,6 +122,9 @@ type MigrationData struct { func (m *MigrationData) ToWithdrawals() ([]*crossdomain.LegacyWithdrawal, error) { messages := make([]*crossdomain.LegacyWithdrawal, 0) for _, msg := range m.OvmMessages { + if msg.Who != predeploys.L2CrossDomainMessengerAddr { + continue + } wd, err := msg.ToLegacyWithdrawal() if err != nil { return nil, err @@ -130,6 +135,9 @@ func (m *MigrationData) ToWithdrawals() ([]*crossdomain.LegacyWithdrawal, error) } } for _, msg := range m.EvmMessages { + if msg.Who != predeploys.L2CrossDomainMessengerAddr { + continue + } wd, err := msg.ToLegacyWithdrawal() if err != nil { return nil, err