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: peer id claim for strong FID<>Peer ID authentication #2164

Open
wants to merge 18 commits into
base: main
Choose a base branch
from

Conversation

Wazzymandias
Copy link
Contributor

@Wazzymandias Wazzymandias commented Jul 12, 2024

Why is this change needed?

  • require FID on hub startup, add FID to gossip contact info

Merge Checklist

Choose all relevant options below by adding an x now or at any time before submitting for review


PR-Codex overview

This PR focuses on adding FID requirement on hub startup and integrating FID into gossip contact info.

Detailed summary

  • Added FID requirement on hub startup
  • Integrated FID into gossip contact info
  • Updated peer claim functions
  • Updated contact info content structure
  • Added peer identity claim message
  • Updated CLI options
  • Updated Docker run command for hub startup

The following files were skipped due to too many changes: apps/hubble/src/network/sync/syncEngine.test.ts, yarn.lock, apps/hubble/src/peerclaim/peerclaim.ts, packages/hub-web/src/generated/gossip.ts, packages/hub-nodejs/src/generated/gossip.ts, packages/core/src/protobufs/generated/gossip.ts, apps/hubble/src/peerclaim/peerclaim.test.ts, apps/hubble/src/hubble.ts, apps/hubble/src/cli.ts, packages/hub-web/src/generated/rpc.ts

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

@Wazzymandias Wazzymandias added the t-bug A fix for a bug with the current system label Jul 12, 2024
Copy link

vercel bot commented Jul 12, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
hub-monorepo ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 19, 2024 3:32am

Copy link

changeset-bot bot commented Jul 12, 2024

🦋 Changeset detected

Latest commit: aad8d67

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
@farcaster/hub-nodejs Patch
@farcaster/hub-web Patch
@farcaster/core Patch
@farcaster/hubble Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Member

@sds sds left a comment

Choose a reason for hiding this comment

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

Should we come up with some signature scheme that allows FIDs to "prove" they are runners of a given peer ID?

Otherwise people can just impersonate.

Thinking here: you don't need to keep your FID's custody wallet online, you just sign a message with your FID + the peer ID you're running with and then any other hub can verify the legitimacy of that signature?

(We may have discussed this, so not a blocker if we just want to get something out)

.github/workflows/ci.yml Outdated Show resolved Hide resolved
apps/hubble/src/hubble.ts Outdated Show resolved Hide resolved
apps/hubble/src/cli.ts Outdated Show resolved Hide resolved
protobufs/schemas/gossip.proto Outdated Show resolved Hide resolved
apps/hubble/src/hubble.ts Outdated Show resolved Hide resolved
Copy link

socket-security bot commented Jul 17, 2024

