The unix-socket reverse proxy checked its backend against the tailscaled socket only when the handler was built, but each backend connection re-resolved the path from scratch. A backend that was benign at config time could later be replaced with a symlink to the tailscaled socket by anyone able to write to its directory, and the next dial followed it. The proxy dials as root, so the same swap could redirect a serve or funnel backend at any root-only unix socket on the host. Move the check to the dial itself, in a dialServeUnixSocket method shared by the HTTP transport, the h2c transport and the TCP-forward handler, all of which previously dialed unix on their own. It refuses tailscaled's socket with ErrProxyToTailscaledSocket immediately before connecting. On Linux 5.6 and newer, the dial pins the resolved socket inode with openat2(2): an O_PATH descriptor opened with RESOLVE_NO_MAGICLINKS, and RESOLVE_BENEATH under the socket's parent directory where the path allows it, or by whole path otherwise. The pinned file is checked against the tailscaled socket, and the connection is made to the pinned file through /proc/self/fd, so replacing the path cannot retarget the connect. On kernels without openat2(2), and on other platforms, the path is dialed directly. The connected peer is re-checked after the dial on every platform. The peer address of a path-bound listener is the path the socket was bound to, not the path that was dialed, so a symlink swapped in before the dial is identified after the connect. This check is best-effort: connections that have no determinable peer name are allowed. Fixes tailscale/corp#50481 Change-Id: Iae5db207519db9c139a512c0427dce3dfa3ca672 Co-authored-by: James Tucker <james@tailscale.com> Signed-off-by: Sam Jean <samj@tailscale.com> Signed-off-by: James Tucker <james@tailscale.com>
Tailscale
Private WireGuard® networks made easy
Overview
This repository contains the majority of Tailscale's open source code.
Notably, it includes the tailscaled daemon and
the tailscale CLI tool. The tailscaled daemon runs on Linux, Windows,
macOS, and to varying degrees
on FreeBSD and OpenBSD. The Tailscale iOS and Android apps use this repo's
code, but this repo doesn't contain the mobile GUI code.
Other Tailscale repos of note:
- the Android app is at https://github.com/tailscale/tailscale-android
- the Synology package is at https://github.com/tailscale/tailscale-synology
- the QNAP package is at https://github.com/tailscale/tailscale-qpkg
- the Chocolatey packaging is at https://github.com/tailscale/tailscale-chocolatey
For background on which parts of Tailscale are open source and why, see https://tailscale.com/opensource/.
Using
We serve packages for a variety of distros and platforms at https://pkgs.tailscale.com.
Other clients
The macOS, iOS, and Windows clients use the code in this repository but additionally include small GUI wrappers. The GUI wrappers on non-open source platforms are themselves not open source.
Building
We always require the latest Go release, currently Go 1.27. (While we build releases with our Go fork, its use is not required.)
go install tailscale.com/cmd/tailscale{,d}
If you're packaging Tailscale for distribution, use build_dist.sh
instead, to burn commit IDs and version info into the binaries:
./build_dist.sh tailscale.com/cmd/tailscale
./build_dist.sh tailscale.com/cmd/tailscaled
If your distro has conventions that preclude the use of
build_dist.sh, please do the equivalent of what it does in your
distro's way, so that bug reports contain useful version information.
Bugs
Please file any issues about this code or the hosted service on the issue tracker.
Contributing
PRs welcome! But please file bugs. Commit messages should reference bugs.
We require Developer Certificate of
Origin
Signed-off-by lines in commits.
See commit-messages.md (or skim git log) for our commit message style.
About Us
Tailscale is primarily developed by the people at https://github.com/orgs/tailscale/people. For other contributors, see:
- https://github.com/tailscale/tailscale/graphs/contributors
- https://github.com/tailscale/tailscale-android/graphs/contributors
Legal
WireGuard is a registered trademark of Jason A. Donenfeld.