Skip to content

EVM Watcher Security Improvements#4676

Open
mdulin2 wants to merge 8 commits intowormhole-foundation:mainfrom
mdulin2:EthereumWatcherSecurityInvariants
Open

EVM Watcher Security Improvements#4676
mdulin2 wants to merge 8 commits intowormhole-foundation:mainfrom
mdulin2:EthereumWatcherSecurityInvariants

Conversation

@mdulin2
Copy link
Copy Markdown
Contributor

@mdulin2 mdulin2 commented Feb 17, 2026

We support a large number of EVM chains. There are several invariants that we currently rely on that we should probably explicitly check for that we were not. Specifically, we assume that the EVM subscription will return only logs matching the filter. We assume that a failed Tx will not have any logs. New checks have been added below.

  • Tx Status.
  • Contract emitter.
  • Event type
  • LogRemoved is false.

@mdulin2
Copy link
Copy Markdown
Contributor Author

mdulin2 commented Feb 17, 2026

There are a couple of less-than-ideal things here. For the instant path, we don't have the TxStatus. So, this requires an extra RPC call to get a single value. If there's a better way to do this, please make me aware, and I'll be happy to change it.

Second, the isLogValid function in the safe/finalized path is slightly annoying to find the proper index. The log entry stores the log index for the entire block, not for the transaction itself. So, we store the block log index instead. From there, we get the first index of the recipient and subtract from that block log index to find the relative offset within the logs. This makes the lookup O(1) but is slightly hard to reason about.

Comment thread node/pkg/watchers/evm/watcher.go Outdated
Comment thread node/pkg/watchers/evm/watcher.go Outdated
Comment thread node/pkg/watchers/evm/by_transaction.go Outdated
Comment thread node/pkg/watchers/evm/connectors/batch_poller.go Outdated
Comment thread node/pkg/watchers/evm/watcher.go Outdated
@mdulin2 mdulin2 force-pushed the EthereumWatcherSecurityInvariants branch from 9e622c3 to eea1015 Compare March 10, 2026 17:34
@mdulin2 mdulin2 requested a review from djb15 as a code owner March 10, 2026 17:34
djb15
djb15 previously approved these changes Mar 10, 2026
Copy link
Copy Markdown
Collaborator

@djb15 djb15 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the changes are fine, but it's worth running this on a Guardian in testnet first before wider rollout given the code changes are on the critical path

Comment thread node/pkg/watchers/evm/watcher.go
Comment thread node/pkg/watchers/evm/watcher.go Outdated
@johnsaigle johnsaigle force-pushed the EthereumWatcherSecurityInvariants branch from 2441370 to 6954f66 Compare April 15, 2026 20:21
@mdulin2 mdulin2 requested a review from djb15 April 15, 2026 21:26
Copy link
Copy Markdown
Contributor

@johnsaigle johnsaigle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some suggestions. Overall the changes look good 👍🏻

Comment thread node/pkg/watchers/evm/by_transaction.go Outdated
Comment thread node/pkg/watchers/evm/by_transaction.go
Comment thread node/pkg/watchers/evm/by_transaction.go
Comment thread node/pkg/watchers/evm/custom_consistency_level.go Outdated
Comment thread node/pkg/watchers/evm/watcher.go Outdated
Comment thread node/pkg/watchers/evm/watcher.go Outdated
Comment thread node/pkg/watchers/evm/watcher.go
Comment thread node/pkg/watchers/evm/by_transaction.go Outdated
Comment thread node/pkg/txverifier/evm.go Outdated
@johnsaigle johnsaigle self-requested a review April 22, 2026 17:29
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.

4 participants