New and removed dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/@aws-sdk/[email protected] Transitive: environment, filesystem, network, shell +95 7.21 MB amzn-oss, aws-sdk-bot, kuhe, ...2 more
npm/@aws-sdk/[email protected] Transitive: environment, filesystem, network, shell +70 3.78 MB amzn-oss, aws-sdk-bot, kuhe, ...2 more
npm/@aws-sdk/[email protected] filesystem Transitive: environment, network +27 1.37 MB amzn-oss, aws-sdk-bot, kuhe, ...2 more
npm/@chainsafe/[email protected] Transitive: environment, filesystem, network +72 22.3 MB wemeetagain
npm/@chainsafe/[email protected] Transitive: environment +58 5.41 MB mpetrunic
npm/@datastructures-js/[email protected] None +1 62.3 kB eyas-ranjous
npm/@faker-js/[email protected] None 0 9.35 MB shinigami92
npm/@farcaster/[email protected] eval +2 12.8 MB wazzymandias
npm/@fastify/[email protected] None +3 554 kB matteo.collina
npm/@figma/[email protected] environment, filesystem, network 0 87.5 kB jfirebaugh
npm/@libp2p/[email protected] None +19 942 kB npm-service-account-libp2p
npm/@libp2p/[email protected] None +19 958 kB npm-service-account-libp2p
npm/@libp2p/[email protected] Transitive: environment +53 2.31 MB npm-service-account-libp2p
npm/@libp2p/[email protected] None +1 276 kB npm-service-account-libp2p
npm/@libp2p/[email protected] Transitive: environment, eval +32 2.96 MB npm-service-account-libp2p
npm/@libp2p/[email protected] None +10 3.21 MB npm-service-account-libp2p
npm/@libp2p/[email protected] Transitive: environment +29 1.5 MB npm-service-account-libp2p
npm/@libp2p/[email protected] Transitive: environment, network +32 1.64 MB npm-service-account-libp2p
npm/@multiformats/[email protected] Transitive: environment, network, unsafe +10 1.86 MB npm-service-account-multiformats
npm/@noble/[email protected] None +1 2.27 MB paulmillr
npm/@types/[email protected] None 0 7.46 kB types
npm/@types/[email protected] None 0 13.5 kB types
npm/@types/[email protected] None 0 13.1 kB types
npm/@types/[email protected] None 0 6.23 kB types
npm/@types/[email protected] None 0 6.51 kB types
npm/@types/[email protected] None 0 4.13 kB types
npm/@types/[email protected] None +1 100 kB types
npm/@viem/[email protected] network Transitive: environment, filesystem, shell +19 841 kB awkweb
npm/[email protected] None 0 1.14 MB awkweb
npm/[email protected] None 0 18.3 kB rogierschouten
npm/[email protected] network 0 2.08 MB jasonsaayman
npm/[email protected] None 0 217 kB lancedikson
npm/[email protected] None +1 15.7 kB junderw
npm/[email protected] filesystem, shell 0 12.3 kB kjv
npm/[email protected] None 0 2.13 MB victorquinn
npm/[email protected] None 0 62.2 kB andidittrich
npm/[email protected] environment, filesystem, shell 0 174 kB abetomo
npm/[email protected] None 0 904 kB david
npm/[email protected] Transitive: environment, eval, filesystem, unsafe +50 7.24 MB eomm
npm/[email protected] None +1 184 kB ralphbot
npm/[email protected] Transitive: environment, filesystem, network, shell +137 13.6 MB npm-service-account-libp2p
npm/[email protected] shell +1 184 kB merencia
npm/[email protected] environment, filesystem Transitive: eval, shell +39 1.47 MB ds300
npm/[email protected] Transitive: environment, filesystem +21 1.53 MB jsumners
npm/[email protected] unsafe Transitive: environment, eval +10 795 kB matteo.collina
npm/[email protected] environment, filesystem, shell, unsafe Transitive: eval, network +94 16.2 MB tknew
npm/[email protected] filesystem, shell 0 2.74 kB ds300
npm/[email protected] None 0 309 B voidagency
npm/[email protected] None 0 15.5 kB turbopope
npm/[email protected] None 0 124 kB animir
npm/[email protected] None +57 1.92 MB wooorm
npm/[email protected] None +32 1.12 MB wooorm
npm/[email protected] None +18 531 kB wooorm
npm/[email protected] None 0 7.6 kB 71104
npm/[email protected] None +1 109 kB npm-cli-ops
npm/[email protected] environment, filesystem +6 340 kB isaacs
npm/[email protected] None 0 5.3 kB binier
npm/[email protected] None +1 1.54 MB kuziu
npm/[email protected] Transitive: environment, filesystem, network, shell, unsafe +25 227 MB hirokiosame
npm/[email protected] None +10 402 kB wooorm
npm/[email protected] network Transitive: environment +5 7.42 MB jmoxey

