From 98718ae270657cd26fb8f525eb9e9e506524c6c9 Mon Sep 17 00:00:00 2001 From: Matt Whitehead Date: Fri, 19 Jan 2024 14:08:53 +0000 Subject: [PATCH] Only accept a address from a peer if it is a valid IP address (#6439) Signed-off-by: Matthew Whitehead --- .../besu/ethereum/p2p/discovery/PeerDiscoveryAgent.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/discovery/PeerDiscoveryAgent.java b/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/discovery/PeerDiscoveryAgent.java index 2324630d831..30272413d49 100644 --- a/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/discovery/PeerDiscoveryAgent.java +++ b/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/discovery/PeerDiscoveryAgent.java @@ -293,7 +293,9 @@ protected void handleIncomingPacket(final Endpoint sourceEndpoint, final Packet .getPacketData(PingPacketData.class) .flatMap(PingPacketData::getFrom) .map(Endpoint::getHost) - .filter(abc -> !abc.equals("127.0.0.1")) + .filter( + fromAddr -> + (!fromAddr.equals("127.0.0.1") && InetAddresses.isInetAddress(fromAddr))) .stream() .peek( h ->