Commit Graph
2270 Commits
Author SHA1 Message Date
David Anderson f4336907aa ipn: configure hybrid handshakes for peers that support it
Updates tailscale/corp#50068

Signed-off-by: David Anderson <[email protected]>
Change-Id: Ibebab03c31b3fceba83af28d72ddecd26a6a6964
2026-11-17 13:27:24 -07:00
Fran Bull f3a3382791 feature/routecheck,ipn,net/routecheck,tailcfg: Probe conn25 connectors
Add conn25 connectors to the targets for routecheck probing. Enables
conn25 clients to use the routecheck report to help decide which
connector to use.

Updates tailscale/corp#47251

Signed-off-by: Fran Bull <[email protected]>
2026-11-17 10:40:12 -08:00
Nick Khyl 13af579d64 ipn/ipnlocal: resend UserProfiles to IPN bus watchers after a profile change
A watch session's UserProfiles dedup state was only reset when the
self node delivered to it changed, as of c9fb05b6f5. Switching to
a profile that never gets a self node, such as a stopped or logged
out one, and back delivered the same self node again, so the profiles
were not resent to watchers that had dropped them on the switch. The
Windows GUI then listed no tagged or other users' devices.

Reset the dedup state on a profile change as well.

Updates #19889
Updates tailscale/corp#51597

Signed-off-by: Nick Khyl <[email protected]>
2026-11-16 18:54:54 -08:00
Brad Fitzpatrick 99b389db5e ipn/ipnlocal: don't abandon netmap delta batches on unknown peers
nodeBackend.UpdateNetmapDelta returned false on a per-field patch for a
peer it didn't have, such as one filtered out by tailnet lock, dropping
the batch's remaining patches. LocalBackend ignored the result and
reported success, so controlclient never sent a full netmap, and its
peer dedup then hid later updates for those peers. Skip such patches
instead, and return false from LocalBackend if nodeBackend fails.

Updates #22379

Change-Id: I142bd47a89568d0f6c457f0da08601f41609d8f7
Signed-off-by: Brad Fitzpatrick <[email protected]>
2026-11-16 07:48:48 -08:00
Brad Fitzpatrick fe5726935c ipn/ipnlocal: recompute suggested exit node on exit node DERP home deltas
suggestExitNode groups candidates by DERP home region, but a HomeDERP
patch on an exit node other than the current suggestion didn't trigger
a recompute, so the suggestion could stay stale until the next full
netmap.

Updates #22379

Change-Id: Ib0c1dd9bf41fe40eac77fca378015c97fba600d1
Signed-off-by: Brad Fitzpatrick <[email protected]>
2026-11-16 07:47:51 -08:00
Dep Updater 9d5313662a go.mod: bump golang.org/x/sys
* golang.org/x/sys: v0.49.0 to v0.50.0

Triggered by @bradfitz via the bumpdep workflow.

Updates #22390

