CVE-2023-35163 (published 2023-06-23T21:15Z)

Vega is a decentralized trading platform that allows pseudo-anonymous trading of derivatives on a blockchain. Prior to version 0.71.6, a vulnerability exists that allows a malicious validator to trick the Vega network into re-processing past Ethereum events from Vega’s Ethereum bridge. For example, a deposit to the collateral bridge for 100USDT that credits a party’s general account on Vega, can be re-processed 50 times resulting in 5000USDT in that party’s general account. This is without depositing any more than the original 100USDT on the bridge. Despite this exploit requiring access to a validator's Vega key, a validator key can be obtained at the small cost of 3000VEGA, the amount needed to announce a new node onto the network.\n\nA patch is available in version 0.71.6. No known workarounds are available, however there are mitigations in place should this vulnerability be exploited. There are monitoring alerts for `mainnet1` in place to identify any issues of this nature including this vulnerability being exploited. The validators have the ability to stop the bridge thus stopping any withdrawals should this vulnerability be exploited.

CVSS v3 base score: 5.2, MEDIUM (CVSS:3.1/AV:P/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:L)

Weakness information:
cwe_id: CWE-20
cwe_name: Improper Input Validation
description: The product receives input or data, but it does
        not validate or incorrectly validates that the input has the
        properties that are required to process the data safely and
        correctly.
extended_description: 
	   Input validation is a frequently-used technique
	   for checking potentially dangerous inputs in order to
	   ensure that the inputs are safe for processing within the
	   code, or when communicating with other components.  When
	   software does not validate input properly, an attacker is
	   able to craft the input in a form that is not expected by
	   the rest of the application. This will lead to parts of the
	   system receiving unintended input, which may result in
	   altered control flow, arbitrary control of a resource, or
	   arbitrary code execution.
	   Input validation is not the only technique for
	   processing input, however.  Other techniques attempt to
	   transform potentially-dangerous input into something safe, such
	   as filtering (CWE-790) - which attempts to remove dangerous
	   inputs - or encoding/escaping (CWE-116), which attempts to
	   ensure that the input is not misinterpreted when it is included
	   in output to another component. Other techniques exist as well
	   (see CWE-138 for more examples.)
	   Input validation can be applied to:
	   
	     raw data - strings, numbers, parameters, file contents, etc.
	     metadata - information about the raw data, such as headers or size
	   
	   Data can be simple or structured.  Structured data
	   can be composed of many nested layers, composed of
	   combinations of metadata and raw data, with other simple or
	   structured data.
	   Many properties of raw data or metadata may need
	   to be validated upon entry into the code, such
	   as:
	   
	     specified quantities such as size, length, frequency, price, rate, number of operations, time, etc.
	     implied or derived quantities, such as the actual size of a file instead of a specified size
	     indexes, offsets, or positions into more complex data structures
	     symbolic keys or other elements into hash tables, associative arrays, etc.
	     well-formedness, i.e. syntactic correctness - compliance with expected syntax 
	     lexical token correctness - compliance with rules for what is treated as a token
	     specified or derived type - the actual type of the input (or what the input appears to be)
	     consistency - between individual data elements, between raw data and metadata, between references, etc.
	     conformance to domain-specific rules, e.g. business logic 
	     equivalence - ensuring that equivalent inputs are treated the same
	     authenticity, ownership, or other attestations about the input, e.g. a cryptographic signature to prove the source of the data
	   
	   Implied or derived properties of data must often
	   be calculated or inferred by the code itself.  Errors in
	   deriving properties may be considered a contributing factor
	   to improper input validation.
	   
	   Note that "input validation" has very different
	   meanings to different people, or within different
	   classification schemes.  Caution must be used when
	   referencing this CWE entry or mapping to it.  For example,
	   some weaknesses might involve inadvertently giving control
	   to an attacker over an input when they should not be able
	   to provide an input at all, but sometimes this is referred
	   to as input validation.
	   Finally, it is important to emphasize that the
	   distinctions between input validation and output escaping
	   are often blurred, and developers must be careful to
	   understand the difference, including how input validation
	   is not always sufficient to prevent vulnerabilities,
	   especially when less stringent data types must be
	   supported, such as free-form text. Consider a SQL injection
	   scenario in which a person's last name is inserted into a
	   query. The name "O'Reilly" would likely pass the validation
	   step since it is a common last name in the English
	   language. However, this valid name cannot be directly
	   inserted into the database because it contains the "'"
	   apostrophe character, which would need to be escaped or
	   otherwise transformed. In this case, removing the
	   apostrophe might reduce the risk of SQL injection, but it
	   would produce incorrect behavior because the wrong name
	   would be recorded.
       
         

