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

Query peerlist should contain network addresses #38

Closed
Tracked by #54
guillaumemichel opened this issue Jun 28, 2023 · 1 comment · Fixed by #41
Closed
Tracked by #54

Query peerlist should contain network addresses #38

guillaumemichel opened this issue Jun 28, 2023 · 1 comment · Fixed by #41

Comments

@guillaumemichel
Copy link
Contributor

The following security issue concerns both go-libp2p-kad-dht and go-kademlia.

Each query needs to keep track of which peers it is (1) already queried, (2) couldn't connect, (3) waiting on a response, or (4) didn't query yet.

A peer should not be marked as couldn't connect, after the first dial failed.

Let's consider the following scenario. A is looking for the 20 closest peers to a specific key (e.g to allocate a provider record). As it converges, A sends a request to B replying with closer peers to the target key. B response include the peer.AddrInfo of C, but with invalid multiaddresses. A tries to query C but cannot connect, as it doesn't know the right multiaddress of C. A marks C as couldn't connect. Later, A receives a response from D containing C's actual multiaddress. A will not try to contact C again, because it considers that this peer.ID is unresponsive. If C is among the 20 closest peers to the target key, then A will miss it, even though it could have reached it.

This has security implications, because it facilitates eclipse attacks. Multiple malicious peers can make it hard to discover a victim, by spreading an incorrect multiaddress. It wouldn't prevent honest nodes to provide the actual address of the victim, but the requester will likely not even try it.

It is OK to classify PeerIDs as (1) already queried, or (4) didn't query yet (and even (3) waiting on a response). It would be better not to classify the PeerID as (2) couldn't connect, but rather the union of peer.ID and the attempted multiaddress. This would allow the query to try connecting to a new multiaddress if a new one is discovered in the future.

@guillaumemichel
Copy link
Contributor Author

#41 addresses this issue in go-kademlia

@guillaumemichel guillaumemichel linked a pull request Jul 6, 2023 that will close this issue
@iand iand closed this as completed in #41 Jul 7, 2023
iand pushed a commit that referenced this issue Jul 7, 2023
Major features of this large PR:
* Cleaning up the `SimpleQuery` module
* Added 100% test coverage for the `SimpleQuery` module
* Small changes introduced in other modules to make sure their interface
can be used by `Query` implementations
* Completed test coverage of other modules
* Fix flaky tests in the `libp2pendpoint` module
* Addressing #38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant