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

Fix security issue #1362. #1377

Closed
wants to merge 3 commits into from
Closed

Fix security issue #1362. #1377

wants to merge 3 commits into from

Conversation

cheatfate
Copy link
Contributor

  • Introducing new configuration parameter maxIncomingPeers with default value of 21
  • Changing default value of configuration parameter maxPeers from 79 to 100.
  • Initialization of PeerPool with maximum number of incoming peers.
  • Fix variable names and 80 chars per line.
  • Removal of unnecessary sleepAsync.

@cheatfate cheatfate requested a review from arnetheduck July 26, 2020 22:27
@cheatfate cheatfate changed the title Fix #1362. Fix security issue #1362. Jul 26, 2020
@stefantalpalaru
Copy link
Contributor

Where are you rejecting new incoming peers when the corresponding limit is reached?

Copy link
Contributor

@mratsim mratsim left a comment

Choose a reason for hiding this comment

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

Security fixes should have a Security (I propose SEC) note so that they are not erased on refactoring.

result.peerPool = newPeerPool[Peer, PeerID](maxPeers = conf.maxPeers)
result.wantedPeers = (conf.maxPeers - conf.maxIncomingPeers)
result.peerPool = newPeerPool[Peer, PeerID](
maxPeers = conf.maxPeers, maxIncomingPeers = conf.maxIncomingPeers)
Copy link
Contributor

Choose a reason for hiding this comment

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

AFAIK this is one of the mitigation recommended in #1362.

This should explicitly be linked to the issue, maybe with "SEC" (like TODO), so that 6 months from now, after a refactoring, this mitigation does not disappear.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mratsim this is something we are missing in our implementation, it will be not refactored and we do not perform refactoring without minds.

@arnetheduck
Copy link
Member

why increase to 100? the odd number is more fun

@arnetheduck
Copy link
Member

Security fixes should have a Security (I propose SEC) note so that they are not erased on refactoring.

I'm not sure a tag is needed really (such things are hard to maintain consistently), but an explanatory comment with background / rationale makes sense regardless if it's a security issue or not every time there's a bug with an underlying tricky condition

Fix #1362.
Fix variable names and 80 chars per line.
Removal of unnecessary sleepAsync.
Add comment about why we limiting number of incoming connections.
@arnetheduck
Copy link
Member

this LGTM, but there is a similar issue with outgoing peers: if we hit limit, they will be queued meaning they'll take up resources as they're stuck in the await, but not be disconnected. #1468 slightly reorganizes when peers are added to peer pool, hopefully it will help make this branch better

@@ -106,10 +106,15 @@ type
name: "udp-port" }: Port

maxPeers* {.
defaultValue: 79 # The Wall gets released
desc: "The maximum number of peers to connect to"
defaultValue: 101 # The Wall gets released
Copy link
Member

Choose a reason for hiding this comment

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

need to leave at 79 or remove cultural reference

@zah
Copy link
Contributor

zah commented Aug 19, 2020

This needs rebasing now.

@cheatfate cheatfate closed this Aug 21, 2020
@arnetheduck arnetheduck deleted the limit-inbound branch November 11, 2020 07:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[SEC] Eth2.0 Req/Resp - Inbound peers may exhaust/dominate peer pool
5 participants