tailscale/wgengine
Patrick O'Doherty a2b3583d49
wgengine/netstack: reject unserved ports on Service (VIP) IPs (#20363) (#20402)
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


(cherry picked from commit a68be19739)

Signed-off-by: kevinliang10 <kevinliang@tailscale.com>
Signed-off-by: Patrick O'Doherty <patrick@tailscale.com>
Co-authored-by: KevinLiang10 <37811973+KevinLiang10@users.noreply.github.com>
2026-07-10 13:44:29 -07:00
..
bench wgengine/magicsock: restore SetDERPMap signature, add SetDERPMapWithoutReSTUN 2026-04-29 12:46:15 -07:00
filter all: use Go 1.26 things, run most gofix modernizers 2026-03-06 13:32:03 -08:00
magicsock wgengine/magicsock: consider VNI as part of peer relay handshake suppression 2026-06-23 13:26:22 -07:00
netlog all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
netstack wgengine/netstack: reject unserved ports on Service (VIP) IPs (#20363) (#20402) 2026-07-10 13:44:29 -07:00
router wgengine/router/osrouter: skip netfilter add-ons when chain setup fails (#19761) 2026-05-15 09:34:44 -04:00
wgcfg go.mod,wgengine/magicsock: pull wireguard-go fix for roaming endpoints (#20118) 2026-06-18 10:10:32 -07:00
wgint all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
wglog all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08: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
pendopen_omit.go all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
pendopen.go all: use bart.Lite instead of bart.Table where appropriate 2026-03-24 14:45:23 +00:00
userspace_ext_test.go all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
userspace_test.go cmd/cloner: preserve nil-valued entries when cloning map (#19749) 2026-05-14 10:37:18 -04:00
userspace.go wgengine, all: remove LazyWG, use wireguard-go callback API for on-demand peers 2026-04-29 19:46:19 -07:00
watchdog_omit.go all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
watchdog_test.go cmd/vet: add subtestnames analyzer; fix all existing violations 2026-04-05 15:52:51 -07:00
watchdog.go wgengine, all: remove LazyWG, use wireguard-go callback API for on-demand peers 2026-04-29 19:46:19 -07:00
wgengine.go wgengine, all: remove LazyWG, use wireguard-go callback API for on-demand peers 2026-04-29 19:46:19 -07:00