Fix information:
repo_url: https://github.com/vegaprotocol/vega
commit_details: repo_url: https://github.com/vegaprotocol/vega
author: Jeremy Letang
author_date: 2023-06-20 10:21:26+01:00
msg: Merge pull request from GHSA-8rc9-vxjh-qjf2

fix: on-chain verification comparison
repository: repo_url: https://github.com/vegaprotocol/vega
repo_name: vegaprotocol/vega
description: A Go implementation of the Vega Protocol, a protocol for creating and trading derivatives on a fully decentralised network.
repo_language: Go
owner: vegaprotocol
file_changes: filename: asset_action.go
change_type: ModificationType.MODIFY
diff: @@ -154,29 +154,29 @@ func (t *assetAction) checkBuiltinAssetDeposit() error {
 
 func (t *assetAction) checkERC20BridgeStopped() error {
 	return t.bridgeView.FindBridgeStopped(
-		t.erc20BridgeStopped, t.blockHeight, t.logIndex)
+		t.erc20BridgeStopped, t.blockHeight, t.logIndex, t.txHash)
 }
 
 func (t *assetAction) checkERC20BridgeResumed() error {
 	return t.bridgeView.FindBridgeResumed(
-		t.erc20BridgeResumed, t.blockHeight, t.logIndex)
+		t.erc20BridgeResumed, t.blockHeight, t.logIndex, t.txHash)
 }
 
 func (t *assetAction) checkERC20Deposit() error {
 	asset, _ := t.asset.ERC20()
 	return t.bridgeView.FindDeposit(
-		t.erc20D, t.blockHeight, t.logIndex, asset.Address(),
+		t.erc20D, t.blockHeight, t.logIndex, asset.Address(), t.txHash,
 	)
 }
 
 func (t *assetAction) checkERC20AssetList() error {
-	return t.bridgeView.FindAssetList(t.erc20AL, t.blockHeight, t.logIndex)
+	return t.bridgeView.FindAssetList(t.erc20AL, t.blockHeight, t.logIndex, t.txHash)
 }
 
 func (t *assetAction) checkERC20AssetLimitsUpdated() error {
 	asset, _ := t.asset.ERC20()
 	return t.bridgeView.FindAssetLimitsUpdated(
-		t.erc20AssetLimitsUpdated, t.blockHeight, t.logIndex, asset.Address(),
+		t.erc20AssetLimitsUpdated, t.blockHeight, t.logIndex, asset.Address(), t.txHash,
 	)
 }
 

