-
Notifications
You must be signed in to change notification settings - Fork 72
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
network-libp2p: Add fixes and improvements to discovery protocol #2461
Conversation
c122841
to
1cfe168
Compare
1cfe168
to
fd8f7aa
Compare
2b9c6d0
to
1bfe8cd
Compare
5777122
to
2377895
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, left some comments.
74ab225
to
fc08ae5
Compare
fc08ae5
to
555eead
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
} | ||
HandlerOutEvent::ObservedAddress { observed_address } => { | ||
self.events | ||
.push_back(ToSwarm::NewExternalAddrCandidate(observed_address)); | ||
} | ||
HandlerOutEvent::Update => self.events.push_back(ToSwarm::GenerateEvent(Event::Update)), | ||
HandlerOutEvent::Error(_) => self.events.push_back(ToSwarm::CloseConnection { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understand correctly this is where the StateTransitionTimeout
would end up. I may have missed it, but I think some logging would be nice here.
555eead
to
2fad9e3
Compare
Add limits to the peer contact addresses and add the ability to verify that these limits are followed when a peer contact is received from the network (discovery protocol).
Reduce the reported observed addresses to a single address within the discovery protocol. This avoids DoS attacks from a peer sending several observed addresses for a specific connection. In terms of functionality, it stays the same since we were only reporting a single observed address (the address that got us a connection). Also reduced the interaction between the handler and the behaviour by setting handler attributes on the constructor instead of using events to the handler.
Do not use the observed addresses sent through the discovery protocol since these addresses are not authenticated and it's been observed that they are not adding any useful address to a peer and instead were adding addresses with incorrect TCP/UDP ports.
Add timeout for the state transition in the discovery handler such that a peer don't hold us in a state indefinitely if it doesn't send us back a message we expect. This fixes #2458.
e011a71
to
87eeee1
Compare
Add verification of peer contacts received from the different messages that can transmit a list of peer contacts in the discovery protocol. The verification includes checks for appropriate lengths, signatures and number of addresses.
87eeee1
to
68ae7db
Compare
What's in this pull request?
This fixes DoS in Discovery Handler #2458.
Pull request checklist
clippy
andrustfmt
warnings.