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: Add sender validation to block proposal RPC #211

Merged
merged 3 commits into from
Feb 17, 2023

Conversation

jbencin
Copy link
Member

@jbencin jbencin commented Feb 10, 2023

Description

Require block proposals to be signed by an approved signer before proceeding to parse and validate the proposal. Because validating a block proposal is an expensive operation, allowing anyone to submit a proposal would be a potential Denial of Service attack vector.

See corresponding issue for full details.

Applicable issues

Additional info (benefits, drawbacks, caveats)

  • I know I'm going to need to add some integration tests. I'm creating the pull request now in order to get some feedback on the code and some advice on testing
  • I chose to hex encode the proposal message before signing it. This allows us to validate the message signature before fully deserializing the JSON. I chose hex encoding over base64 to avoid introducing an extra dependency
  • Membership in the set of allowed signers is currently checked using Vec::contains(). Depending on the size of the signer set, it may be good to change this to a HashSet (or BTreeSet), but that would require a code change in stacks-blockchain: Deriving Hash (or Ord) for Secp256k1PublicKey

Checklist

  • Test coverage for new or modified code paths
  • Changelog is updated
  • Required documentation changes (e.g., docs/rpc/openapi.yaml and rpc-endpoints.md for v2 endpoints, event-dispatcher.md for new events)
  • New clarity functions have corresponding PR in clarity-benchmarking repo
  • New integration test(s) added to bitcoin-tests.yml

@CLAassistant
Copy link

CLAassistant commented Feb 10, 2023

CLA assistant check
All committers have signed the CLA.

@codecov-commenter
Copy link

codecov-commenter commented Feb 10, 2023

Codecov Report

Merging #211 (54cb37b) into master (54c653c) will not change coverage.
The diff coverage is n/a.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@           Coverage Diff           @@
##           master     #211   +/-   ##
=======================================
  Coverage   91.19%   91.19%           
=======================================
  Files           6        6           
  Lines         284      284           
=======================================
  Hits          259      259           
  Misses         25       25           

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@jbencin jbencin force-pushed the feat/validate-block-proposal branch from 05f72b2 to 6fcd0fb Compare February 12, 2023 18:23
@saralab saralab requested review from kantai and obycode February 13, 2023 15:37
Copy link
Contributor

@kantai kantai left a comment

Choose a reason for hiding this comment

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

This looks great to me! My only comment is on the message field -- it seems like it would make more sense for that to be a Proposal type rather than the String, but I could be convinced otherwise.

@jbencin jbencin force-pushed the feat/validate-block-proposal branch from 6fcd0fb to 54cb37b Compare February 17, 2023 20:54
@jbencin jbencin requested a review from kantai February 17, 2023 20:57
Copy link
Member

@obycode obycode left a comment

Choose a reason for hiding this comment

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

lgtm!

@jbencin jbencin merged commit 0a5ccc1 into hirosystems:master Feb 17, 2023
@jbencin jbencin deleted the feat/validate-block-proposal branch February 17, 2023 23:06
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.

Add sender validation to block proposal RPC
5 participants