🚮 Removed packages: npm/@chainsafe/[email protected], npm/@chainsafe/[email protected], npm/@chainsafe/[email protected], npm/@esbuild-kit/[email protected], npm/@esbuild-kit/[email protected], npm/@esbuild-kit/[email protected], npm/@esbuild/[email protected], npm/@esbuild/[email protected], npm/@esbuild/[email protected], npm/@esbuild/[email protected], npm/@esbuild/[email protected], npm/@esbuild/[email protected], npm/@esbuild/[email protected], npm/@esbuild/[email protected], npm/@esbuild/[email protected], npm/@esbuild/[email protected], npm/@esbuild/[email protected], npm/@esbuild/[email protected], npm/@esbuild/[email protected], npm/@esbuild/[email protected], npm/@esbuild/[email protected], npm/@esbuild/[email protected], npm/@esbuild/[email protected], npm/@esbuild/[email protected], npm/@esbuild/[email protected], npm/@esbuild/[email protected], npm/@esbuild/[email protected], npm/@esbuild/[email protected], npm/@ethersproject/[email protected], npm/@ethersproject/[email protected], npm/@ethersproject/[email protected], npm/@ethersproject/[email protected], npm/@ethersproject/[email protected], npm/@ethersproject/[email protected], npm/@ethersproject/[email protected], npm/@ethersproject/[email protected], npm/@ethersproject/[email protected], npm/@ethersproject/[email protected], npm/@ethersproject/[email protected], npm/@ethersproject/[email protected], npm/@ethersproject/[email protected], npm/@ethersproject/[email protected], npm/@ethersproject/[email protected], npm/@ethersproject/[email protected], npm/@ethersproject/[email protected], npm/@ethersproject/[email protected], npm/@ethersproject/[email protected], npm/@ethersproject/[email protected], npm/@ethersproject/[email protected], npm/@ethersproject/[email protected], npm/@ethersproject/[email protected], npm/@ethersproject/[email protected], npm/@ethersproject/[email protected], npm/@ethersproject/[email protected], npm/@ethersproject/[email protected], npm/@ethersproject/[email protected], npm/@ethersproject/[email protected], npm/@ethersproject/[email protected], npm/@farcaster/[email protected], npm/@farcaster/[email protected], npm/@farcaster/[email protected], npm/@farcaster/[email protected], npm/@farcaster/[email protected], npm/@farcaster/[email protected], npm/@fastify/[email protected], npm/@grpc/[email protected], npm/@grpc/[email protected], npm/@grpc/[email protected], npm/@metamask/[email protected], npm/@noble/[email protected], npm/@noble/[email protected], npm/@noble/[email protected], npm/@nomicfoundation/[email protected], npm/@nomicfoundation/[email protected], npm/@nomicfoundation/[email protected], npm/@nomicfoundation/[email protected], npm/@nomicfoundation/[email protected], npm/@nomicfoundation/[email protected], npm/@nomicfoundation/[email protected], npm/@nomicfoundation/[email protected], npm/@nomicfoundation/[email protected], npm/@nomicfoundation/[email protected], npm/@nomicfoundation/[email protected], npm/@nomicfoundation/[email protected], npm/@nomicfoundation/[email protected], npm/@nomicfoundation/[email protected], npm/@nomicfoundation/[email protected], npm/@nomicfoundation/[email protected], npm/@nomicfoundation/[email protected], npm/@nomicfoundation/[email protected], npm/@nomicfoundation/[email protected], npm/@nomicfoundation/[email protected], npm/@nomicfoundation/[email protected], npm/@nomicfoundation/[email protected], npm/@scure/[email protected], npm/@scure/[email protected], npm/@sentry/[email protected], npm/@sentry/[email protected], npm/@sentry/[email protected], npm/@sentry/[email protected], npm/@sentry/[email protected], npm/@sentry/[email protected], npm/@sentry/[email protected], npm/@types/[email protected], npm/@types/[email protected], npm/@types/[email protected], npm/@types/[email protected], npm/@types/[email protected], npm/@types/[email protected], npm/@types/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected]

View full report↗︎

resolved "https://registry.npmjs.org/@chainsafe/libp2p-noise/-/libp2p-noise-11.0.0.tgz#ecfc82230f0fa73be3ed92add4b09424d9d1e280"
integrity sha512-NEl5aIv6muz9OL+dsa3INEU89JX0NViBxOy7NwwG8eNRPUDHo5E3ZTMSHXQpVx1K/ofoNS4ANO9xwezY6ss5GA==
"@chainsafe/libp2p-noise@^11.0.0":
version "11.0.4"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't know why this changed, but hub peered and synced fine with it 🤷🏾

