ipn,ipn/localapi: require local admin to serve Unix domain sockets

This resolves a local privilege escalation (LPE). Prior to this change,
a non-admin user could utilize serve to access local Unix sockets they
otherwise should not be able to access. For example,

  tailscale serve --http 80 unix:/var/run/docker.sock

would give the user access to the Docker socket (usually root only).
This works because tailscaled has root access and implements the proxy
to the socket (see also: 'the confused deputy problem').

We resolve the problem by refusing to serve Unix targets altogether
unless instructed to by a root user.

Thanks to Tim Sageser (dtrsecurity) for this report.

Fixes tailscale/corp#41998

Signed-off-by: Harry Harpham <harry@tailscale.com>
This commit is contained in:
Harry Harpham
2026-06-03 09:45:02 -06:00
parent 40c98cd267
commit fa542426e5
4 changed files with 217 additions and 5 deletions
+40
View File
@@ -264,6 +264,46 @@ func (sc *ServeConfig) HasPathHandler() bool {
return false
}
// IsServingUnixAny reports whether ServeConfig is serving Unix targets on any
// port or web handler.
func (sc *ServeConfig) IsServingUnixAny() bool {
if sc == nil {
return false
}
for _, fgSrvCfg := range sc.Foreground {
if fgSrvCfg.IsServingUnixAny() {
return true
}
}
for _, ph := range sc.TCP {
if strings.HasPrefix(ph.TCPForward, "unix:") {
return true
}
}
for _, web := range sc.Web {
for _, h := range web.Handlers {
if strings.HasPrefix(h.Proxy, "unix:") {
return true
}
}
}
for _, svcCfg := range sc.Services {
for _, ph := range svcCfg.TCP {
if strings.HasPrefix(ph.TCPForward, "unix:") {
return true
}
}
for _, web := range svcCfg.Web {
for _, h := range web.Handlers {
if strings.HasPrefix(h.Proxy, "unix:") {
return true
}
}
}
}
return false
}
// IsTCPForwardingAny reports whether ServeConfig is currently forwarding in
// TCPForward mode on any port. This is exclusive of Web/HTTPS serving.
func (sc *ServeConfig) IsTCPForwardingAny() bool {