Commit Graph
2255 Commits
Author SHA1 Message Date
Nick Khyl 3bd67a8085 ipn/ipnlocal,logtail,net/netmon: subscribe to eventbus events by value
The eventbus routes events by exact type, and these three subscribers
took a pointer to an event type that is only ever published by value,
so they never ran. logtail could not detect the network coming back up
after an upload failure, LocalBackend never recorded or announced the
latest client version, and the magicsock portmapper log limiter never
reset after a major link change.

Updates #22307

Signed-off-by: Nick Khyl <[email protected]>
2026-11-10 13:47:01 -08:00
Brad FitzpatrickandFredrik Fornwall 501037640d tsnet: build with minimal feature tags, add test
tsnet called the serve LocalAPI client and LocalBackend methods
unconditionally, so it didn't build with ts_omit_serve, which every
minimal feature set includes. Make those methods return
feature.ErrUnavailable when serve is omitted, as ListenFunnel and
ListenService now do too.

Declare tsnet's minimum feature set (netstack) as
featuretags.TSNetMin, add cmd/featuretags --tsnet to keep it, and add
a test that type-checks tsnet with it and a few other small feature
sets.

Fixes #22282
Updates #22283

Change-Id: I866fa34d052bfd437b1c9d3309063999d7ebb02c
Co-Authored-By: Fredrik Fornwall <[email protected]>
Signed-off-by: Brad Fitzpatrick <[email protected]>
2026-11-10 10:17:13 -08:00
kari-ts f6eb3f9dc7 ipn, feature/guivisibility: send incremental gui visibility updates (#22067)
This moves HiddenNetworkDvice policy out of ipnlocal and into an optional ipnext.
This adds a per-session notification hook that uses each watcher's effective policy snapshot to populate NodeGUIVisibility.
A full visibility snapshot is sent on initialization and policy changes, and on subsequent peer updates, only changed peers are evaluated.
The extension populates Notify.NodeGUIVisibility with the hidden peers
among the nodes the Notify covers: all peers when it carries Policy
(initially and on policy change), or the PeersChanged peers otherwise.
Absent means visible, so a Policy-bearing Notify replaces the client's
visibility state and a peer-change Notify updates only the changed peers.
No NodeGUIVisibilityChanges/Removed fields and no per-session node state
are needed: removed peers simply leave the client's peer set, and full
netmap updates already resend every peer alongside SelfChange.

When the feature isn't linked, the hook slice is empty and the fast path
in notifyForSessionLocked is unchanged. When the policy isn't configured,
the hook costs a snapshot lookup per session per Notify and sends nothing.

Updates tailscale/corp#44104

Signed-off-by: kari <[email protected]>
Signed-off-by: Nick Khyl <[email protected]>
2026-11-10 10:05:32 -08:00
chaosinthecrd 408f0d2b36 ipn,feature/acme,client/local: add tests for the cert-status localapi endpoint
Tests that the localapi cert-status/ handler checks read access and returns
the status as JSON, that LocalBackend.CertStatus goes through the hook, and
that feature/acme's hook reports the same missing, valid and expired results
as the C2N /tls-cert-status handler. Also tests that Client.CertStatus
returns ErrCertStatusUnsupported for a 404 and not for other errors.

Updates tailscale/corp#38175

Signed-off-by: chaosinthecrd <[email protected]>
2026-11-10 17:37:53 +00:00
chaosinthecrd a986bbfac2 ipn,feature/acme,client/local: add a read-only cert-status localapi endpoint
The localapi cert/ endpoint fetches a cert when none is cached, so polling it
triggers issuance. feature/acme can already report a cached cert without
contacting the CA, but only over the C2N /tls-cert-status path. This moves
that check into an extension method and serves it as localapi cert-status/,
with a matching Client.CertStatus, reporting Missing on a cache miss instead
of issuing. Client.CertStatus returns ErrCertStatusUnsupported (wrapping
errors.ErrUnsupported) when tailscaled has no cert-status endpoint.

Updates tailscale/corp#38175

Signed-off-by: chaosinthecrd <[email protected]>
2026-11-10 17:37:53 +00:00
Brad Fitzpatrick 444baf1ef5 ipn: make ServeConfig.IsFunnelOn false in ts_omit_serve builds
Funnel can't be on without serve. With the HasServe check, the
compiler reduces the method to a constant and inlines it, so the
linker drops it from those builds.

Updates #22283

Change-Id: Idd5da9c1e4f8f41a828a3774f5c4d44872eb1dda
Signed-off-by: Brad Fitzpatrick <[email protected]>
2026-11-10 07:24:48 -08:00
Fredrik Fornwall b9d5ff3ae7 ipn/ipnlocal: don't apply netmap from a replaced control client
setControlClientStatusLocked releases b.mu around tkaSyncIfNeeded. If
Logout replaced the control client meanwhile, the old client's netmap
was applied to the new profile, leaving it Stopped with the old IPs.

Fixes #22274

Change-Id: If4e9fdd5477db7f97b0362c5632c280dba4c18f5
Signed-off-by: Fredrik Fornwall <[email protected]>
2026-11-10 07:10:18 -08:00
Brad Fitzpatrick d566ac8ac9 ipn/ipnlocal, feature/acme: fix ts_omit_serve build with acme
feature/acme uses LocalBackend.ServeConfig to find hostnames needing
cert refresh, which broke builds with ts_omit_serve but not
ts_omit_acme. The serveConfig field it reads exists in all builds, so
move the method out of the serve-only file rather than making acme
depend on serve, and skip the refresh loop hook when serve is omitted
so the linker can drop it.

Updates #22283

Change-Id: I2cef6683cd6e6144306ddec95255d606f7a539ae
Signed-off-by: Brad Fitzpatrick <[email protected]>
2026-11-09 16:12:07 -08:00
kari-ts 211f737bb4 ipn/ipnlocal: add shared login bootstrap orchestration (#21857)
Apple and Android both implement their own login orchestration, coordinating preference updates, backend startup, and interative login. This requires the clients to understand details about the backend lifecycle and has led to duplicated logic and ordering issues.

Android needs to avoid setting WantRunning=true via EditPrefs before calling Start, because doing so triggers Login on the existing control client, which Start then tears down, potentially canceling an in-flight registration before an authentication URL is returned (see https://github.com/tailscale/tailscale-android/commit/83057865e13b8f116a0871a3c6d6adf46f5c3d32). Apple has similar orchestration, including separate handling for auth keys, custom control servers, and reauth.

This adds a LocalBackend helper that accepts optional masked prefs and an auth key, prepares the desired startup prefs, and initiates or resumes auth. This avoids unnecessary control client resets, preserves the existing control client and auth url when the login configuration hasn't changed, and ensures WantRunning is applied as part of Start when restarting the backend. This can be used for:
-first time login with a custom control url or auth key
-resuming an existing interactive login without losing auth url
-retrying login without unnecessarily resetting the control client
-reauth without restarting the backend

A followup will expose this through localapi.

Updates tailscale/tailscale#18304

Signed-off-by: kari-ts <[email protected]>
2026-11-09 11:34:27 -08:00
Aditya Merchant c38365bcff ipn/ipnlocal: don't follow symlinks out of served directories (#22215)
When a Serve or Funnel handler serves a path, serveFileOrDirectory
used os.Stat and os.Open on it, and http.FileServer(http.Dir(dir)) for
a directory. All of these follow symlinks, so a symlink in place of a
served file or directory, or inside a served directory, could make
tailscaled serve any file it can read from elsewhere on the host.
Those directories may be writable by local users who can't configure
Serve, and a symlink placed there is followed at request time.

Resolve the configured path through an os.Root of its parent
directory, and serve a directory through an os.Root of its own.
os.Root refuses symlinks whose target leaves the root, and absolute
symlinks, and still follows relative symlinks that stay inside it. A
refused path inside a served directory is reported as not found, like
a missing file. A refused configured path is logged and reported as a
server error, like other errors reading it.

This changes behavior for setups that serve such symlinks on purpose,
including absolute symlinks and Windows junctions: a configured file
or directory that is one, or that points out of its parent directory,
now fails, and such links inside a served directory now return 404.
Symlinks higher up the configured path are still followed, and a
filesystem root can still be served. Opening the parent directory
needs read permission on it, where os.Stat only needed search
permission. Hardlinks are not covered, since os.Root can't tell them
apart from regular files.

RELNOTE: tailscale serve stops following symlinks out of served directories

Updates tailscale/corp#51116

Signed-off-by: Aditya Merchant <[email protected]>
2026-11-09 12:15:34 -07:00
Fredrik Fornwall 62d055f4c3 ipn/ipnlocal: skip log directory lookup when logtail is omitted
Avoid a startup panic when no log directory is available and the
sockstat logger is disabled by ts_omit_logtail.

Fixes #22246

Change-Id: I06efea76cdaf6cda4b454dbede8cf2e69bbd588d
Signed-off-by: Fredrik Fornwall <[email protected]>
2026-11-08 15:27:51 -08:00
Nick Khyl b31eb1c9bc ipn/ipnlocal,ipn/localapi: fix flaky TestResumeIPNBus
The test resumed a live session, so notifications already
on the wire (notably, spurious health change notifications)
could arrive ahead of the initial status.

In this PR, we add LocalBackend.SuspendWatchNotifications,
which suspends a session as if it had fallen behind,
and update the test to suspend the session and drain
pending notifications before resuming it.

Updates tailscale/corp#51067
Updates tailscale/corp#50256
Updates tailscale/corp#50907

Signed-off-by: Nick Khyl <[email protected]>
2026-11-06 19:31:20 -08:00
Nick Khyl b706df603a ipn,client/local: let IPN bus watchers be suspended instead of disconnected
Since edcc2c94, tailscaled closes the watch when a subscriber falls
behind. That doesn't work well for GUIs where closing the watch has side
effects. On Windows, the last client disconnecting can reset the backend
state unless unattended or always-on mode is enabled. On Android and
Apple platforms, nothing restarts a watch that ended this way, so the
UI silently stops updating.

Add ipn.NotifySuspendWhenBehind. A watcher that sets it stays connected
when it falls behind, but gets a Notify with Suspended set and nothing
else until the client resumes the session via the new resume-ipn-bus
LocalAPI endpoint or LocalBackend.ResumeWatchNotifications. Resuming
replays the initial Notify and new notifications follow from there.

Updates tailscale/corp#51067
Updates tailscale/corp#50256
Updates tailscale/corp#50907

Signed-off-by: Nick Khyl <[email protected]>
2026-11-06 14:33:01 -08:00
Brendan Creane e906e6934d ipn/ipnlocal: resolve exit node when it arrives by netmap delta (#22184)
Since aa5da2e5f, a peer that control adds to a running client arrives as a
netmap delta rather than a full netmap. The delta path never re-resolved
the exit node prefs. An exit node selected by IP before it was in the
netmap stayed unresolved, and an auto exit node stayed on the blackhole
route, until tailscaled restarted or a full netmap arrived.

Re-resolve the exit node in UpdateNetmapDelta when the delta can change
the result. Any upserted peer qualifies while an ExitNodeIP is set. An
exit node being upserted or coming online qualifies while an auto exit
node is unresolved. The selected auto exit node going offline, losing its
exit routes, or being removed qualifies once one is selected. The last
case replaces the separate offline check, so the exit node is resolved
once per delta. The auto exit node check walks every peer, so it only
runs in those cases.

On the delta path, the resolved prefs ride in the same Notify as the peer
changes, sent while b.mu is held. resolveExitNodeLocked no longer sends a
Notify; its callers do. The full-netmap path still sends the prefs in a
separate Notify after the netmap.

Fixes #22012
Updates #22206

Signed-off-by: Brendan Creane <[email protected]>
2026-11-05 16:28:01 -08:00
alexcastgonz 01fa3caf30 ipn/ipnlocal: fix redirect for nested directories in serve (#22118)
ipn/ipnlocal: resolve serve file redirects against the request path

http.FileServer sends a Location relative to the request URL, such as
"nested/" or "../file". fixLocationHeaderResponseWriter prefixed that
value with the mount point, which dropped every directory between the
mount point and the target. A request for /doc/subdir/nested was
redirected to /doc/nested/.

Resolve the relative Location against the original request path
instead. Collapse leading slashes in the result so a request path like
//host/dir cannot produce a protocol-relative Location.

Fixes #22049

Signed-off-by: Alex Castillo González <[email protected]>
2026-11-05 11:14:35 -08:00
Brendan Creane ae6c916f0f ipn/ipnlocal: normalize the serve hostname before the config lookup (#22141)
Serve looked up its config with the name exactly as the client sent
it. Config keys are lowercase with no trailing dot, so a plain HTTP
request for "svelte.example.ts.net." or "Svelte.Example.TS.net" got a
404. HTTPS had the same gap for case. TLS rejects a trailing dot in
SNI but does not lowercase it, so a client that sent mixed-case SNI
failed the handshake with "no webserver configured". Browsers and curl
lowercase the hostname before connecting, which hid that path.

Lowercase the name and trim the trailing dot in both branches of
getServeHandler, and lowercase the SNI in the cert callback.

Fixes #21538
Fixes #21986

Signed-off-by: Brendan Creane <[email protected]>
2026-11-05 08:32:05 -08:00
Brendan Creane e7f595b491 ipn/ipnserver, ipn/localapi: require root to serve a path or Unix socket
The operator user could serve a path or Unix socket if tailscaled
found a sudo rule for them, but the check used the GECOS display name
and so failed for most users with a 401. The check cannot be repaired
safely: listing another user's sudo rules never prompts, so it proves
a rule exists, not that the user has authenticated. An operator who
had not entered their sudo password could serve any root-readable file
or root-only socket. Require root instead and say so in the error.

Fixes #21204
Fixes #21985
Fixes #21988

Signed-off-by: Brendan Creane <[email protected]>
2026-11-03 14:39:07 -08:00
Naman Sood d8eae46481 appc,feature/conn25,tailcfg: read conn25 config from non-experimental nodeattr
Updates tailscale/corp#39984.

Signed-off-by: Naman Sood <[email protected]>
2026-11-03 12:30:26 -05:00
Claus Lensbøl f8358c7f3b ipn/ipnlocal: remove wireguard peers on profile switch (#22150)
Remove old unusable peers from the WG config after a profile switch.

Updates #22149

Signed-off-by: Claus Lensbøl <[email protected]>
2026-11-02 18:04:50 -05:00
Andrew Dunham e19eb275ea ipn/ipnlocal,cmd/tsnet-proxy: strip underscore variants of identity headers (#22143)
Serve deletes client-supplied `Tailscale-User-Login` (and similar) headers
before setting its own. However, `http.Header.Del` only matches the exact
canonical name. A client could send Tailscale_User_Login instead, which
was passed through to the backend.

For Go (and some other) backends, that's not an issue, but backends that
map headers to CGI-style variables (HTTP_TAILSCALE_USER_LOGIN) treat
both names the same.  Thus, for Funnel requests (or tagged nodes), where
serve sets no identity headers, the backend could trust the spoofed
value. The same applies to Tailscale-App-Capabilities.

This fixes the issue by also deleting any header whose name matches
case-insensitively after replacing '_' with '-'.

This is similar to how other projects do this:
- Django drops them: https://www.djangoproject.com/weblog/2015/jan/13/security/
- nginx does not allow them by default: https://nginx.org/en/docs/http/ngx_http_core_module.html#underscores_in_headers
- Puma had a CVE and now drops them: https://nvd.nist.gov/vuln/detail/cve-2024-45614

Fixes tailscale/corp#50821

Signed-off-by: Andrew Dunham <[email protected]>
2026-11-02 16:42:36 -05:00
Brendan CreaneandSam Jean f3b80645fb ipn/ipnlocal: enable full duplex in the serve reverse proxy (#22116)
Go's HTTP/1 server closes the request body once the handler starts
writing the response. The proxy's Transport may still be reading that
body, and when its final read fails it closes the backend connection
under the response it is copying. The client gets a truncated response.

Fixes #21894

Signed-off-by: Brendan Creane <[email protected]>
Co-authored-by: Sam Jean <[email protected]>
2026-11-02 09:13:00 -08:00
Adriano Sela Aviles 5cf2727225 control,ipn: add Tailnet hint for device registration
Add an ipn.Prefs.Tailnet field, passed through controlclient.Options
into tailcfg.RegisterRequest.Tailnet, so a client can recommend or
require a tailnet at registration (e.g. to skip the tailnet picker when
the intent is already known) without impersonating MDM.

Previously this value could only come from the "Tailnet" syspolicy
setting. That setting still takes precedence as an administrative
override; the prefs value is used only when no policy is set.

Updates #22093

Signed-off-by: Adriano Sela Aviles <[email protected]>
2026-11-02 09:22:43 -07:00
Jaron Kramer 6c6dd62b60 ipn/store/kubestore: omit ARI replaces for unstamped shared certs (#22053)
A retained legacy cert may have been issued by a different account even when no pre-adoption local key is available. Require a matching fingerprint before claiming a shared-account renewal replaces it.

Fixes #22041

Signed-off-by: Jaron Kramer <[email protected]>
2026-10-31 11:43:17 +00:00
Claus Lensbøl 2c7aeadb1d ipn/ipnlocal,wgengine{,/magicsock}: cleanup TSMP disco logs (#22088)
Logging is quite aggressive and most of the logs can be hidden behind
component logging. A few logs are instead gated on if they changed or if
the original state was zero.

Updates #cleanup

Signed-off-by: Claus Lensbøl <[email protected]>
2026-10-30 11:08:15 -04:00
Adrian Dewhurst 7304dd42c1 feature/conn25, ipn/ipnlocal: use the new net/routelimits package for blocking host-scoped destinations
Similar to #20866 for 4via6, conn25 needs to block host-scoped
destinations. Due to the similarity between the two situations, the
matching is no longer in a 4via6-specific location. Since there is no
backwards compatibility to satisfy, there is no exception list for
conn25.

ipn/ipnlocal (for 4via6) and feature/conn25 now both use the new
package.

Updates tailscale/corp#50118
Updates tailscale/corp#46169

Change-Id: Ic3f9cccd2f5823a2ca48bd78607792b0fd6d7db9
Signed-off-by: Adrian Dewhurst <[email protected]>
2026-10-29 13:57:37 -04:00
James Tucker 7ad13349f1 ipn/ipnlocal: randomize DNS query IDs
Allocate a fresh 16-bit ID for each QueryDNS request instead of using the
constant ID 1.

Updates tailscale/corp#48187

Change-Id: I9b47a3fbbef70f0462f1da4f3b29eb77cf31f9f0
Signed-off-by: James Tucker <[email protected]>
2026-10-29 08:53:10 -07:00
James Tucker 7623e71e9c ipn/ipnlocal,ipn/localapi: propagate context through DNS queries
Accept a caller context in LocalBackend.QueryDNS and pass it to the
internal resolver. Use the HTTP request context for localapi DNS queries
so cancellation and deadlines bound the lookup.

Updates #8338

Change-Id: I1bb8ec0b779c883ec40d52063adf25ff36cf43e3
Signed-off-by: James Tucker <[email protected]>
2026-10-29 08:52:50 -07:00
Sam JeanandJames Tucker 3a38840ccc ipn/ipnlocal: check the tailscaled socket on every serve unix dial
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 <[email protected]>
Signed-off-by: Sam Jean <[email protected]>
Signed-off-by: James Tucker <[email protected]>
2026-10-27 13:08:08 -07:00
kari-ts 822061d89c ipn/ipnlocal: reset alwayson override before reconciling prefs (#21998)
https://github.com/tailscale/tailscale/commit/09982e1918f27c740320a4879bbafdd9f379733a
introduced an alwayson override reset before applying policy settings
during Start.
A prefs reconciliation refactor in
https://github.com/tailscale/tailscale/commit/cb7b49941eae3a933c4c5b7dc56398bce24d7e08
changed the ordering so that Start reconciled prefs before clearing the
override. If the user disconnected with a reason, reconciliation would
preserve WantRunning=false, and Start could retain that stale value
after the override was cleared.
https://github.com/tailscale/tailscale/commit/f4aea70f7a199e5ac155e225fe7ad4de374e9dea
added cached netmap startup, so processing the cached netmap can
reconcile the current prefs to WantRunning=true while Start still holds
a local prefs snapshot with WantRunning=false. Start can then notify the
frontend with the stale value even though the backend is transitioning
to Running with WantRunning=true.

This resets the alwayson override before reconciling prefs, restoring
the original Start ordering and ensuring that the prefs used throughout
Start reflect the effective alwayson policy

Updates tailscale/corp#44094
Updates tailscale/corp#44095

Signed-off-by: kari <[email protected]>
2026-10-27 12:42:35 -07:00
Sam Jean 713be260c3 ipn/ipnlocal: refuse serving TCP to the tailscaled socket (#21966)
tailscale serve --tcp=<port> unix:<path> dialed the target socket with
no check, so pointing it at tailscaled's own LocalAPI socket proxied a
tailnet peer straight into the LocalAPI. The LocalAPI authorizes a
unix-socket caller by the peer credentials of the dialing process --
tailscaled itself, as root -- so the peer got a write-capable LocalAPI
and could change the node's settings.

The HTTP proxy path already refused this via isTailscaledSocket; the
TCP-forward path, added later, did not. Reject it at config-set time in
setServeConfigLocked so "tailscale serve" fails up front, and keep a
dial-site guard returning ErrProxyToTailscaledSocket as a backstop for
configs set by other means.

RELNOTE: tailscale serve no longer proxies to tailscaled's own socket

Fixes tailscale/corp#50425

Change-Id: I5ed02e83d32bdfb09c8164907bf38cabcc406169

Signed-off-by: Sam Jean <[email protected]>
2026-10-26 21:52:39 -03:00
James Tucker a1e51f4942 tsnet: authorize ListenSSH peers, fix PTY emulation and session queue bound
ListenSSH now documents its session trust model and takes an
authorization callback. A session is accepted from any peer that the
tailnet ACL's TCP rules allow and that resolves with WhoIs. The server
performs no SSH client authentication, does not map the peer to a local
user, and does not record the session. The application is responsible
for what each session does. Set Server.SSHAuthCallback to reject
unwanted sessions before they reach Accept. A rejected session is
refused at open with exit status 1 and is never yielded to Accept. The
callback is plumbed through LocalBackend.ListenSSH and HookListenSSH.
With no callback, behavior is unchanged.

The listener's SSH server runs session channels only, with no port
forwarding. Closing the listener closes the accepted connections.

- DisablePTYEmulation runs on every session, so a PTY session passes
  data through unchanged instead of translating "\n" to "\r\n". The
  translation corrupted binary data read through the net.Conn
  interface. Window changes are drained for every session, even when
  the application never calls Pty, because gliderssh writes window
  changes from the session request loop and an undrained channel
  blocks the session's requests. Pty drops window changes when the
  application is not reading them.

- The handshake is bounded by TS_SSH_LOGIN_GRACE_TIME, default 120
  seconds, the same as sshd's LoginGraceTime.

- TS_SSH_IDLE_TIMEOUT bounds connections with no SSH traffic. It is 0
  by default, and zero applies no bound, so quiet but live sessions
  are not closed by default. Both timeout knobs accept a Go duration
  such as "90s" or a bare number of seconds.

- Accepted sessions wait for Accept in a bounded queue. When the queue
  is full, further sessions are refused, so an application that stops
  calling Accept parks only a bounded number of sessions.

Updates tailscale/corp#50380

Signed-off-by: James Tucker <[email protected]>
2026-10-25 11:31:39 -07:00
Mike Jensen 566f89e0fb ipn/ipnlocal: fix serve app caps leaking across mounts (#21931)
`serveWebHandler` wrote each mount's accepted app capabilities into the connection-scoped serveHTTPContext. Concurrent h2 streams of one TLS serve connection share that struct, so a request to a mount accepting no capabilities could be proxied carrying another mount's `Tailscale-App-Capabilities` header, letting backends that trust the header authorize the wrong mount.

This change fixes that issue by storing accepted capabilities per-request via a context value instead of a field on the shared struct.

Updates tailscale/corp#50380

Change-Id: I5d0a4a02266018f342ba75a1b3291176738ce05b

Signed-off-by: Mike Jensen <[email protected]>
2026-10-24 18:39:53 -06:00
kari-ts 00650c0b3b ipn, ipn/local: expose hidden device gui gui_visibility (#21822)
This interprets HiddenNetworkDevices per watch session and sends GUI visibility metadata for peers (without filtering them). We refresh the visibility snapshot when policy or peer membership changes.

Updates tailscale/corp#44104

Signed-off-by: kari-ts <[email protected]>
2026-10-23 11:45:38 -07:00
Michael Ben-Ami e310c02787 ipn/ipnext: add NodeBackend.NodeBy{Addr,ID}
The immediate use case is feature/conn25 identifying the connector peer
node that responds to a DoH request.

Updates tailscale/corp#46169

Signed-off-by: Michael Ben-Ami <[email protected]>
2026-10-16 12:45:54 -04:00
chaosinthecrd e915ebc42a control/controlclient,ipn/ipnlocal,tstest/integration: test node removal
Adds tests that only a 404 map response wraps ErrNodeRemoved, that the
node-removed warning and NeedsLogin state are cleared by a new netmap or
a profile switch, and that a node restarted after it was deleted shows
the warning and reaches NeedsLogin.

Updates #18700

Signed-off-by: chaosinthecrd <[email protected]>
2026-10-16 16:40:31 +01:00
chaosinthecrd 0f3c767d17 control/controlclient,ipn/ipnlocal,tsconst: go to NeedsLogin on node removal
When a node is deleted, control answers its map requests with a 404 and
the client keeps retrying in its current state, so watchers like
containerboot can't tell a deleted node from a lost connection. This
wraps that error in ErrNodeRemoved, and LocalBackend then moves to
NeedsLogin and sets a node-removed health warning, both cleared on the
next netmap or profile switch. It repurposes #18701 as a stopgap until a
broader fix, such as structured errors from control, exists.

Updates #18700

Signed-off-by: chaosinthecrd <[email protected]>
2026-10-16 16:40:31 +01:00
Jonathan Nobels 5cc8aa7f07 net/dns: flush stale MagicDNS NXDOMAINs on Apple platforms (#21584)
Updates tailscale/corp#49775

Track authoritative NXDOMAINs for at least 60 seconds on macOS and iOS (where our short SOA ttls are not properly respected), and flush when a cached name becomes resolvable. Compile a no-op tracker elsewhere and avoid duplicate VPN reconfiguration on link changes.
2026-10-13 15:48:31 -04:00
Brendan Creane 4f86936ef0 ipn/ipnlocal: resolve auto exit node on first netcheck report (#21775)
On a fresh install the first netmap arrives before the first netcheck
report, so auto exit node resolution installed the blackhole
ipn.UnresolvedExitNodeID and nothing re-resolved it once the report
arrived. Refresh in setNetInfo while the exit node is still unresolved.

Fixes #18199

Signed-off-by: Brendan Creane <[email protected]>
2026-10-13 10:24:12 -07:00
Brad Fitzpatrick 0a1eb8c4da ipn/ipnlocal: don't answer single-label names from quad-100
Since 7e609b258 (v1.102), quad-100 looks up MagicDNS names in
nodeBackend.nodeByName, which also holds short-name keys for in-process
dials. So a query for "foo." matched peer "foo.tail-scale.ts.net" and
was answered with its Tailscale IP. 1ec348784 fixed that for MagicDNS
off; this fixes it for MagicDNS on, too, matching pre-1.102 behavior.
The OS applies the search domain to short names before they reach
quad-100, so a single-label query is a root zone name, not a tailnet
name, and must be forwarded (e.g. to LAN mDNS/LLMNR or a global
nameserver). Short names still work for in-process dials via
NodeByName.

Updates #20789

Signed-off-by: Brad Fitzpatrick <[email protected]>
Change-Id: Ic8199a96cf79178210c9a85e0cebfb46567a894a
2026-10-09 11:01:40 -07:00
Alex Valiushko 76648a00fd net/tstun: implement independent injection queue (#21681)
Injected packets now arrive on a queue of their own rather than being
multiplexed onto queue 0. Wrapper.Read is deprecated. It still reads the
first kernel-backed queue, but from now on no single queue of a Wrapper
sees every packet.

Deletes the poll goroutine, the bufferConsumed token, the vectorOutbound
channel, tunVectorReadResult, a full-size slab, and the copy of every
accepted packet between the two slabs.

wireguard-go now runs an extra TUN reader goroutine, a net wash compared
to running our poll routine.

Measured on c8gn.2xlarge, Ubuntu 24.04, Kernel v6.14, tailscaled under
load from two peers, each running iperf3 -P8.

            tx mean   rx mean   cores
  main       7.00      8.84      3.49
  branch     8.94      8.86      3.95

Bumps wireguard-go pin to tailscale/wireguard-go@e61b6b7811.

Updates tailscale/corp#37878

Change-Id: Ide0e8a9f345371b2747fad59dd2bf963c8af5b63

Signed-off-by: Alex Valiushko <[email protected]>
2026-10-08 13:13:11 -07:00
kari-ts a89b32904f ipn/localapi: use caller scope for syspolicy requests (#21701)
This resolves unscoped policy requests to the connected user's effective
policy instead of the default scope.

Tested by changing the device-scoped AlwaysOn policy at runtime and
running tailscale syspolicy reload. Cofnirmed tailscaled immediately
enforced the updated policy with tailscale down

Updates tailscale/corp#41463

Signed-off-by: kari <[email protected]>
2026-10-08 08:35:14 -07:00
kari-ts a5ae05dd9d ipn/ipnlocal: use session user for policy change notifications (#21699)
This fetches the effective policy snapshot for the user scope instead of
using the default policy scope, ensuring that policy change
notifications reflect the correct user-scoped effective policy.

Updates tailscale/corp#41463t

Signed-off-by: kari <[email protected]>
2026-10-07 19:01:49 -07:00
Brad Fitzpatrick 2a61a720e5 ipn/ipnlocal: drop the appc import from ts_omit_appconnectors builds
LocalBackend named appc.AppConnector in its appConnector field, in the
field's constructor call, and in the AppConnector accessor, so even
builds with ts_omit_appconnectors linked the appc package and its
dependencies. The buildfeatures.HasAppConnectors checks let the linker
drop the code but could not remove the import.

Add a build-tag-gated type for the field: appcAppConnector is an alias
for appc.AppConnector by default, and in ts_omit_appconnectors builds it
is an empty struct with no-op versions of the methods local.go calls, so
the shared code still type checks. The constructor call moves behind a
newAppConnector helper in the same gated file, and the AppConnector
accessor keeps its *appc.AppConnector signature there, with a nil-
returning version in the omitted build.

This takes tailscale.com/appc out of depaware-min.txt and
depaware-minbox.txt. Add a DepChecker test to keep it out; it also sets
ts_omit_conn25, since conn25 uses appc as well.

Updates #12614

Signed-off-by: Brad Fitzpatrick <[email protected]>
Change-Id: Ia7e2d9c4f1b8e6a3d5c0f2b7e9a1c4d6f8b0e2a5
2026-10-06 13:12:00 -07:00
Brendan Creane edf8abd69e ipn/conffile: reject null services and endpoints in Services config files (#21647)
A JSON null for a service or for an endpoint target unmarshals as a nil
pointer, and loadConfigV0 dereferenced it without a check. This made
"tailscale serve set-config" panic. Return an error that names the
service or endpoint instead.

Fixes #21534

Signed-off-by: Brendan Creane <[email protected]>
2026-10-05 12:29:40 -07:00
Brad Fitzpatrick 92a64b306d ipn/{ipnext,ipnlocal},feature/conn25: add ExtraDNSRoutes hook for conn25 split DNS
dnsConfigForNetmap called appc.AppDNSRoutes directly to synthesize the
conn25 split DNS routes from the self node's capability map, which was
the one place node_backend.go depended on the appc package and was
marked with a TODO to make it a hook.

Add ipnext.Hooks.ExtraDNSRoutes, which returns extension-supplied split
DNS routes. authReconfigLocked calls it and passes the result into
dnsConfigForNetmap, which adds the routes alongside the netmap's own
routes with the same UseWithExitNode handling as before.

The hook takes no arguments: the conn25 extension computes the routes
in its OnSelfChange handler and clears them on a switch to a different
node, and it already tracks the AppConnector.Advertise pref from
ProfileStateChange. Both of those hooks fire before the reconfig that
consults ExtraDNSRoutes, so the state is current. The conditions are
unchanged: no routes when this node itself advertises as an app
connector, and none without the experimental capability.

Updates tailscale/corp#37125

Signed-off-by: Brad Fitzpatrick <[email protected]>
Change-Id: I6c2e9f4b8a1d3e7f5c0b2a9d8e6f4c3b1a7d5e9f
2026-10-05 10:14:23 -07:00
Alex Chan 9128778b65 types/key: rename NLPublic/Private to TLPublic/Private
The NL prefix is one of the last references to the "Network Lock" name
which we're cleaning up.

Updates tailscale/corp#37904

Change-Id: I751194e0b49447e97a65ed6975e3da680226ce85
Signed-off-by: Alex Chan <[email protected]>
2026-10-02 16:03:51 +01:00
Jonathan Nobels d8c7cafeda feature/exitnodehealth: warn when selected exit nodes are unavailable (#21017)
updates tailscale/corp#33007

When a selected exit node can't carry internet traffic due to a misconfiguration (wrong ID, node
deleted, routes removed, etc), blackhole default routes are installed and all internet traffic is dropped.
That is the correct behavior -- better to drop than leak to the local network -- but it was entirely silent:
the stable-ID lookup in nodeBackend.updateRouteManagerPrefs misses without a log line, and Status
leaves ExitNodeStatus nil. The user sees a healthy Tailscale with no internet. If an admin fat-fingers the
exit node name in an IT policy, for example, it's easy to break every node with zero feedback.

This adds an exit-node-unavailable health warning covering every way the selection can fail to carry
traffic (short of reachability which is a separate concern), reported via exitnodehealth.ArgExitNodeReason.

The warning names the exit node, caching its display name while it is still a peer so the name survives
its departure, and falls back to the stable ID or IP. When the selection is mandated by the ExitNodeID
or ExitNodeIP policy settings, the message tells the user to contact their network administrator instead
of suggesting they pick another exit node.

To test this, set a forced exit node policy with some random ip or node id. The warning has a 5 second
 threshold. It should clear as soon as you change to a proper exit node.

Signed-off-by: Jonathan Nobels <[email protected]>
2026-10-01 08:57:20 -04:00
Brad Fitzpatrick 5d5607fea2 ipn/ipnlocal: use more buildfeatures consts so the linker drops dead code
Several features with ts_omit build tags were still linked into
minimal builds because LocalBackend called into them unconditionally,
so the linker couldn't prove them unreachable. Guard those call sites
with their buildfeatures constants:

  * app connectors: only subscribe to route update and store events
    when app connectors are included; appc is their only publisher.
    This also drops AdvertiseRoute and UnadvertiseRoute.
  * client update: only subscribe to the tailnet default auto-update
    event when auto-updates are supported, as that's all it affects.
  * syspolicy: only register the policy change watch when system
    policy support is included.
  * advertise routes and exit nodes: only validate AdvertiseRoutes
    when one of the two features is included.
  * netstack: only netstack consults the intercepted TCP ports, so
    don't build the port matching func without it.
  * ssh: don't check SSH prefs, report the "SSH on but unusable"
    health message, or intercept port 22 without SSH support. The
    RunSSH pref is still accepted without effect, as before; port 22
    was previously intercepted by netstack builds without SSH.
  * web client: don't track whether the web client should run when
    it's not included.
  * tailnet lock: peers marked UnsignedPeerAPIOnly are only special
    in that tailnet lock skips their signature checks, and the packet
    filter check guards that exemption. Without tailnet lock, all
    peers from control are trusted anyway, so skip the check.

This reduces the size of a build_dist.sh --min tailscaled binary on
linux/amd64 by 65,536 bytes (0.5%), about 28 KB of it in ipnlocal and
most of the rest in eventbus and slices generic instantiations for the
events no longer subscribed to.

Updates #12614

Signed-off-by: Brad Fitzpatrick <[email protected]>
Change-Id: I8f4d4c0779e84f46f3b076d0fb35514c69a52d8f
2026-09-30 18:34:57 -07:00
Kristoffer Dalby cf7d4c6015 ipn/ipnlocal: report peers dropped by a full netmap as PeersRemoved
Peer-change watchers upsert PeersChanged, so peers missing from a full
netmap were never removed from their view.

Updates #15660

Signed-off-by: Kristoffer Dalby <[email protected]>
2026-09-29 19:23:51 +02:00
Kristoffer Dalby c4a66d1ce1 ipn/ipnlocal, tstest/largetailnet: test removals bundled with full netmaps
A peer removal sent with any MapResponse field that forces a full netmap
rebuild never reaches IPN bus watchers; these tests fail.

Updates #15660

Signed-off-by: Kristoffer Dalby <[email protected]>
2026-09-29 19:23:51 +02:00