Change-Id: I402717314704a7f7b164a15e073608ef9dcc31fb
Signed-off-by: Dep Updater <[email protected]>
2026-11-14 09:50:33 -08:00
Joe Tsai 09d54b6ce2 logtail: add support for authenticated log uploads (#20482)
Control via nodecap.LogUploadAuth may notify the node
that there is an authorization token to use when uploading logs.
If specified, then the logtail.Logger will use that token
when uploading.

Unfortunately, there is a time-of-use and time-of-check discrepancy
that complicates logging. When logs are written under the context
of being for a particular node, we cannot store the token,
as it may be invalid by the time that the logs are uploaded.

Instead, we add Logger.SetAuthID to annotate subsequent log entries
with an identifier for the token to later use.
Only when we upload do we strip out the auth ID, lookup the
auth token to use, and then perform the upload.

We assume that control will notify the client of new tokens
well before they expire. Fetching a refreshed token
is not the job of the client.

Updates tailscale/corp#39092

Signed-off-by: Joe Tsai <[email protected]>
2026-11-13 16:01:46 -08:00
Andy TianandClaude Opus 5.5 e0d532cca9 ipn/ipnlocal: don't write a netmap cache without CacheNetworkMaps (#22335)
onHomeDERPUpdateLocked wrote the netmap cache without checking the
CacheNetworkMaps capability, unlike the full netmap and peer delta
paths. On a node without it, each home DERP change recreated a cache
with no peers, and the next start went Running from it before control
sent any peers.

Check the capability before that write. A cache written before this
fix can still be loaded once; the first netmap from control without
the capability then discards it.

Fixes #22334

Change-Id: I2f49a6617e6756e36316605995b171f6d7b3ff28

Signed-off-by: Andy Tian <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
2026-11-13 10:05:07 -05:00
Claus Lensbøl c687660ac5 ipn/ipnlocal{,/netmapcache}: extract file store in prep for new stores (#22266)
The filestore was the only implemented store but we want to be able to
add other stores depending on the platform.

Make space for compiling on more stores, though keep the file store as
the default option.

Updates #22265

Signed-off-by: Claus Lensbøl <[email protected]>
2026-11-13 09:51:10 -05:00
Joe Tsai 59064619a0 ipn/ipnlocal: add stub for LocalBackend.SetLogUploader (#22375)
This is needed for authenticated log uploads (see #20482).
Add a noop declaration now, so that we can call it from
client implementations on other platforms (e.g., Android or iOS).

Updates tailscale/corp#39092

Signed-off-by: Joe Tsai <[email protected]>
2026-11-12 18:00:38 -08:00
Fran Bull 36d2564bd4 ipn/ipnlocal: add hook to peerapi dns response
to allow headers to be added. To enable feature/conn25 to add a header.

Updates tailscale/corp#46169

Signed-off-by: Fran Bull <[email protected]>
2026-11-12 13:49:18 -08:00
Fran Bull e982a66c01 ipn/ipnstate,tailcfg: fix comment
The comment should refer to dbx.Node.IsRouter, not
dbx.Node.IsSubnetRouter.

Updates #cleanup

Signed-off-by: Fran Bull <[email protected]>
2026-11-12 13:24:06 -08:00
kari-ts 7109040a7d ipn/ipnlocal: handle lagging watchers on policy changes (#22313)
This uses the same notification delivery logic for policy changes and regular ipn bus updates. Previously, sysPolicyChangedForSession silnetly dropped policy notifications when a watcher's channel was full, potentially leaving clients with stale policy and gui visibility state. Now lagging watchers follow the existing block, suspend, or close behavior, allowing them to recover the latest policy when they resume or reconnect.

Updates tailscale/corp#44104

Signed-off-by: kari-ts <[email protected]>
2026-11-12 12:58:52 -08:00
yaruk-byte 846e948ff5 tstest/integration: add Windows unattended-mode test coverage (#21876)
Updates #20751

Signed-off-by: Yaruk Asghar <[email protected]>
2026-11-10 18:51:07 -07:00
James Tucker 4ad0fa1bee net,ipn,cmd: migrate dialer hooks to ControlContext
Use ControlContext for production net.Dialer socket hooks:
PeerAPI and debug peer dialing, captive-portal probes, stunstamp TCP
measurements, and the test agent connection.

Update the PeerDialControlFunc callback signature and Apple extension
implementation together with both consumers. Preserve namespace binding,
socket settings, timeout values, and existing error handling. Listener
Control and RawConn.Control are separate APIs and remain unchanged.

Add coverage for platform hook forwarding and errors, debug and captive
portal dialing, cancellation, SO_REUSEADDR, and test-agent hook selection
and keepalive configuration. Cover the Apple missing-interface error and
non-Linux bypass no-op in their platform-specific tests.

Updates tailscale/corp#50948

Change-Id: I4fb162666724f307f2d3d0beba6ed1b0ed15bb4f
Signed-off-by: James Tucker <[email protected]>
2026-11-10 16:47:42 -08:00
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