mirror of
https://github.com/tailscale/tailscale.git
synced 2025-12-06 04:42:42 +00:00
net/portmapper: don't return unspecified/local external IPs
We were previously not checking that the external IP that we got back from a UPnP portmap was a valid endpoint; add minimal validation that this endpoint is something that is routeable by another host. Updates tailscale/corp#23538 Signed-off-by: Andrew Dunham <andrew@du.nham.ca> Change-Id: Id9649e7683394aced326d5348f4caa24d0efd532
This commit is contained in:
@@ -638,6 +638,19 @@ func (c *Client) tryUPnPPortmapWithDevice(
|
||||
return netip.AddrPort{}, nil, err
|
||||
}
|
||||
|
||||
// Do a bit of validation on the external IP; we've seen cases where
|
||||
// UPnP devices return the public IP 0.0.0.0, which obviously doesn't
|
||||
// work as an endpoint.
|
||||
//
|
||||
// See: https://github.com/tailscale/corp/issues/23538
|
||||
if externalIP.IsUnspecified() {
|
||||
c.logf("UPnP returned unspecified external IP %v", externalIP)
|
||||
return netip.AddrPort{}, nil, fmt.Errorf("UPnP returned unspecified external IP")
|
||||
} else if externalIP.IsLoopback() {
|
||||
c.logf("UPnP returned loopback external IP %v", externalIP)
|
||||
return netip.AddrPort{}, nil, fmt.Errorf("UPnP returned loopback external IP")
|
||||
}
|
||||
|
||||
return netip.AddrPortFrom(externalIP, newPort), client, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user