Skip to content

Conversation

@alienx5499
Copy link
Contributor

Summary

This PR fixes a security vulnerability where the C++ implementation of libp2p's Identify protocol did not validate the signedPeerRecord field, allowing malicious peers to inject or forward third-party signed peer records leading to address poisoning and potential identity spoofing.

Changes

  1. Added signedPeerRecord field to Identify protobuf (src/protocol/identify/protobuf/identify.proto)

    • Added optional bytes field signedPeerRecord = 8 for signed peer record envelope
  2. Implemented validation logic (src/protocol/identify/identify_msg_processor.cpp)

    • Added consumeSignedPeerRecord() method to validate signed peer records
    • Modified identifyReceived() to check and validate signedPeerRecord before accepting addresses
    • If signedPeerRecord is present but invalid, all addresses are rejected (prevents address injection)
    • Falls back to listenAddrs only if no signedPeerRecord is present
  3. Added method declaration (include/libp2p/protocol/identify/identify_msg_processor.hpp)

    • Added private method consumeSignedPeerRecord() declaration

Security Impact

Before: signedPeerRecord field was completely ignored, allowing any peer to send third-party signed records, causing address poisoning attacks.

After: signedPeerRecord is validated (currently rejects invalid records), preventing the vulnerability. Full peer record envelope parsing can be implemented later.

Testing

  • All existing tests pass (4/4 tests)
  • Code compiles without errors
  • Protobuf files regenerated successfully
  • Backward compatibility maintained

Related Issues

Fixes #332

Implementation Notes

The current implementation provides a security fix that rejects invalid signedPeerRecord values. 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.

@alienx5499 alienx5499 changed the title # Fix signedPeerRecord validation in IdentifyMessageProcessor (Issue #332) Fix signedPeerRecord validation in IdentifyMessageProcessor Dec 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Lack of signedPeerRecord Validation in C++ IdentifyMessageProcessor Leads to Address Injection

1 participant