-
Notifications
You must be signed in to change notification settings - Fork 111
swarm/network: Use actual remote peer ip in underlay #1224
Conversation
Currently we can use the It that's the case, would this fix also solve that? I see this would bring the advantage of:
But would also bring the problem:
|
I don't think it would be much of an attack. Since that service wouldn't speak That said: yes, this fix indeed improve the previous situation, as it won't allow arbitrary host information in the swarm handshake.
For the second part of your question, I would say that this is out of scope for this PR. What you are discussing seems to concern the |
And actually, the description in the PR is a bit misleading. Their enode strings will not be localhost on the |
// the remote enode string may advertise arbitrary host information (e.g. localhost) | ||
// this method ensures that the addr of the peer will be the one | ||
// applicable on the interface the connection came in on | ||
// it modifies the passed bzzaddr in place, and returns the same pointer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why return pointer then?
swarm/network/protocol.go
Outdated
log.Debug("rewrote peer uaddr host/port", "addr", baddr) | ||
baddr.UAddr = regexpEnodeIP.ReplaceAll(baddr.UAddr, []byte(remoteStr)) | ||
} | ||
return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just please check len(hsSubmatch)
Submitted upstream ethereum/go-ethereum#19137 |
I think we should revert this PR. We are already overwriting good remote IPs, for example:
If a node announces itself with a given IP:PORT, by protocol definition this is what we should try to connect to, and not infer its remote IP:PORT. If a node announces itself with |
Resolves #1219 (see description below) by extracting the remote address of the
p2p.Peer
and overwriting theBzzAddr.UAddr
if they differ.This is a temporary fix awaiting ENR refactor.
Example; Nodes
A
,B
andC
are started without--nat
flag. Their enode strings used in the swarm handshake will all have localhost.You find a subnet ip for
A
that's reachable fromB
andC
. You replace the localhost in the enode string with this ip. Then you execute RPC calladmin.addPeer
with that enode string toB
andC
.Result:
B
andC
will have connected toA
, but not have connected to each other.It seems that in the discovery protocol,
B
andC
still "convince" A that they exist on localhost, and when A suggests B to C, it will be with localhost as the host part.Instead, it would be more natural that A stores the ip from the interface the request can in on, and propagates this as the host part.
Note; the same problem applies if you do the
admin.addPeer
onA
toB
andC
.