programming_language: Go
filename: erc20.go
change_type: ModificationType.MODIFY
diff: @@ -34,11 +34,11 @@ var (
 )
 
 type ERC20BridgeView interface {
-	FindAssetList(al *types.ERC20AssetList, blockNumber, logIndex uint64) error
-	FindBridgeStopped(al *types.ERC20EventBridgeStopped, blockNumber, logIndex uint64) error
-	FindBridgeResumed(al *types.ERC20EventBridgeResumed, blockNumber, logIndex uint64) error
-	FindDeposit(d *types.ERC20Deposit, blockNumber, logIndex uint64, ethAssetAddress string) error
-	FindAssetLimitsUpdated(update *types.ERC20AssetLimitsUpdated, blockNumber uint64, logIndex uint64, ethAssetAddress string) error
+	FindAssetList(al *types.ERC20AssetList, blockNumber, logIndex uint64, txHash string) error
+	FindBridgeStopped(al *types.ERC20EventBridgeStopped, blockNumber, logIndex uint64, txHash string) error
+	FindBridgeResumed(al *types.ERC20EventBridgeResumed, blockNumber, logIndex uint64, txHash string) error
+	FindDeposit(d *types.ERC20Deposit, blockNumber, logIndex uint64, ethAssetAddress string, txHash string) error
+	FindAssetLimitsUpdated(update *types.ERC20AssetLimitsUpdated, blockNumber uint64, logIndex uint64, ethAssetAddress string, txHash string) error
 }
 
 func (e *Engine) EnableERC20(

programming_language: Go
filename: mocks.go
change_type: ModificationType.MODIFY
diff: @@ -504,73 +504,73 @@ func (m *MockERC20BridgeView) EXPECT() *MockERC20BridgeViewMockRecorder {
 }
 
 // FindAssetLimitsUpdated mocks base method.
-func (m *MockERC20BridgeView) FindAssetLimitsUpdated(arg0 *types.ERC20AssetLimitsUpdated, arg1, arg2 uint64, arg3 string) error {
+func (m *MockERC20BridgeView) FindAssetLimitsUpdated(arg0 *types.ERC20AssetLimitsUpdated, arg1, arg2 uint64, arg3, arg4 string) error {
 	m.ctrl.T.Helper()
-	ret := m.ctrl.Call(m, "FindAssetLimitsUpdated", arg0, arg1, arg2, arg3)
+	ret := m.ctrl.Call(m, "FindAssetLimitsUpdated", arg0, arg1, arg2, arg3, arg4)
 	ret0, _ := ret[0].(error)
 	return ret0
 }
 
 // FindAssetLimitsUpdated indicates an expected call of FindAssetLimitsUpdated.
-func (mr *MockERC20BridgeViewMockRecorder) FindAssetLimitsUpdated(arg0, arg1, arg2, arg3 interface{}) *gomock.Call {
+func (mr *MockERC20BridgeViewMockRecorder) FindAssetLimitsUpdated(arg0, arg1, arg2, arg3, arg4 interface{}) *gomock.Call {
 	mr.mock.ctrl.T.Helper()
-	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FindAssetLimitsUpdated", reflect.TypeOf((*MockERC20BridgeView)(nil).FindAssetLimitsUpdated), arg0, arg1, arg2, arg3)
+	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FindAssetLimitsUpdated", reflect.TypeOf((*MockERC20BridgeView)(nil).FindAssetLimitsUpdated), arg0, arg1, arg2, arg3, arg4)
 }
 
 // FindAssetList mocks base method.
-func (m *MockERC20BridgeView) FindAssetList(arg0 *types.ERC20AssetList, arg1, arg2 uint64) error {
+func (m *MockERC20BridgeView) FindAssetList(arg0 *types.ERC20AssetList, arg1, arg2 uint64, arg3 string) error {
 	m.ctrl.T.Helper()
-	ret := m.ctrl.Call(m, "FindAssetList", arg0, arg1, arg2)
+	ret := m.ctrl.Call(m, "FindAssetList", arg0, arg1, arg2, arg3)
 	ret0, _ := ret[0].(error)
 	return ret0
 }
 
 // FindAssetList indicates an expected call of FindAssetList.
-func (mr *MockERC20BridgeViewMockRecorder) FindAssetList(arg0, arg1, arg2 interface{}) *gomock.Call {
+func (mr *MockERC20BridgeViewMockRecorder) FindAssetList(arg0, arg1, arg2, arg3 interface{}) *gomock.Call {
 	mr.mock.ctrl.T.Helper()
-	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FindAssetList", reflect.TypeOf((*MockERC20BridgeView)(nil).FindAssetList), arg0, arg1, arg2)
+	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FindAssetList", reflect.TypeOf((*MockERC20BridgeView)(nil).FindAssetList), arg0, arg1, arg2, arg3)
 }
 
 // FindBridgeResumed mocks base method.
-func (m *MockERC20BridgeView) FindBridgeResumed(arg0 *types.ERC20EventBridgeResumed, arg1, arg2 uint64) error {
+func (m *MockERC20BridgeView) FindBridgeResumed(arg0 *types.ERC20EventBridgeResumed, arg1, arg2 uint64, arg3 string) error {
 	m.ctrl.T.Helper()
-	ret := m.ctrl.Call(m, "FindBridgeResumed", arg0, arg1, arg2)
+	ret := m.ctrl.Call(m, "FindBridgeResumed", arg0, arg1, arg2, arg3)
 	ret0, _ := ret[0].(error)
 	return ret0
 }
 
 // FindBridgeResumed indicates an expected call of FindBridgeResumed.
-func (mr *MockERC20BridgeViewMockRecorder) FindBridgeResumed(arg0, arg1, arg2 interface{}) *gomock.Call {
+func (mr *MockERC20BridgeViewMockRecorder) FindBridgeResumed(arg0, arg1, arg2, arg3 interface{}) *gomock.Call {
 	mr.mock.ctrl.T.Helper()
-	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FindBridgeResumed", reflect.TypeOf((*MockERC20BridgeView)(nil).FindBridgeResumed), arg0, arg1, arg2)
+	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FindBridgeResumed", reflect.TypeOf((*MockERC20BridgeView)(nil).FindBridgeResumed), arg0, arg1, arg2, arg3)
 }
 
 // FindBridgeStopped mocks base method.
-func (m *MockERC20BridgeView) FindBridgeStopped(arg0 *types.ERC20EventBridgeStopped, arg1, arg2 uint64) error {
+func (m *MockERC20BridgeView) FindBridgeStopped(arg0 *types.ERC20EventBridgeStopped, arg1, arg2 uint64, arg3 string) error {
 	m.ctrl.T.Helper()
-	ret := m.ctrl.Call(m, "FindBridgeStopped", arg0, arg1, arg2)
+	ret := m.ctrl.Call(m, "FindBridgeStopped", arg0, arg1, arg2, arg3)
 	ret0, _ := ret[0].(error)
 	return ret0
 }
 
 // FindBridgeStopped indicates an expected call of FindBridgeStopped.
-func (mr *MockERC20BridgeViewMockRecorder) FindBridgeStopped(arg0, arg1, arg2 interface{}) *gomock.Call {
+func (mr *MockERC20BridgeViewMockRecorder) FindBridgeStopped(arg0, arg1, arg2, arg3 interface{}) *gomock.Call {
 	mr.mock.ctrl.T.Helper()
-	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FindBridgeStopped", reflect.TypeOf((*MockERC20BridgeView)(nil).FindBridgeStopped), arg0, arg1, arg2)
+	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FindBridgeStopped", reflect.TypeOf((*MockERC20BridgeView)(nil).FindBridgeStopped), arg0, arg1, arg2, arg3)
 }
 
 // FindDeposit mocks base method.
-func (m *MockERC20BridgeView) FindDeposit(arg0 *types.ERC20Deposit, arg1, arg2 uint64, arg3 string) error {
+func (m *MockERC20BridgeView) FindDeposit(arg0 *types.ERC20Deposit, arg1, arg2 uint64, arg3, arg4 string) error {
 	m.ctrl.T.Helper()
-	ret := m.ctrl.Call(m, "FindDeposit", arg0, arg1, arg2, arg3)
+	ret := m.ctrl.Call(m, "FindDeposit", arg0, arg1, arg2, arg3, arg4)
 	ret0, _ := ret[0].(error)
 	return ret0
 }
 
 // FindDeposit indicates an expected call of FindDeposit.
-func (mr *MockERC20BridgeViewMockRecorder) FindDeposit(arg0, arg1, arg2, arg3 interface{}) *gomock.Call {
+func (mr *MockERC20BridgeViewMockRecorder) FindDeposit(arg0, arg1, arg2, arg3, arg4 interface{}) *gomock.Call {
 	mr.mock.ctrl.T.Helper()
-	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FindDeposit", reflect.TypeOf((*MockERC20BridgeView)(nil).FindDeposit), arg0, arg1, arg2, arg3)
+	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FindDeposit", reflect.TypeOf((*MockERC20BridgeView)(nil).FindDeposit), arg0, arg1, arg2, arg3, arg4)
 }
 
 // MockEthereumEventSource is a mock of EthereumEventSource interface.

programming_language: Go
filename: erc20_logic_view.go
change_type: ModificationType.MODIFY
diff: @@ -111,6 +111,7 @@ func (e *ERC20LogicView) FindAssetList(
 	al *types.ERC20AssetList,
 	blockNumber,
 	logIndex uint64,
+	txHash string,
 ) error {
 	bf, err := bridgecontract.NewErc20BridgeLogicRestrictedFilterer(
 		e.clt.CollateralBridgeAddress(), e.clt)
@@ -145,7 +146,8 @@ func (e *ERC20LogicView) FindAssetList(
 	for iter.Next() {
 		if hex.EncodeToString(iter.Event.VegaAssetId[:]) == assetID &&
 			iter.Event.Raw.BlockNumber == blockNumber &&
-			uint64(iter.Event.Raw.Index) == logIndex {
+			uint64(iter.Event.Raw.Index) == logIndex &&
+			iter.Event.Raw.TxHash.Hex() == txHash {
 			event = iter.Event
 
 			break
@@ -170,6 +172,7 @@ func (e *ERC20LogicView) FindBridgeStopped(
 	al *types.ERC20EventBridgeStopped,
 	blockNumber,
 	logIndex uint64,
+	txHash string,
 ) error {
 	bf, err := bridgecontract.NewErc20BridgeLogicRestrictedFilterer(
 		e.clt.CollateralBridgeAddress(), e.clt)
@@ -200,7 +203,8 @@ func (e *ERC20LogicView) FindBridgeStopped(
 
 	for iter.Next() {
 		if iter.Event.Raw.BlockNumber == blockNumber &&
-			uint64(iter.Event.Raw.Index) == logIndex {
+			uint64(iter.Event.Raw.Index) == logIndex &&
+			iter.Event.Raw.TxHash.Hex() == txHash {
 			event = iter.Event
 
 			break
@@ -225,6 +229,7 @@ func (e *ERC20LogicView) FindBridgeResumed(
 	al *types.ERC20EventBridgeResumed,
 	blockNumber,
 	logIndex uint64,
+	txHash string,
 ) error {
 	bf, err := bridgecontract.NewErc20BridgeLogicRestrictedFilterer(
 		e.clt.CollateralBridgeAddress(), e.clt)
@@ -255,7 +260,8 @@ func (e *ERC20LogicView) FindBridgeResumed(
 
 	for iter.Next() {
 		if iter.Event.Raw.BlockNumber == blockNumber &&
-			uint64(iter.Event.Raw.Index) == logIndex {
+			uint64(iter.Event.Raw.Index) == logIndex &&
+			iter.Event.Raw.TxHash.Hex() == txHash {
 			event = iter.Event
 
 			break
@@ -278,6 +284,7 @@ func (e *ERC20LogicView) FindDeposit(
 	d *types.ERC20Deposit,
 	blockNumber, logIndex uint64,
 	ethAssetAddress string,
+	txHash string,
 ) error {
 	bf, err := bridgecontract.NewErc20BridgeLogicRestrictedFilterer(
 		e.clt.CollateralBridgeAddress(), e.clt)
@@ -315,7 +322,8 @@ func (e *ERC20LogicView) FindDeposit(
 		if hex.EncodeToString(iter.Event.VegaPublicKey[:]) == targetPartyID &&
 			iter.Event.Amount.Cmp(depamount) == 0 &&
 			iter.Event.Raw.BlockNumber == blockNumber &&
-			uint64(iter.Event.Raw.Index) == logIndex {
+			uint64(iter.Event.Raw.Index) == logIndex &&
+			iter.Event.Raw.TxHash.Hex() == txHash {
 			event = iter.Event
 			break
 		}
@@ -337,6 +345,7 @@ func (e *ERC20LogicView) FindWithdrawal(
 	w *types.ERC20Withdrawal,
 	blockNumber, logIndex uint64,
 	ethAssetAddress string,
+	txHash string,
 ) (*big.Int, string, uint, error) {
 	bf, err := bridgecontract.NewErc20BridgeLogicRestrictedFilterer(
 		e.clt.CollateralBridgeAddress(), e.clt)
@@ -376,7 +385,8 @@ func (e *ERC20LogicView) FindWithdrawal(
 	for iter.Next() {
 		if nonce.Cmp(iter.Event.Nonce) == 0 &&
 			iter.Event.Raw.BlockNumber == blockNumber &&
-			uint64(iter.Event.Raw.Index) == logIndex {
+			uint64(iter.Event.Raw.Index) == logIndex &&
+			iter.Event.Raw.TxHash.Hex() == txHash {
 			event = iter.Event
 
 			break
@@ -399,6 +409,7 @@ func (e *ERC20LogicView) FindAssetLimitsUpdated(
 	update *types.ERC20AssetLimitsUpdated,
 	blockNumber uint64, logIndex uint64,
 	ethAssetAddress string,
+	txHash string,
 ) error {
 	bf, err := bridgecontract.NewErc20BridgeLogicRestrictedFilterer(
 		e.clt.CollateralBridgeAddress(), e.clt)
@@ -434,7 +445,8 @@ func (e *ERC20LogicView) FindAssetLimitsUpdated(
 		if update.LifetimeLimits.EQ(eventLifetimeLimit) &&
 			update.WithdrawThreshold.EQ(eventWithdrawThreshold) &&
 			iter.Event.Raw.BlockNumber == blockNumber &&
-			uint64(iter.Event.Raw.Index) == logIndex {
+			uint64(iter.Event.Raw.Index) == logIndex &&
+			iter.Event.Raw.TxHash.Hex() == txHash {
 			event = iter.Event
 			break
 		}

programming_language: Go
filename: bridge_view_stub.go
change_type: ModificationType.MODIFY
diff: @@ -22,22 +22,22 @@ func NewBridgeViewStub() *BridgeViewStub {
 	return &BridgeViewStub{}
 }
 
-func (*BridgeViewStub) FindAssetList(al *types.ERC20AssetList, blockNumber, logIndex uint64) error {
+func (*BridgeViewStub) FindAssetList(al *types.ERC20AssetList, blockNumber, logIndex uint64, txHash string) error {
 	return nil
 }
 
-func (*BridgeViewStub) FindBridgeStopped(al *types.ERC20EventBridgeStopped, blockNumber, logIndex uint64) error {
+func (*BridgeViewStub) FindBridgeStopped(al *types.ERC20EventBridgeStopped, blockNumber, logIndex uint64, txHash string) error {
 	return nil
 }
 
-func (*BridgeViewStub) FindBridgeResumed(al *types.ERC20EventBridgeResumed, blockNumber, logIndex uint64) error {
+func (*BridgeViewStub) FindBridgeResumed(al *types.ERC20EventBridgeResumed, blockNumber, logIndex uint64, txHash string) error {
 	return nil
 }
 
-func (*BridgeViewStub) FindDeposit(d *types.ERC20Deposit, blockNumber, logIndex uint64, ethAssetAddress string) error {
+func (*BridgeViewStub) FindDeposit(d *types.ERC20Deposit, blockNumber, logIndex uint64, ethAssetAddress string, txHash string) error {
 	return nil
 }
 
-func (*BridgeViewStub) FindAssetLimitsUpdated(w *types.ERC20AssetLimitsUpdated, blockNumber, logIndex uint64, ethAssetAddress string) error {
+func (*BridgeViewStub) FindAssetLimitsUpdated(w *types.ERC20AssetLimitsUpdated, blockNumber, logIndex uint64, ethAssetAddress string, txHash string) error {
 	return nil
 }

programming_language: Go
filename: on_chain_verifier.go
change_type: ModificationType.MODIFY
diff: @@ -138,7 +138,8 @@ func (o *OnChainVerifier) CheckStakeDeposited(
 			if hex.EncodeToString(iter.Event.VegaPublicKey[:]) == vegaPubKey &&
 				iter.Event.Amount.Cmp(amountDeposited) == 0 &&
 				iter.Event.Raw.BlockNumber == event.BlockNumber &&
-				uint64(iter.Event.Raw.Index) == event.LogIndex {
+				uint64(iter.Event.Raw.Index) == event.LogIndex &&
+				iter.Event.Raw.TxHash.Hex() == event.TxID {
 				// now we know the event is OK,
 				// just need to check for confirmations
 				return o.ethConfirmations.Check(event.BlockNumber)
@@ -216,7 +217,8 @@ func (o *OnChainVerifier) CheckStakeRemoved(event *types.StakeRemoved) error {
 			if hex.EncodeToString(iter.Event.VegaPublicKey[:]) == vegaPubKey &&
 				iter.Event.Amount.Cmp(amountDeposited) == 0 &&
 				iter.Event.Raw.BlockNumber == event.BlockNumber &&
-				uint64(iter.Event.Raw.Index) == event.LogIndex {
+				uint64(iter.Event.Raw.Index) == event.LogIndex &&
+				iter.Event.Raw.TxHash.Hex() == event.TxID {
 				// now we know the event is OK,
 				// just need to check for confirmations
 				return o.ethConfirmations.Check(event.BlockNumber)

programming_language: Go
filename: on_chain_verifier.go
change_type: ModificationType.MODIFY
diff: @@ -165,7 +165,8 @@ func (o *OnChainVerifier) CheckThresholdSetEvent(
 		if iter.Event.Raw.BlockNumber == event.BlockNumber &&
 			uint64(iter.Event.Raw.Index) == event.LogIndex &&
 			iter.Event.NewThreshold == uint16(event.Threshold) &&
-			nonce.Cmp(iter.Event.Nonce) == 0 {
+			nonce.Cmp(iter.Event.Nonce) == 0 &&
+			iter.Event.Raw.TxHash.Hex() == event.TxHash {
 			// now we know the event is OK,
 			// just need to check for confirmations
 			return o.ethConfirmations.Check(event.BlockNumber)
@@ -205,7 +206,8 @@ func (o *OnChainVerifier) filterSignerAdded(
 		if iter.Event.Raw.BlockNumber == event.BlockNumber &&
 			uint64(iter.Event.Raw.Index) == event.LogIndex &&
 			iter.Event.NewSigner.Hex() == event.Address &&
-			nonce.Cmp(iter.Event.Nonce) == 0 {
+			nonce.Cmp(iter.Event.Nonce) == 0 &&
+			iter.Event.Raw.TxHash.Hex() == event.TxHash {
 			// now we know the event is OK,
 			// just need to check for confirmations
 			return o.ethConfirmations.Check(event.BlockNumber)
@@ -245,7 +247,8 @@ func (o *OnChainVerifier) filterSignerRemoved(
 		if iter.Event.Raw.BlockNumber == event.BlockNumber &&
 			uint64(iter.Event.Raw.Index) == event.LogIndex &&
 			iter.Event.OldSigner.Hex() == event.Address &&
-			nonce.Cmp(iter.Event.Nonce) == 0 {
+			nonce.Cmp(iter.Event.Nonce) == 0 &&
+			iter.Event.Raw.TxHash.Hex() == event.TxHash {
 			// now we know the event is OK,
 			// just need to check for confirmations
 			return o.ethConfirmations.Check(event.BlockNumber)

programming_language: Go