Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: verify all p2p messages #958

Merged
merged 53 commits into from
Dec 2, 2024
Merged

feat: verify all p2p messages #958

merged 53 commits into from
Dec 2, 2024

Conversation

djordon
Copy link
Collaborator

@djordon djordon commented Nov 26, 2024

Description

Closes #995.

We now verify all network messages, not just the WSTS ones.

Changes

  • Always verify that the message was signed with the given public key upon receipt of the message.
  • Decode protobuf messages in a way that allows for upgradability.

Testing Information

This PR adds tests that check that we can upgrade protobufs and things can be decoded and verified. Maybe we should add another test that improperly signed messages are rejected.

Checklist:

  • I have performed a self-review of my code

@djordon djordon added the signer communication Communication across sBTC bootstrap signers. label Nov 26, 2024
@djordon djordon self-assigned this Nov 26, 2024
@cylewitruk
Copy link
Member

cylewitruk commented Nov 26, 2024

So I guess I'm mostly curious if we feel we need this? We already have Strict message validation enabled in the gossipsub config so all messages are already signed using the signer's pubkey (now that we use the signers' keys for identity) and verified at receipt/propagation.

More info here: https://github.com/libp2p/specs/blob/master/pubsub%2FREADME.md

@djordon
Copy link
Collaborator Author

djordon commented Nov 26, 2024

So I guess I'm mostly curious if we feel we need this?

No we don't, not strictly speaking at least. We have multiple layers of security: one or two at the networking layer, another with WSTS checks, validation of bitcoin and stacks transactions, trusted peers, and so on. But I think it's best to go with a "defense in depth" approach (other bitcoin bridges do this too). So I'm for a simple change like this for that reason.

But AR also flagged missing integrity checks on our messages (in #517) so I think we should care that we sign our entire messages on top of the networking layer. And if we care about signing the entire message, we should verify them as well.

@djordon djordon force-pushed the 517-add-integrity-protection-for-all-messages branch from 295735b to 98c1d84 Compare November 26, 2024 20:38
@djordon
Copy link
Collaborator Author

djordon commented Dec 1, 2024

I'm going to add one more test here but this is good to review now.

@djordon djordon marked this pull request as ready for review December 1, 2024 13:17
signer/src/ecdsa.rs Outdated Show resolved Hide resolved
signer/src/error.rs Outdated Show resolved Hide resolved
signer/src/ecdsa.rs Show resolved Hide resolved
Base automatically changed from 517-add-integrity-protection-for-all-messages to main December 2, 2024 00:05
@djordon djordon merged commit 53cc756 into main Dec 2, 2024
4 checks passed
@djordon djordon deleted the verify-all-p2p-messages branch December 2, 2024 00:32
@cylewitruk cylewitruk added the breaking-protocol Breaking protocol changes label Dec 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-protocol Breaking protocol changes signer communication Communication across sBTC bootstrap signers.
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

[Feature]: Verify that the message's public key match message source
4 participants