3021 Commits
Author SHA1 Message Date
Irbe Krumina cc0716a2f8 cmd/k8s-operator: clarify tag requirements (#15757)
Updates tailscale/tailscale#15732

Signed-off-by: Irbe Krumina <[email protected]>
2026-11-19 17:36:17 +00:00
chaosinthecrd 93ba239f2c cmd/k8s-operator: test ProxyGroup StatefulSet Pod management policy
Covers a new ProxyGroup getting a Parallel StatefulSet, and an existing
OrderedReady one being deleted and then recreated as Parallel.

Updates tailscale/corp#38175

Signed-off-by: chaosinthecrd <[email protected]>
2026-11-19 13:17:44 +00:00
chaosinthecrd 1af2fa9eeb cmd/k8s-operator: start ProxyGroup Pods in parallel
With a readiness probe and the default OrderedReady policy, one unready
ProxyGroup Pod stops the rest from starting, so ProxyGroup StatefulSets now
use Parallel. The policy can't change in place, so an existing StatefulSet is
deleted with its Pods orphaned and recreated, adopting them.

Updates tailscale/corp#38175

Signed-off-by: chaosinthecrd <[email protected]>
2026-11-19 13:17:44 +00:00
chaosinthecrd b76d891d98 cmd/k8s-operator,k8s-operator: test proxy liveness and readiness probes
Covers the ProxyClass probe defaults and overrides, the env cases that skip or
move the probes, probes on ProxyGroup proxies, and rejecting probes on the
init container or with an env that leaves the endpoints unreachable.

Updates tailscale/corp#38175

Signed-off-by: chaosinthecrd <[email protected]>
2026-11-19 13:17:44 +00:00
chaosinthecrd 6308edfdce cmd/k8s-operator,k8s-operator: run liveness and readiness probes on ProxyGroups
Proxies now serve /livez and /readyz, but nothing points Kubernetes probes at
them. This adds livenessProbe and readinessProbe fields to the ProxyClass
Tailscale container, each off unless set, with tunable timing (older proxy
images don't serve the endpoints, so a probe would fail against them), and
wires them into ProxyGroup proxies. A ProxyGroup is rejected if its ProxyClass
sets probes but its env would leave the endpoints unreachable, such as
TS_ENABLE_HEALTH_CHECK=false, TS_LOCAL_ADDR_PORT on loopback, or the
deprecated TS_HEALTHCHECK_ADDR_PORT. Probes follow a custom TS_LOCAL_ADDR_PORT
port, and liveness gets a 5s timeout by default, as a restart drops traffic
that a slow tailscaled still carries.

Updates tailscale/corp#38175

Signed-off-by: chaosinthecrd <[email protected]>
2026-11-19 13:17:44 +00:00
chaosinthecrd 6e8f0f40cc cmd/containerboot,kube/{certs,health}: test the /livez and /readyz checks
Covers the Probe handlers and conditions, AllCertsPresent with present,
missing, expired and unreadable certs, and the containerboot checks for
tailscaled failing or timing out, certs for advertised HTTPS-only Services and
a serve config file that doesn't exist.

Updates tailscale/corp#38175

Signed-off-by: chaosinthecrd <[email protected]>
2026-11-19 13:17:44 +00:00
chaosinthecrd b5fa6773ce cmd/containerboot,kube/{certs,health,localclient}: serve /livez and /readyz
Proxies only serve /healthz, which reports whether the node has a tailnet IP,
so it can't back a liveness or readiness probe. When TS_ENABLE_HEALTH_CHECK is
set, containerboot now also serves /livez, which fails only when tailscaled
stops answering LocalAPI, and /readyz, which passes once the node has tailnet
IPs and, with TS_SERVE_CONFIG set, has applied the serve config and has a cert
for each HTTPS-only Tailscale Service it advertises. Certs are checked through
the read-only cert-status endpoint so the probe never triggers issuance. An
expired or unreadable cert counts as present, as failing readiness on it would
stop a StatefulSet rollout before it reaches the replica that renews certs.

Updates tailscale/corp#38175

Signed-off-by: chaosinthecrd <[email protected]>
2026-11-19 13:17:44 +00:00
Mario Minardi ed75aa3c1f various: add auth-exchange-attempts flag to up
Add an optional auth-exchange-attempts flag to up that allows for
controlling the number of attempts made on transient errors (e.g, 5XX or
client-side deadline exceeded errors) during OAuth or workload identity
federation auth exchange operations.

This defaults to 1 (e.g., no retries). Specifying a larger number of
attempts enables retrying the auth exchange with exponential backoff
instead of the default of failing after a single try.

Updates https://github.com/tailscale/tailscale/issues/20339

Signed-off-by: Mario Minardi <[email protected]>
2026-11-18 15:15:43 -07:00
Brad Fitzpatrick 1f36d5a89f feature/linuxdnsfight, go.mod: replace gonotify with direct inotify calls
The resolv.conf watcher needs one watch on one directory and a
blocking read. gonotify v3.0.2 has a bug where it loops forever
without advancing when a record's name length runs past the end of a
read. It also never closes its fd on cancel and allocates 32 KB per
Read. Use x/sys/unix directly, return an error on a malformed record,
and stop when the kernel removes the watch.

Fixes #16576

Signed-off-by: Brad Fitzpatrick <[email protected]>
Change-Id: If2bc5e94f8aab2922ee9e07b3c2b75a76f4f9236
2026-11-18 09:25:28 -08:00
BeckyPauley 53c9d49750 cmd/k8s-operator/e2e: tidy e2e test logging (#22485)
Log which data keys the operator Secret contains when the expected state is
missing.

Discard logs for tsnet.Servers created as part of test setup and during
tests to reduce log noise.

Updates tailscale/corp#34562

Change-Id: I37d730a46304004fb1579350a755bc92cdf46e42

Signed-off-by: Becky Pauley <[email protected]>
2026-11-18 14:15:42 +00:00
David Bond 87edd6b488 cmd/k8s-operator,k8s-operator: truncate long default egress proxy hostnames (#22081)
An egress Service without the tailscale.com/hostname annotation gets the
default proxy hostname <namespace>-<name>. When that hostname exceeds 63
bytes, the operator rejects the Service. This includes ProxyGroup egress
Services, which do not use the hostname.

For egress Services, shorten a default that is too long to a 54-char
prefix and an 8-char hash. Defaults that fit do not change, so no
existing proxy is renamed. Explicit annotations and ingress hostnames
keep the current validation.

Rename TruncateLabelValue to TruncateWithHash, as it now also truncates
hostnames.

Fixes #22080

Change-Id: Ib1589a5e9c750cd37d0641829a84fabd0c4352a7

Signed-off-by: David Bond <[email protected]>
2026-11-18 13:17:36 +00:00
David Bond 2a4186eba7 cmd/k8s-operator: raise the egress ProxyGroup port limit to 20000 (#22209)
This commit widens the egress match port range from [10000, 11000) to
[10000, 30000). The old limit of 1000 ports was arbitrary, and users
with many egress Services reach it. The new range ends below the Linux
ephemeral port range, so match ports do not collide with ports that the
proxy itself uses.

The port count also no longer includes the health check port, which
lowered the real limit by one. A new test covers allocation up to the
limit.

Fixes #22195

Change-Id: Ie20feb2744b40dce052d3732f9f486b1bff31b32

Signed-off-by: David Bond <[email protected]>
2026-11-18 13:17:15 +00:00
Dep Updater a920394089 go.mod: bump gvisor.dev/gvisor
* gvisor.dev/gvisor: https://github.com/google/gvisor/compare/a6f909f08a72...0303b2605d5e

Triggered by @bradfitz via the bumpdep workflow.

Updates #22104

Signed-off-by: Dep Updater <[email protected]>
2026-11-17 13:10:30 -08:00
Jim Wright e232b0a131 client/web,release/dist: move web client from yarn to pnpm (#22464)
Import yarn.lock into pnpm with the same supply-chain settings as
cmd/tsconnect, plus overrides replacing yarn resolutions, two narrow
trustPolicyExclude entries for packages published without provenance,
and denied esbuild/@swc/core install scripts.

Switch assets.go, cmd/build-webclient, release/dist and CI to
tool/pnpm. release/dist now looks up pnpm only when building web
client assets; Build.Yarn is deprecated.

Updates tailscale/corp#51439

Change-Id: Ib472fc8439e916bfe41158e3952f9fa8c02f522d

Signed-off-by: Jim Wright <[email protected]>
2026-11-17 13:07:03 -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
Jim Wright 9123e6e26c cmd/tsconnect: upgrade tsconnect from yarn to pnpm (#22437)
Import yarn.lock to pnpm-workspace.yaml and pnpm-lock.yaml
Add pnpm tool and update references

Fixes tailscale/corp#51437

Change-Id: Ia25017e7e82cf3af13e04fc3c07b82196f211744

Signed-off-by: Jim Wright <[email protected]>
2026-11-17 10:03:01 -07:00
chaosinthecrd 51a970a4e6 cmd/containerboot: add tests for egress resync on FQDN target changes
Adds table tests for shouldResync, covering peer device and Tailscale
Service targets that lose and regain their addresses, a device or
Tailscale Service that failed to resolve at the last sync, a device
replaced by a Tailscale Service, a target removed from the config, a
Service that gains a second host (which must not resync), and a 4via6
route that is withdrawn or advertised.

Updates #21159
Updates #21426

Signed-off-by: chaosinthecrd <[email protected]>
2026-11-17 16:22:01 +00:00
chaosinthecrd 076da81190 cmd/containerboot: resync egress rules when an FQDN target changes
The egress proxy only stored a target FQDN's addresses after a lookup
that returned some, and on a netmap update only compared them with peer
device names. Targets that failed to resolve, had no addresses or were
Tailscale Services were never rechecked, so their rules stayed missing
until a config change or Pod restart.

This fixes this by storing every lookup result, rebuilt on each sync,
and resolving each stored FQDN in shouldResync the same way sync does.
A target that leaves the netmap now triggers a resync too, so its rules
are removed straight away. serviceIPsFromNetMap returns each Service IP
once, so a Service gaining or losing a host doesn't cause a resync.

Fixes #21159
Fixes #21426

Signed-off-by: chaosinthecrd <[email protected]>
2026-11-17 16:22:01 +00:00
Mario Minardi aac0e23d1d cmd/tsconnect: stop including tailwind styles in tsconnect package CSS
pkg.css was publishing Tailwind CSS classes unnecessarily which could
cause conflicts with downstream consumers (e.g., if the downstream uses
Tailwind 4 as an example).

Only publish xterm's styles as these are needed for the components used
by the library.

Updates https://github.com/tailscale/corp/issues/50293

Signed-off-by: Mario Minardi <[email protected]>
2026-11-16 09:31:58 -07:00
Brad Fitzpatrick 0d822c9d3a cmd/testwrapper, .github/workflows: bound hung CI test jobs
A burst of PR pushes on 2026-11-13 left several GitHub-hosted test
shards sitting in "test all" for hours after their disks filled up,
holding hosted runner slots until GitHub's 6 hour job limit. Nothing
bounded them: go test's -timeout only limits a test binary while it
runs, not compiling and linking it, and test.yml set no job timeouts.

Give every test.yml job a timeout-minutes of roughly twice the slowest
successful run seen across ~1200 recent jobs.

In testwrapper, kill go test if it goes quiet for longer than any
single test binary may run (the go test -timeout plus a 5 minute
margin, overridable via TS_TESTWRAPPER_IDLE_MARGIN) and log the
process tree under testwrapper so the stuck process is visible.
Also bound the go list and listpkgs invocations and each retry
attempt, including its rebuild.

While here, fix testwrapper exiting 0 when go test was killed by a
signal (exit code -1) with no failed tests recorded.

Updates tailscale/corp#51500

Signed-off-by: Brad Fitzpatrick <[email protected]>
Change-Id: I52bd41c247fca157d8e56381319fe80ae2f7cf02
2026-11-13 16:30:16 -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
chaosinthecrd 1d32249f40 cmd/k8s-proxy: add test for parsePort
Updates #21714

Signed-off-by: chaosinthecrd <[email protected]>
2026-11-12 22:40:34 +00:00
chaosinthecrd 7ce5547382 cmd/k8s-proxy: listen on the PORT that the operator sets
For kube-apiserver ProxyGroups with static endpoints, the operator sets
PORT on the k8s-proxy container to the targetPort of the NodePort
Services behind the advertised endpoints. k8s-proxy never read PORT, so
tsnet listened on a random port and traffic to the static endpoints was
forwarded to a port with nothing listening. Peers stayed on DERP.

This fixes this by parsing PORT and setting it as tsnet.Server.Port.
Thanks to @icheishvili (#18841) and @rquitales (#21716), whose changes
this is based on.

Updates #21714

Signed-off-by: chaosinthecrd <[email protected]>
2026-11-12 22:40:34 +00: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
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
Nick Khyl 503010831e net/{netmon,tstun},tsconst: avoid enumerating all interfaces when retrieving the default
GetWindowsDefault called GetAdaptersAddresses to build a map of every
adapter before walking the routing table. Enumerating adapters is
expensive on Windows and, since the call doesn't skip DNS info, it also
goes through the DNS Client service, which on recent Windows builds
enumerates every interface for each DNS server on each adapter.

In this PR, we query only what we need: the routing table, the metric
of each interface with a default route, and the interface row for routes
that beat the current best. We also identify the Tailscale interface by
its Wintun GUID rather than by its description, and move the GUID to
tsconst so that net/tstun and net/netmon share it.

Updates #17772
Updates #21885

Change-Id: I4c6a9d9ed791788fb0567154ee1dbe0f6a2c52a2
Signed-off-by: Nick Khyl <[email protected]>
2026-11-07 12:29:01 -08:00
chaosinthecrd 9eea2c890c cmd/k8s-operator,k8s-operator: support ProxyClass metrics for PeerRelay
The PeerRelay reconciler ignored a ProxyClass's spec.metrics, so enabling metrics created no metrics Service or ServiceMonitor and the relay Pods never served /metrics. This fixes this by setting TS_ENABLE_METRICS in ApplyProxyClass and calling tailscaled.EnsureMetricsResources for PeerRelay. PeerRelay now also waits for its ProxyClass to be ready before creating anything, as the other proxies do, so the existing ProxyClass test fixture is marked ready.

ApplyProxyClass now replaces an env var that the ProxyClass also sets instead of appending a second one. The PeerRelay StatefulSet is applied with server-side apply, which rejects duplicate env names, so a ProxyClass that sets an env var the operator also sets, such as TS_ENABLE_METRICS, would stop the StatefulSet from being applied.

Updates #22034

Signed-off-by: chaosinthecrd <[email protected]>
2026-11-05 17:22:05 +00:00
chaosinthecrd 31652c9978 cmd/k8s-operator,k8s-operator/reconciler: move metrics handling to tailscaled
The metrics Service and ServiceMonitor handling lived in cmd/k8s-operator,
and the ProxyClass reconciler kept its own copy of the ServiceMonitor CRD
check, so reconcilers in k8s-operator/reconciler could not share it. This
moves it into the tailscaled package as EnsureMetricsResources and
EnsureMetricsResourcesDeleted, which take the proxy type and parent, and
switches cmd/k8s-operator and the ProxyClass reconciler over to it. No
behaviour change.

Updates #22034

Signed-off-by: chaosinthecrd <[email protected]>
2026-11-05 17:22:05 +00:00
chaosinthecrd 68ec83c60b cmd/k8s-operator: test requeue on optimistic lock errors
Adds tests that a conflict while provisioning a Service, a Service on a
ProxyGroup, a ProxyGroup or a Connector proxy results in a timed
requeue, and that the Connector and ProxyGroup status is set to
creating rather than failed. The test for a Service on a ProxyGroup
fails the update to the shared ingress config ConfigMap, as no watch
maps that ConfigMap back to the Service, so without the requeue the
conflict was never retried.

Updates #22074
Updates #18922

Signed-off-by: chaosinthecrd <[email protected]>
2026-11-05 15:27:01 +00:00
chaosinthecrd 9a44f4f69c cmd/k8s-operator,k8s-operator/reconciler: requeue on optimistic lock errors
Reconcilers logged "optimistic lock error, retrying" with the full
conflict error at Info, and Connector, Recorder and ProxyGroup also put
it in their status. That reads like a failure, but a conflict between a
cached read and an update is expected and is retried. The reconcilers
also returned an empty result, so the retry only happened if a watch
event arrived. This fixes this by logging the conflict at Debug as an
update conflict, using a neutral status message and requeueing after a
short delay.

Updates #22074
Updates #18922

Signed-off-by: chaosinthecrd <[email protected]>
2026-11-05 15:27:01 +00:00
David Bond 2993b5e6de cmd/k8s-operator: move Recorder reconciler into its own package (#20891)
Move the Recorder reconciler and its object specs into
k8s-operator/reconciler/recorder, following the earlier ProxyClass,
DNSConfig and nameserver moves, and switch it to the shared finalizer,
resource tracker and CreateOrUpdate helpers.

Hoist two duplicated helpers into tailscaled.PrefsFromStateSecret and
reconciler.IsOptimisticLockError, and add
k8s-operator/reconciler/reconcilertest for the test helpers each package
had copied, including one fake Tailscale API client in place of four.

No behaviour change; the Recorder's watches and labels are untouched.

Fixes tailscale/corp#37086

Signed-off-by: David Bond <[email protected]>
2026-11-05 08:35:13 +00:00
David Bond 5455bf6a9f cmd/k8s-operator: require egress Pods in every IP family's EndpointSlice (#22157)
This commit changes the egress ProxyGroup readiness gate to mark a Pod
ready only when, for each egress Service, the Pod is an endpoint in the
EndpointSlice of every IP family that the proxy reports in its egress
status. Before, the gate accepted a Pod that was in either family's
EndpointSlice. On a dual-stack cluster, the StatefulSet rollout could
then move to the next Pod before the other family routed to the new Pod.

The gate reads the families from the proxy's state Secret, because a
proxy older than v1.102 does not report an IPv6 address. Such a proxy
never joins the IPv6 EndpointSlice, so its Pod must not wait for it.

Fixes #21077

Signed-off-by: David Bond <[email protected]>
2026-11-04 19:00:53 +00:00
David Bond 44066ac026 cmd/k8s-operator: keep ProxyGroup state Secrets until cleanup finishes (#22155)
This commit removes the owner reference from ProxyGroup state Secrets,
also from Secrets that an older operator created. On a Foreground
delete, the garbage collector deleted these Secrets before the
finalizers ran. The finalizers read them to find devices, so cleanup
failed and devices stayed in the tailnet.

The ProxyGroup cleanup now deletes the Secrets after the devices, and
the reconciler watches them by label. The kube-apiserver cleanup finds
its cert resources by label, so it does not need the state Secrets. A
new e2e test covers Foreground deletes.

Fixes #22072

Signed-off-by: David Bond <[email protected]>
2026-11-04 18:56:58 +00:00
Santhi Prakash f851ca27e4 cmd/containerboot: keep egress proxy watch alive after failed FQDN resolve (#22108)
In singleton egress mode (TS_TAILNET_TARGET_FQDN), a failed resolution
of the target FQDN logged the error but then broke out of the main
runLoop instead of continuing to the next netmap update. From then on
containerboot blocked in wg.Wait() while the pod still looked healthy,
and the egress proxy kept forwarding to stale addresses until restart.

A missing target is typically transient (peer not yet in the netmap,
ACL change in flight), so log and continue to let the next netmap
update retry the resolution and reinstall the forwarding rules.

Fixes #22102

Signed-off-by: Santhi Prakash <[email protected]>
2026-11-04 10:21:20 +00:00
Brendan Creane 3f78bcb0a7 cmd/tailscale/cli: do not suggest an operator for path and socket targets
When tailscaled denies a serve config, the CLI advises configuring an
operator to avoid root. That advice is wrong for path and Unix socket
targets, which require root regardless. Replace the access-denied
error for those targets with one that says to use sudo.

Updates #21204

Signed-off-by: Brendan Creane <[email protected]>
2026-11-03 14:39:07 -08:00
Brad Fitzpatrick 697bdea5aa cmd/pgproxy: delete, leave README stub
Fixes tailscale/corp#50889

Change-Id: I9ea45c14ea305fb3e5cd5adee5f64701db054f8e
Signed-off-by: Brad Fitzpatrick <[email protected]>
2026-11-03 08:12:30 -08:00
Brendan Creane d45c5ddfbb cmd/tailscale/cli: check the requested port before enabling Funnel (#22120)
The funnel command checked Funnel access with a hardcoded port 443, so
any requested port passed and the CLI reported it as available on the
internet. Check the port the user asked for instead. Turning Funnel
off skips the check so existing configs on other ports can still be
removed.

Fixes #10742
Fixes #21989

Signed-off-by: Brendan Creane <[email protected]>
2026-11-03 06:39:53 -08:00
Hamza KhokharandClaude Opus 5.5 f5d378471e cmd/k8s-operator: grant dnsconfigs/finalizers so the nameserver provisions on OpenShift (#21276)
* cmd/k8s-operator: grant dnsconfigs/finalizers so the nameserver provisions on OpenShift

The nameserver ServiceAccount, Deployment, Service and ConfigMap are created
with an ownerReference to the cluster-scoped DNSConfig and
blockOwnerDeletion: true. Clusters running the
OwnerReferencesPermissionEnforcement admission plugin - which OpenShift enables
by default and upstream Kubernetes does not - require the creating identity to
hold update on the owner finalizers subresource before accepting such a child.

The operator ClusterRole grants dnsconfigs and dnsconfigs/status but no rule on
any finalizers subresource, so every nameserver reconcile is rejected:

  serviceaccounts "nameserver" is forbidden: cannot set blockOwnerDeletion if
  an ownerReference refers to a resource you cannot set finalizers on

It retries forever, the DNSConfig never gets a status, and dns-records-reconciler
waits indefinitely. Granting the rule lets the reconcile succeed on the next
attempt; it is inert where the admission plugin is not enabled.

Static manifest regenerated with ./tool/go run ./cmd/k8s-operator/generate staticmanifests

Fixes #21275

Signed-off-by: Hamza Khokhar <[email protected]>

* cmd/k8s-operator: grant proxygroups, recorders and services finalizers

Extend the OwnerReferencesPermissionEnforcement fix to the other owners whose
children are created with blockOwnerDeletion: true: ProxyGroup and Recorder
(tailscale.com) and Service (core). Without update on their finalizers
subresource, creates of the owned resources are rejected on clusters that
enable the admission plugin, such as OpenShift.

Static manifest regenerated with ./tool/go run ./cmd/k8s-operator/generate staticmanifests

Updates #21275

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Hamza Khokhar <[email protected]>

---------

Signed-off-by: Hamza Khokhar <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
2026-11-03 09:19:45 +00:00
BeckyPauley 1db86dac84 cmd/k8s-operator/e2e: add IP family tests for ingress (#22091)
Restructure the L3, L3 HA and L7 ingress e2e tests into IP family subtests
to cover IPv4 and IPv6, plus DualStack for ProxyGroup.

Updates tailscale/corp#38029

Signed-off-by: Becky Pauley <[email protected]>
2026-11-03 08:41:03 +00: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
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
chaosinthecrd 57ca6e1e2a cmd/k8s-operator/e2e: test that cleanup finds devices by machine key
Adds an e2e test for proxy cleanup when the state Secret has no
device_id, as the unit tests use a fake client and can't show that
control honours the machineKey filter. It fills the tailnet with other
devices, checks the filter returns only the proxy's device, then removes
device_id from the state Secret and unexposes the Service. It checks
that the proxy's device is deleted and the other devices are left alone.

Updates #18922

Signed-off-by: chaosinthecrd <[email protected]>
2026-11-02 11:36:55 +00:00
chaosinthecrd afb8baf000 cmd/k8s-operator,k8s-operator: test cleanup of HA devices with no device ID
Adds tests that ProxyGroup scale-down and cleanup, Recorder cleanup and
PeerRelay cleanup delete the device matching the machine key in a state
Secret that has no device ID. The Recorder test puts that Secret on
replica 0, so it also checks that cleanup carries on to the other
replicas.

Updates #18922

Signed-off-by: chaosinthecrd <[email protected]>
2026-11-02 11:36:55 +00:00
chaosinthecrd 4f24492cf9 cmd/k8s-operator: test cleanup of devices that never reported a device ID
Adds a test that proxy cleanup deletes the device matching the machine
key in a state Secret that has no device_id. It also checks that
device_id is still used when present, that Secrets with a missing or
invalid machine key are skipped, and that Connector status does not
list a proxy before it reports its device ID.

Updates #18922

Signed-off-by: chaosinthecrd <[email protected]>
2026-11-02 11:36:55 +00:00
chaosinthecrd 8af4c2b6bd cmd/k8s-operator,k8s-operator: delete HA devices that never reported an ID
ProxyGroup, Recorder and PeerRelay cleanup and replica scale-down only
delete a replica's device if its state Secret holds the device's ID. A
replica that is shut down after it registered with control but before it
learnt its ID leaves its device in the tailnet.

This fixes this by deleting the device by the machine key in the state
Secret in each of these places when there is no ID.

Updates #18922

Signed-off-by: chaosinthecrd <[email protected]>
2026-11-02 11:36:55 +00:00
chaosinthecrd 44b0a0e8dd cmd/k8s-operator: continue Recorder cleanup past replicas with no device ID
Recorder cleanup deletes the device of each replica in turn. When a
replica had no state Secret or no device ID in it, cleanup stopped there
and reported itself done, so the devices of later replicas were left in
the tailnet.

This fixes this by moving on to the next replica instead.

Updates #18922

Signed-off-by: chaosinthecrd <[email protected]>
2026-11-02 11:36:55 +00:00
chaosinthecrd 2a65cff748 cmd/k8s-operator: delete proxy devices that never reported a device ID
Service, Ingress and Connector proxy cleanup finds the devices to delete
through the device_id key in each proxy's state Secret, which
containerboot only writes after the proxy's first netmap. If the proxy is
shut down after it registered with control but before that (for example,
a Service exposed and then unexposed in quick succession), cleanup finds
no device, removes the state Secret and the finalizer, and the device is
left in the tailnet. Connector replica scale-down has the same problem.

This fixes this by deleting the device by the machine key in the state
Secret when there is no device_id. Service, Ingress and Connector status
still only list devices that have an ID.

Updates #18922

Signed-off-by: chaosinthecrd <[email protected]>
2026-11-02 11:36:55 +00: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
Aarnav Tale 6630facd78 cmd/tsconnect/wasm: hold back partial UTF-8 sequences in termWriter
termWriter converted each chunk of the SSH output to a JS string on its
own which incorrectly handles multi-byte characters across chunk
boundaries. Move it to a separate cmd/tsconnect/termwriter package with
tests, and hold back incomplete sequences for the next write.

Fixes #22007

Signed-off-by: Aarnav Tale <[email protected]>
2026-10-29 09:57:11 -07:00