Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
DHT allows the impersonation attack because method getNode updates the node's addr in following case: node A (IP address 1.1.1.1) has InfoHash 8ffe0d18748cfc04d1bc0a2e8c3a548e06f3f794 and sends a Ping to node B (IP address 2.2.2.2), then node B sends neighborhood maintenance to 1.1.1.1. Thus, a malicious node (IP Address 3.3.3.3) discovers the InfoHash 8ffe0d18748cfc04d1bc0a2e8c3a548e06f3f794 from Node A and sends DHT packets to Node B.
Thus, when node B receives a message, it will update the node A address. Then, it will send the neighborhood maintenance to 3.3.3.3 instead 1.1.1.1.
With this change, node A will update the node addr when node B sends a confirmation after 1 minute or it is old. When node B is not old, node A updates the node addr with its actual addr.