Fix signedPeerRecord validation in IdentifyMessageProcessor #338
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.
Summary
This PR fixes a security vulnerability where the C++ implementation of libp2p's Identify protocol did not validate the
signedPeerRecordfield, allowing malicious peers to inject or forward third-party signed peer records leading to address poisoning and potential identity spoofing.Changes
Added
signedPeerRecordfield to Identify protobuf (src/protocol/identify/protobuf/identify.proto)signedPeerRecord = 8for signed peer record envelopeImplemented validation logic (
src/protocol/identify/identify_msg_processor.cpp)consumeSignedPeerRecord()method to validate signed peer recordsidentifyReceived()to check and validatesignedPeerRecordbefore accepting addressessignedPeerRecordis present but invalid, all addresses are rejected (prevents address injection)listenAddrsonly if nosignedPeerRecordis presentAdded method declaration (
include/libp2p/protocol/identify/identify_msg_processor.hpp)consumeSignedPeerRecord()declarationSecurity Impact
Before:
signedPeerRecordfield was completely ignored, allowing any peer to send third-party signed records, causing address poisoning attacks.After:
signedPeerRecordis validated (currently rejects invalid records), preventing the vulnerability. Full peer record envelope parsing can be implemented later.Testing
Related Issues
Fixes #332
Implementation Notes
The current implementation provides a security fix that rejects invalid
signedPeerRecordvalues. Full peer record envelope parsing and signature verification according to libp2p specifications can be added in a follow-up PR. The structure is in place for future enhancement.