@Wazzymandias Wazzymandias changed the title fix: require FID on hub startup, add FID to gossip contact info [WIP] fix: require FID on hub startup, add FID to gossip contact info Jul 18, 2024
…ck to match signer with FID after on-chain event sync
Copy link

socket-security bot commented Jul 19, 2024

🚨 Potential security issues detected. Learn more about Socket for GitHub ↗︎

To accept the risk, merge this PR and you will not be notified again.

Alert Package NoteSourceCI
Install scripts npm/[email protected] 🚫

View full report↗︎

Next steps

What is an install script?

Install scripts are run when the package is installed. The majority of malware in npm is hidden in install scripts.

Packages should not be running non-essential scripts during install and there are often solutions to problems people solve with install scripts that can be run at publish time instead.

Take a deeper look at the dependency

Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support [AT] socket [DOT] dev.

Remove the package

If you happen to install a dependency that Socket reports as Known Malware you should immediately remove it and select a different dependency. For other alert types, you may may wish to investigate alternative packages or consider if there are other ways to mitigate the specific risk posed by the dependency.

Mark a package as acceptable risk

To ignore an alert, reply with a comment starting with @SocketSecurity ignore followed by a space separated list of ecosystem/package-name@version specifiers. e.g. @SocketSecurity ignore npm/[email protected] or ignore all packages with @SocketSecurity ignore-all

@Wazzymandias Wazzymandias changed the title [WIP] fix: require FID on hub startup, add FID to gossip contact info fix: require FID on hub startup, add FID to gossip contact info Jul 19, 2024
const contactInfo = NetworkFactories.GossipContactInfoContent.build({ timestamp: now });
const olderContactInfo = NetworkFactories.GossipContactInfoContent.build({ timestamp: now - 10 });
const newerContactInfo = NetworkFactories.GossipContactInfoContent.build({ timestamp: now + 10 });
const contactInfo: ContactInfoContent = NetworkFactories.GossipContactInfoContent.build({
Copy link
Contributor Author

@Wazzymandias Wazzymandias Jul 19, 2024

Choose a reason for hiding this comment

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

We should dedupe content and body attributes at some point, especially since they're no longer equivalent after this PR and can end up creating subtle, annoying bugs

@@ -125,6 +125,9 @@ jobs:
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1

- name: Install turbo
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This might not be needed - CI is failing, still investigating

@@ -36,7 +36,7 @@ jobs:

- name: Run Hubble
shell: bash
run: docker run --name hub --detach -p2282:2282 -p2283:2283 farcasterxyz/hubble:test sh -c 'node build/cli.js identity create && HUBBLE_ARGS="start --rpc-port 2283 --ip 0.0.0.0 --gossip-port 2282 --eth-mainnet-rpc-url https://eth-mainnet.g.alchemy.com/v2/8cz__IXnQ5FK_GNYDlfooLzYhBAW7ta0 --l2-rpc-url https://opt-mainnet.g.alchemy.com/v2/3xWX-cWV-an3IPXmVCRXX51PpQzc-8iJ --network 3 --allowed-peers none --catchup-sync-with-snapshot false" npx pm2-runtime start pm2.config.cjs'
run: docker run --name hub --detach -p2282:2282 -p2283:2283 farcasterxyz/hubble:test sh -c 'node build/cli.js identity create && HUBBLE_ARGS="start --rpc-port 2283 --ip 0.0.0.0 --gossip-port 2282 --eth-mainnet-rpc-url https://eth-mainnet.g.alchemy.com/v2/8cz__IXnQ5FK_GNYDlfooLzYhBAW7ta0 --l2-rpc-url https://opt-mainnet.g.alchemy.com/v2/3xWX-cWV-an3IPXmVCRXX51PpQzc-8iJ --network 3 --allowed-peers none --catchup-sync-with-snapshot false --hub-operator-fid 1" npx pm2-runtime start pm2.config.cjs'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this still needs valid claim file, to be passed in via --peer-identity-claim - working on it

@Wazzymandias Wazzymandias changed the title fix: require FID on hub startup, add FID to gossip contact info feat: peer id claim for strong FID<>Peer ID authentication Jul 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
t-bug A fix for a bug with the current system
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants