tailscale/wgengine
KevinLiang10 a68be19739
wgengine/netstack: reject unserved ports on Service (VIP) IPs (#20363)
A connection to a Tailscale Service IP on a port the service does
not serve was forwarded to the underlying host. `acceptTCP` fell through to
the isTailscaleIP case (a VIP is in the Tailscale IP range), which rewrote
the dial target to 127.0.0.1:<port> and forwardTCP'd the connection onto
whatever unrelated listener happened to be on the host's loopback at that
port.

This is reachable through the service IP by any peer which was granted
access only to the service (dst: svc:foo), so it exposes host ports the
peer has no ACL access to via the machine's regular IP. This happens
when there tailscaled has a Tun interface and the forward bits are set.

In this commit, we added a guard in acceptTCP, before the isTailscaleIP case
that RSTs connections to a VIP service IP on a port with no serve handler.
Served ports return earlier via TCPHandlerForDst, so only unserved ports reach the guard.
Layer 3 services are unaffected: their traffic is released to the host in
injectInbound and never reaches acceptTCP.

Fixes #20362

Signed-off-by: kevinliang10 <kevinliang@tailscale.com>
2026-07-10 14:06:15 -04:00
..
bench wgengine: replace Engine.SetNetworkMap with SetSelfNode 2026-06-24 15:03:55 -07:00
filter all: fix more typos caused by unnecessary repetition 2026-07-06 10:36:17 +01:00
magicsock wgengine/magicsock: delete Conn.UpdatePeers, derive peer state internally 2026-07-10 10:47:44 -07:00
netlog wgengine/netlog: stop using netmap.NetworkMap type, use LocalBackend 2026-06-17 15:11:57 -07:00
netstack wgengine/netstack: reject unserved ports on Service (VIP) IPs (#20363) 2026-07-10 14:06:15 -04:00
router wgengine/router/osrouter,util/linuxfw: remove orphaned tailnet addrs (#20199) 2026-06-24 13:41:36 -07:00
wgcfg wgengine,wgcfg,feature/netlog: move network flow logging behind a feature hook 2026-07-09 12:56:37 -07:00
wgint all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
wglog wgengine/wglog: stop using netmap.NetworkMap here too 2026-06-23 09:06:37 -07:00
winnet all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
mem_ios.go all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
netlog_hooks.go wgengine,wgcfg,feature/netlog: move network flow logging behind a feature hook 2026-07-09 12:56:37 -07:00
pendopen_omit.go all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
pendopen.go feature/conn25: recreate transit IP mappings when connector loses them 2026-06-17 13:50:51 -04:00
userspace_ext_test.go all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
userspace_test.go wgengine,util/execqueue: wait for in-flight linkChange before closing 2026-07-07 06:01:08 -07:00
userspace.go wgengine/magicsock: delete Conn.UpdatePeers, derive peer state internally 2026-07-10 10:47:44 -07:00
wgengine.go wgengine,wgcfg,feature/netlog: move network flow logging behind a feature hook 2026-07-09 12:56:37 -07:00