Commit Graph
11923 Commits
Author SHA1 Message Date
James Tucker d4f09f596b feature/acme: rotate existing P-256 ACME account keys to P-384
Upgrade persisted ECDSA P-256 ACME account keys to ECDSA P-384 on the
next certificate issuance or renewal using RFC 8555 §7.3.5 account key
rollover via (*tempfork/acme.Client).AccountKeyRollover.

Pre-commit rollover failures (such as a CA without keyChange support or
a transient CA error) are logged and treated as non-fatal so certificate
issuance proceeds with the existing key and retries rotation later.
Concurrent issuances that loaded the old P-256 key before rotation
re-read the persisted key under accountMu so rollover happens once.

Updates #22893

Signed-off-by: James Tucker <[email protected]>
Change-Id: I5685c5e247804f305926fa6b56bb7f19a02c0212
2026-12-05 00:12:26 -08:00
James Tucker 4a83542d84 feature/acme: generate ECDSA P-384 keys for ACME certificates and accounts
Migrate newly generated TLS certificate keys, TLS-ALPN-01 challenge
keys, and ACME account keys from ECDSA P-256 to ECDSA P-384, following
Chrome and Let's Encrypt recommendations to move away from P-256.

Existing persisted P-256 ACME account keys continue to load unchanged.

Updates #22893

Signed-off-by: James Tucker <[email protected]>
Change-Id: I99a1e80c4a6ae35e17ceb42c16b9f843b06946de
2026-12-04 23:18:39 -08:00
Bazyli Brzoska aeb0f740f5 ssh/tailssh: report command exit status through login on macOS
On macOS, the incubator execs /usr/bin/login to run non-interactive
commands so that they run in a macOS login session (see #4939). But
macOS login runs the program as a child and exits 0 regardless of how
it exited, so every command over Tailscale SSH to a Mac reported
success to the client: "ssh mac 'exit 7'" exited 0. The same happened
to shells without a TTY, such as "ssh -T mac < script".

For those sessions, run login as a child instead, telling it to run
"tailscaled be-child ssh-login-cmd", which runs the user's shell as
login would have (as a login shell, with argv[0] "-zsh") and writes its
exit status to a file created by the incubator and owned by the local
user. login closes inherited descriptors, so a pipe can't be used. The
helper unlinks the file as soon as it starts, and the incubator reads
the status through its own descriptor and exits with it, or with
login's status (or 1) if none was recorded, so an unknown result is
never reported as success.

login stays in the incubator's process group, as it did when the
incubator exec'd into it, so the ssh-monitor's SIGHUP and SIGKILL to
the session's group still reach it and the command. With a TTY that
group is the terminal's foreground group, so the incubator ignores the
terminal's SIGINT and SIGQUIT while it waits.

Interactive shells with a TTY and SFTP still exec into login, and other
platforms are unchanged.

Also run the SSH integration tests on macOS in CI, as root and as a
regular user, and fix the tests that assumed /proc or Linux's stty -a
output.

Fixes #18256

RELNOTE: Tailscale SSH on macOS now reports the exit status of
non-interactive commands instead of always exiting 0.

Change-Id: I3fb4f5201667a5a218b996e0d9762429337857eb
Signed-off-by: Bazyli Brzoska <[email protected]>
2026-12-04 20:04:46 -08:00
Brad Fitzpatrick 67489a9581 ssh/tailssh: report terminated session exit before the SIGKILL grace ends
Since 133489986 (#22076), the session monitor keeps a terminated
leader unreaped until its SIGKILL deadline so its PID and process
group can't be reused. But it also withheld the exit notification
until then, so every canceled monitored session waited out the full
HUP escalation (5s by default) after its shell had already exited.

Report the exit as soon as the leader dies, still reaping only after
SIGKILL. On Linux, read the zombie's wait status with waitid(WNOWAIT),
not from /proc/<pid>/stat, whose exit_code reads as 0 when the monitor
may not ptrace the child, such as the root login process of a non-root
user's PTY session. On macOS and FreeBSD, get it from a kqueue
EVFILT_PROC NOTE_EXIT event registered at spawn and drained when the
monitor sweeps on SIGCHLD. OpenBSD keeps the old behavior until it can
be tested there.

That same commit took TestSessionMonitorCancellation, which sets a 30s
escalation, from 0.1s to 60s, making it one of our slowest tests.
Split it into pipe and PTY top-level tests so the test runner can
schedule them independently, and they now take 2s each on Linux and
macOS. Add TestMonitorTerminateReportsExitEarly, which also runs on
FreeBSD, and TestZombieWaitStatus for the Linux siginfo decoding.

Updates #deflake

Change-Id: I6ccdff33a8d4e4c96a84a27c0dbb64ac74954f47
Signed-off-by: Brad Fitzpatrick <[email protected]>
2026-12-04 16:58:34 -08:00
James Tucker 737e33224f ssh/tailssh: add OpenSSH ssh-mldsa44-ed25519 composite host key support
Add support for OpenSSH 10.6's composite ML-DSA-44 + Ed25519 host key
format (ssh-mldsa44-ed25519, per draft-ietf-sshm-composite-sigs-00),
enabled by the golang.org/x/crypto bump carrying upstream CL 848605
(golang/go#82315):

- Look up /etc/ssh/ssh_host_mldsa44_ed25519_key (matching OpenSSH's
  _PATH_HOST_MLDSA44_ED25519_KEY_FILE) when running as root.
- Generate and persist $TAILSCALE_VAR/ssh/ssh_host_mldsa44_ed25519_key
  in OpenSSH private key PEM format via ssh.GenerateCompositeKey and
  ssh.MarshalPrivateKey when no system key is present.
- Cover ssh-mldsa44-ed25519 in host key generation, handshake,
  integration, and known_hosts tests.

Updates #22864
Fixes #22807

Change-Id: I18daa6fee051f46792fc6e78896d9a8f6297b742
Signed-off-by: James Tucker <[email protected]>
2026-12-04 14:34:35 -08:00
Brad Fitzpatrick 6db878a571 util/clientmetric: deflake TestRemoteConcurrent
The local g.Set(1) loop and the Remote's gauge updates store to the
same value, so the test failed with g = 1 whenever the local writer
finished last. Apply one more remote update after the writers finish.

It failed 2999 of 9000 runs (-race -cpu=1,2,4) before, and passes
207,883 runs under flakestress now.

Flake analysis: http://flakes/analyze-test?name=tailscale.com%2Futil%2Fclientmetric.TestRemoteConcurrent

Updates #deflake

Change-Id: Iaa5c71cec6db4a8d6ab6d27b6b0e6fa9102b7c7c
Signed-off-by: Brad Fitzpatrick <[email protected]>
2026-12-04 13:52:08 -08:00
Brad Fitzpatrick a538761334 tstest/membudget: measure with one TUN and UDP queue
Since 2e6fcb4f6 opened up to min(16, GOMAXPROCS) TUN and UDP queues on
Linux, each queue's reader pins a ~128 KiB packet buffer per address
family. On a 16-core machine that raised the measured startup cost
from ~2.3 MiB to ~7.5 MiB, at the edge of the 8 MiB budget, and the
test failed about a third of the time. iOS, which the budget protects,
only ever opens one queue, so set TS_DEBUG_MAX_QUEUES=1 as the test
previously did for TS_DEBUG_WG_BATCH_SIZE.

It failed within 4 runs under flakestress before, and passes 16,427
runs now.

Updates #deflake

Change-Id: I0697a8a9fe2ad3b1742d0ac2a93796bd3aceecbc
Signed-off-by: Brad Fitzpatrick <[email protected]>
2026-12-04 13:51:57 -08:00
Brad Fitzpatrick b81b993869 portlist: deflake TestPortlistBackendChurn
The test closed a fixture listener and required the host's total
listening port count to drop, which fails whenever another process
opens a port between the two listings. Instead, check that the closed
port itself is gone. Listen on the dual-stack wildcard at a port
outside the ephemeral range so no other process holds or quickly
reuses the same port number, and ignore entries owned by other known
pids.

It failed on the first run under flakestress before, and passes
36,585 runs now.

Flake analysis: http://flakes/analyze-test?name=tailscale.com%2Fportlist.TestPortlistBackendChurn

Updates #deflake

Change-Id: I12faefb77e597a3480af1f7f7e3932911f94130d
Signed-off-by: Brad Fitzpatrick <[email protected]>
2026-12-04 13:35:13 -08:00
Dep Updater 83c76880e1 go.mod: bump golang.org/x/crypto
* golang.org/x/crypto: v0.59.0 to v0.59.1-0.20261204172400-d9f41beb107f

Triggered by @raggi via the bumpdep workflow.

Updates #22864

Signed-off-by: Dep Updater <[email protected]>
2026-12-04 12:36:23 -08:00
James Tucker f0c37d5807 cmd/tailscale/cli: test known_hosts generation with ML-DSA host keys
Verify that genKnownHosts and golang.org/x/crypto/ssh/knownhosts accept
and validate ssh-mldsa-44 host keys advertised in PeerStatus.SSH_HostKeys
alongside classical Ed25519 keys.

Updates #22864

Change-Id: I7985492c8a4e495764b783ebed9f553974f2e3a9
Signed-off-by: James Tucker <[email protected]>
2026-12-04 12:26:59 -08:00
NazarkinRomanandRoman Nazarkin f8accbe3c4 wgengine/router: accept loopback traffic from Service VIPs (#22702)
In TUN mode the VIPs of a Tailscale Service have to be on a local
interface, so a connection from the node to its own Service runs over
lo with a VIP as both source and destination. ts-input accepts loopback
traffic only from the node's own addresses, so over IPv4 these packets
hit the CGNAT anti-spoofing DROP, and the node cannot reach its own
Service. IPv6 has no such drop and works.

Have the Linux router keep an "-i lo -s <vip> -j ACCEPT" rule for each
address in router.Config.ServiceAddrs, like it does for LocalAddrs,
re-adding them when the netfilter mode changes. The rule matches only
packets that enter on lo, so it has no effect unless the VIP is a local
address.

Fixes #22701

Change-Id: I94563d2b3b989f29a737de1e377ab59f9e25fc2c

Signed-off-by: Roman Nazarkin <[email protected]>
Signed-off-by: Brendan Creane <[email protected]>
Co-authored-by: Roman Nazarkin <[email protected]>
2026-12-04 12:19:31 -08:00
Simon Law f53a1c7ba4 util/linuxfw: correct swapped table and chain names in error message (#22878)
In nftables, when a chain was not found, Tailscale would report:

	chain mangle not found in table OUTPUT

for the OUTPUT chain in the mangle table.

This patch strikes that and reverses it.

It also adds types/structs.RequireKeyedLiterals to prevent this from
happening again to this struct.

Fixes #22877

Change-Id: I930b1c2d66dc658e0486400fd7dc2c93591c3984

Signed-off-by: Simon Law <[email protected]>
2026-12-04 11:21:24 -08:00
Francois Marier ffcc7836f3 cmd/tta,tstest/natlab/vmtest: add vmtest for port mapping deletion
Add a TTA /stop-tailscaled command that sends SIGTERM to tailscaled
and waits for the process to exit.

TestPortmapDelete uses it to check that the tailscale client deletes
its PCP, NAT-PMP or UPnP mapping when it shuts down cleanly.

Fixes #21713

Change-Id: I2dfb6468fbe8dbe2483fefd83590fdda7b2e8fb2
Signed-off-by: Francois Marier <[email protected]>
2026-12-04 12:11:02 -07:00
Mike O'Driscoll 87e4d40046 wgengine/magicsock: send CallMeMaybe to peers whose endpoints we don't know (#22902)
magicsock only sent a CallMeMaybe after disco-pinging at least one of
the peer's endpoints. So if neither node's netmap had the other's
endpoints, neither ever started discovery, and traffic between them
stayed on DERP for good, even though each had the other's disco key and
home DERP and could have told the other its endpoints over DERP.

Control sends Funnel targets to Tailscale's ingress nodes without their
endpoints, and sent the ingress nodes to the targets without endpoints
too, so all Funnel traffic was relayed over DERP.

When we know none of a peer's endpoints, send it a CallMeMaybe anyway,
at most once per discoPingInterval. The peer then pings our endpoints,
which tells us its endpoints, and normal discovery takes over. Only one
of the two nodes needs this change.

Add TestMemnetDirectWithoutEndpoints, which fails without this change.

Updates #22576

Change-Id: I098ca7023f38070eb6e27aff876d3030d9fdbadf

Signed-off-by: Mike O'Driscoll <[email protected]>
2026-12-04 13:43:24 -05:00
Brad Fitzpatrick 63a8c8dd39 tstest/memnettest: test direct/DERP path failover on memnet in synctest
Add a new test-only package, tstest/memnettest, for tests that run
whole nodes and the servers they talk to on a memnet.Network in a
testing/synctest bubble, using the engine's TestOnlyPacketListener and
TestOnlyDERPDialer hooks.

Its first test, TestMemnetPathFailover, runs two nodes, each a full
userspace engine (tstun, wireguard-go, magicsock) with a netstack, plus
a DERP server and a STUN server. A TCP stream between the nodes starts
on a direct UDP path. The test then drops UDP between the nodes, checks
that the stream keeps working once both fall back to DERP, then lets
UDP through again and checks that both return to the direct path. That
covers about 20 seconds of magicsock timers but runs in about 10ms, and
the bubble checks that no goroutines outlive the nodes.

Updates #22831

Change-Id: I04adb4af691302fd012bc8d52193f7e6d4152bc7
Signed-off-by: Brad Fitzpatrick <[email protected]>
2026-12-04 09:47:22 -08:00
Mike O'Driscoll 0e8bf23404 control/tsp: let SendMapUpdate send endpoints (#22898)
Add SendMapUpdateOpts.Endpoints so tsp clients can tell control how
peers can reach them directly. cmd/ingressd needs this: without its
endpoints in their netmaps, Funnel nodes never start NAT traversal to
ingressd, and all Funnel traffic is relayed over DERP.

Updates #22576

Change-Id: Ibbae9770dcea6eca0d11b01010151d534a2f700f

Signed-off-by: Mike O'Driscoll <[email protected]>
2026-12-04 11:20:29 -05:00
Brad Fitzpatrick f11f3e9307 cmd/tsvet: add MainWith, skip cgo-generated files, add jsonduration
Other repos building on package tsvet had to modify its analyzers in
place to turn some off or skip some packages, and to not report
problems in files that cgo generates from C declarations.

Add MainWith, which runs exactly the given analyzers, so callers can
filter or wrap Analyzers instead. Drop diagnostics in cgo-generated
files for all analyzers.

deferrecover reported recover in function literals assigned to
variables that are deferred, such as "f := func() { recover() };
defer f()". Treat a function literal assigned to a variable as deferred
if the variable is ever deferred or is used other than by calling it
(including parameters, results, and package-level variables), as it
may then be deferred elsewhere.

Add jsonduration from tailscale/corp, which reports JSON-tagged
time.Duration fields, which need a jsonformat wrapper type to be
encoded the same way by encoding/json/v2. Fields only encoded by v1
encoding/json, as integer nanoseconds, can instead be declared with the
new jsonformat.DurationAsIntegerNanos alias for time.Duration, which
isn't an API change. Do so for the four existing ones.

That makes tailcfg and others depend on jsonformat, so make jsonformat
use encoding/json/v2 directly, rather than go-json-experiment's aliases
for it.

Updates #22811

Change-Id: I53c1bf4febb6b4c223b6697dfd9a502ee2e96051
Signed-off-by: Brad Fitzpatrick <[email protected]>
2026-12-04 06:50:29 -08:00
Navid Khan (Ali) 82ba6c3623 cmd/k8s-nameserver: return NOERROR for A queries on IPv6-only names (#22366)
The A branch of handleFunc returned NXDOMAIN whenever a name had no
IPv4 records, without checking IPv6. A name with only AAAA records
therefore both existed and did not exist depending on the query type,
and resolvers that treat NXDOMAIN as final (musl, busybox) failed to
resolve IPv6-only names at all.

Mirror the AAAA branch: only return NXDOMAIN when the name has
neither A nor AAAA records; when only IPv6 records exist, return
NOERROR with no A answers, per RFC 4074.

Fixes #22358

Signed-off-by: Navid Khan (Ali) <[email protected]>
2026-12-04 12:15:17 +00:00
Jeremy Schoemaker 5610fe6b29 cmd/k8s-operator: restrict load-balancer status to LoadBalancer Services (#22712)
The API server rejects load-balancer ingress status on ClusterIP and
NodePort Services. Writing it alongside the configured condition caused
reconciliation to fail once an ingress ProxyGroup backend advertised the
Tailscale Service, so the condition could never become ready.

Only publish load-balancer ingress for LoadBalancer Services. Continue
updating the configured condition for every exposed Service type.

Test the unready, advertising and withdrawn states for all three Service
types, with a fake-client interceptor enforcing the API server's status
validation.

Fixes #22028

Change-Id: I57f0309cb2fce61eef0373641580bf8a3354da61

Signed-off-by: Jeremy Schoemaker <[email protected]>
2026-12-04 12:03:21 +00:00
Nurullah MorshedandClaude Opus 5.5 81fe9507ef cmd/k8s-operator,k8s-operator: apply ProxyClass probes to PeerRelay pods (#22798)
* cmd/k8s-operator,k8s-operator: apply ProxyClass probes to PeerRelay pods

The ProxyClass livenessProbe and readinessProbe from #22461 were applied
only to ProxyGroups. A PeerRelay StatefulSet rolls with RollingUpdate, but
its Pods had no readiness probe, so a template change replaced every
relay within seconds and peers relaying through them fell back to DERP.

The probe helpers move from cmd/k8s-operator to the shared tailscaled
reconciler package, and ApplyProxyClass now applies them to the relay
container. ProxyGroups use the same code, unchanged. With a
readinessProbe set, a PeerRelay rollout waits for each new relay to be
Ready before it replaces the next one.

Fixes #22670

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

* k8s-operator: report a PeerRelay ProxyClass whose probes can't run

A ProxyGroup reports a ProxyClass that sets probes while its env turns
the /livez and /readyz endpoints off as invalid. A PeerRelay skipped the
probes without saying so.

The check moves to tailscaled.ValidateProbes, shared by both. A PeerRelay
whose ProxyClass fails it gets Ready=False with reason ProxyClassInvalid,
and nothing is created, as for its other invalid specs.

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

* k8s-operator/reconciler/tailscaled: rename probes subtest for tsvet

Updates #22670

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

---------

Signed-off-by: Nurullah Morshed <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
2026-12-04 10:54:35 +00:00
James Tucker 44fc559bf8 ipn/ipnlocal: report client metrics for PQ vs classic Serve TLS handshakes
Add two clientmetric counters in serveTLSConfig when terminating TLS for
Serve and Funnel connections (both HTTPS Serve and TLS-terminated TCP
forwarding), excluding ACME tls-alpn-01 challenge handshakes:

  - serve_tls_pq
  - serve_tls_classic

Updates tailscale/corp#52720

Change-Id: I411a45118adba722ec5bd2f80baf224df611793c
Signed-off-by: James Tucker <[email protected]>
2026-12-04 01:54:09 -08:00
James Tucker 5f104edef0 cmd/derper: report TLS PQ key exchange request and active connection metrics
Add MultiLabelMap metrics alongside derper_tls_request_version and
gauge_derper_tls_active_version to track post-quantum vs classic key
exchange usage across all HTTPS endpoints served by derper:

  - derper_tls_request_key_exchange{pq,group} (counter)
  - derper_tls_active_key_exchange{pq,group} (gauge)

The active gauge reuses hijackTrackingResponseWriter so hijacked
connections (DERP, WebSocket DERP, CONNECT) remain counted until closed.

Updates tailscale/corp#52720

Change-Id: Iea553ee6efd30907d3f719f7e5a7de3573b34533
Signed-off-by: James Tucker <[email protected]>
2026-12-04 01:53:13 -08:00
James Tucker b08899f18c derp/derpserver: report TLS PQ metrics for DERP and WebSocket connections
Track accepted and currently active DERP connections in Server.ExpVar by
transport ("http" vs "websocket"), post-quantum status ("true", "false",
or "none" when r.TLS is nil), and negotiated TLS key exchange group:

  - derp_tls_accepts{transport,pq,group}
  - derp_current_tls_connections{transport,pq,group}

Both derpserver.Handler and derpserver.AddWebSocketSupport inspect r.TLS
before handing off to Server.Accept (without retaining *http.Request on
hijacked goroutines) and decrement the active gauge when Accept returns.

Updates tailscale/corp#52720

Change-Id: I32bdb549c1218654df1f86e91b0217c5a169c566
Signed-off-by: James Tucker <[email protected]>
2026-12-04 01:01:28 -08:00
James Tucker aff6d18f39 derp/derphttp: report client metrics for PQ vs classic TLS connections
Add two clientmetric counters recording whether TLS DERP client
connections (both HTTPS upgrade and WebSocket paths where TLS state is
available) negotiated a post-quantum or classic key exchange:

  - derphttp_connect_tls_pq
  - derphttp_connect_tls_classic

Also propagate res.TLS from websocket.Dial in derphttp/websocket.go so
non-js WebSocket dials populate Client.tlsState and report PQ status.

Updates tailscale/corp#52720

Change-Id: Idcbc7fe4580e515632a4ade7a0bbfe9ae266e4f1
Signed-off-by: James Tucker <[email protected]>
2026-12-04 01:00:12 -08:00
James Tucker f082989ae6 net/tlsdial, control/controlhttp: export IsPQCurve and CurveName helpers
Move post-quantum TLS key exchange classification from control/controlhttp
into net/tlsdial.IsPQCurve so DERP client and server metrics can share the
same classification. Also add net/tlsdial.CurveName to format tls.CurveID
values into bounded metric label strings.

Updates tailscale/corp#52720

Change-Id: Ibfdc787a4afe411364888d61fe2314a4589b4f73
Signed-off-by: James Tucker <[email protected]>
2026-12-04 00:59:13 -08:00
Nick Khyl 5e622e4a4c ipn/ipn{state,local},cmd/tailscale/cli: report the protocol of the last WireGuard session
Add PeerStatus.LastProtocol, the protocol of the WireGuard session
last established with a peer. Unlike Protocol, it is kept after
the session ends. It is forgotten when the peer is removed or
its node key changes, and it is not persisted across tailscaled
restarts.

Use it for the hybrid-pq label in tailscale status --verbose and
on the web status page, so that the label no longer depends on
the session still being up.

Updates #22853
Updates tailscale/corp#50068
Updates tailscale/corp#52622

Signed-off-by: Nick Khyl <[email protected]>
2026-12-03 22:48:46 -08:00
James Tucker 35f4a6e55a control/controlhttp: prefer post-quantum/P-384 HTTPS before HTTP and default HTTPS
Previously, the Noise control dialer preferred plaintext HTTP on port 80
and only fell back to HTTPS on port 443 for middlebox compatibility,
because Noise already encrypted the inner connection with X25519.

To protect control connections against near-term 256-bit ECC / quantum
concerns when the server supports stronger key exchange, without
sacrificing compatibility, dial in three staggered stages:

  1. TLS 1.3 with post-quantum key exchange (hybrid ML-KEM), falling
     back to P-384/P-521 (excluding 256-bit ECC curves X25519 and P-256)
  2. Plaintext HTTP (Noise over HTTP), unless forceNoise443 is set
  3. Default HTTPS using Go's default TLS settings (matching the
     existing Tailscale HTTPS fallback)

Also adds clientmetric counters for the negotiated transport
(controlhttp_dial_pq_https, controlhttp_dial_p384_https,
controlhttp_dial_http, controlhttp_dial_classic_https) and a
TS_DISABLE_NOISE_PQ_HTTPS envknob to restore the legacy HTTP-first order.

Updates #21022
Updates tailscale/corp#52709

Change-Id: I9f1d264ee196a58e75857b4401be8185de4b3e3e
Signed-off-by: James Tucker <[email protected]>
2026-12-03 19:56:27 -08:00
Nick Garlis 85095d76d9 util/linuxfw: remove connmark rules in firewall cleanup (#22417)
The iptables and nftables cleanups didn't remove the connmark rules
from the mangle tables, so they were left behind by --cleanup and
after an unclean exit followed by a switch to another firewall mode.

AddConnmarkSaveRule created mangle/OUTPUT with type filter, which
iptables-nft can't add rules to. Create it with type route, as
iptables-nft does, and at startup delete the old filter-type chain
if nothing else uses it.

Updates #22363

Change-Id: I7b64e8e9894773f1dd88384c3339106603db15ae
Signed-off-by: Nikolaos Gkarlis <[email protected]>
2026-12-03 17:39:29 -08:00
Nick Khyl c069cc6561 various: mark hybrid-pq sessions in tailscale status
Report in ipn.PeerState and ipnstate.PeerStatus whether the current
WireGuard session with a peer was established with a hybrid
post-quantum handshake, and print "hybrid-pq" for such peers
in tailscale status --verbose.

The value comes from wireguard-go's PeerSessionStateFunc,
which now carries it along with the session state.

Updates #22853
Updates tailscale/corp#50068
Updates tailscale/corp#52622

Signed-off-by: Nick Khyl <[email protected]>
2026-12-03 17:18:37 -08:00
James Tucker ec75c026e4 ssh/tailssh: add pure ML-DSA-44 host key support
Go 1.27 (crypto/mldsa, crypto/x509) and golang.org/x/crypto v0.59.0
already implement pure ML-DSA SSH host keys (ssh-mldsa-44, per
draft-sfluhrer-ssh-mldsa-08) and PKCS#8 private key serialization.

Filter host key specs against ssh.SupportedAlgorithms().HostKeys so
builds without ML-DSA support (such as GOFIPS140=v1.0.0) continue to
skip unsupported key types cleanly, and add mldsa44 host key
generation, system key lookup, and handshake/integration test coverage.

Updates #22864
Updates #22807

Change-Id: I191e62a9a3d439db0c999172b283d00d501e1bcc
Signed-off-by: James Tucker <[email protected]>
2026-12-03 14:01:37 -08:00
Brad Fitzpatrick bf353f9754 ssh/tailssh: don't switch host keys when OpenSSH creates new ones
On macOS, launchd's sshd-keygen-wrapper recreates missing system host
keys on any TCP connection to port 22. tailssh preferred system keys
and re-read them on every connection, but only advertised its keys in
Hostinfo at startup or on prefs changes, so peers then failed host key
verification. Keep using host keys tailssh previously generated even
if system keys appear later, and load the keys once per process.

Fixes tailscale/corp#52474

Change-Id: I3ab9d27ecb246b91d184700ca6aabbb366f11023
Signed-off-by: Brad Fitzpatrick <[email protected]>
2026-12-03 11:54:26 -08:00
James Tucker 3ab0d50817 cmd/proxy-test-server: use upstream golang.org/x/crypto/acme
proxy-test-server already imports golang.org/x/crypto/acme/autocert and
only uses acme.ALPNProto, so it does not need tailscale.com/tempfork/acme.

Updates #10238

Change-Id: Ife3b33e1ce3164cebeb75041238d04eb808490ba
Signed-off-by: James Tucker <[email protected]>
2026-12-03 11:05:25 -08:00
James Tucker b66743bb05 cmd/derper: use upstream golang.org/x/crypto/acme for IP certs
Upstream golang.org/x/crypto/acme gained issuance profile support in
v0.59.0 (golang/go#73101), so cmd/derper no longer needs
tailscale.com/tempfork/acme. Switch ipcert.go to upstream
golang.org/x/crypto/acme using acme.WithOrderIssuanceProfile.

Also switch from CreateOrderCert to CreateCertFromOrder so order
finalization does not depend on the optional Location header in the
finalize response.

Updates #10238
Updates #22654

Change-Id: I28b4ed7f0af5e496fcc9e56ea9cd1112bbe19bb0
Signed-off-by: James Tucker <[email protected]>
2026-12-03 11:05:00 -08:00
Francois Marier 865435c678 net/portmapper: add metrics on available protocols
We want to measure the relative availability of each port mapping
protocol in the wild in order to more effectively prioritize
work in this area. This weighs active devices more heavily.

Updates tailscale/corp#51202

Change-Id: Iea5908cc3108e602256a9a7bd73c89ec5e3e10ff
Signed-off-by: Francois Marier <[email protected]>
2026-12-03 09:42:57 -07:00
Brendan Creane cd8532f160 ipn/ipnlocal: send one Notify per control status update (#22441)
A full netmap from control produced up to five separate ipn.Notify
messages: LoginFinished, the login prefs, the self node and peers, the
exit node suggestion, and the re-resolved exit node prefs. A GUI that
applied each one on arrival briefly showed the state between them.

setControlClientStatusLocked now collects all of them into one Notify,
sent from a deferred call when any field is set. suggestExitNodeLocked
no longer sends. It records a changed suggestion in a Notify that its
caller passes in, and the caller sends it with its other changes. The
two netmap blocks after the prefs save are merged. Nothing between them
ran unlocked.

Fixes #22206

Signed-off-by: Brendan Creane <[email protected]>
2026-12-03 08:11:18 -08:00
Nick Khyl cb5166bdc7 health: don't publish a stale Change from a superseded visibility timer
The visibility timer's callback only checked that its Warnable was
still unhealthy. If the Warnable was reset just as the timer fired, the
callback published the old Change even though the Warnable was no
longer visible, and removed the new timer from pendingVisibleTimers, so
that SetHealthy could not stop it. Similarly, changing a pending
Warnable's args left the old timer running.

Subscribers such as captive portal detection then received a Change for
a Warnable that was not in CurrentState.

Stop the pending timer when the unhealthy state changes, and make the
callback check that the state it was started for is still current.

Updates #15396
Updates #1634
Updates tailscale/corp#27985

Signed-off-by: Nick Khyl <[email protected]>
2026-12-03 07:58:51 -08:00
Nick Khyl 94f41e9841 net/{captivedetection,netns}: bind captive portal probes to interfaces on Windows
Without this, we try to send probes through the Tailscale interface when an exit node
is in use. The exit node is usually unreachable until the user signs in to the captive portal,
so the probes get blackholed and we miss the portal.

Updates #1634
Updates #17095
Updates tailscale/corp#21896

Change-Id: I124652d5a4e933089084f4317f7242c3e1470b99
Signed-off-by: Nick Khyl <[email protected]>
2026-12-03 07:18:03 -08:00
Brad Fitzpatrick 5ad3413af4 ipn/ipnlocal: resolve Service ExtraRecords by short name in UserDial
nodeBackend indexed device names under both their FQDN and short name
but DNS.ExtraRecords only under the record name, and control sends
Services only as FQDNs. So with userspace networking, dials of a
Service by its short name fell through to the system resolver and
failed, while TUN clients worked via the OS search domain. Also index
ExtraRecords under the MagicDNS suffix by their short name, if it is a
single label. Device names and literal short-name records still win.

Fixes #22778

Signed-off-by: Brad Fitzpatrick <[email protected]>
Change-Id: I4c03df285a80fcd7093cf47fe9a3eb73de116a13
2026-12-03 05:44:27 -08:00
Brad Fitzpatrick b21f560533 cmd/tsvet: replace cmd/vet, staticcheck, golangci-lint, and checklocks
We ran overlapping checks in four tools at different versions:
golangci-lint only reported problems on changed lines, vet only ran
for linux, and staticcheck took seven CI jobs, each compiling the tree
from scratch.

cmd/tsvet now runs the go vet suite, staticcheck, checklocks, and our
own analyzers as a single vettool, for linux, windows, and darwin, plus
a goimports check of all Go files. Small analyzers replace the
golangci-lint and revive checks that nothing else covered, and
lint:ignore directives work for every check.

CI runs it with the next toolchain (tailscale.go1.28), whose go vet
type checks dependencies instead of compiling them. Pushes to main
save one cache that per-GOOS PR jobs restore, and go test no longer
runs its own vet in jobs that tsvet covers.

Over the past 30 days, these checks cost about 43 runner-minutes per
PR (29 of them staticcheck's). On a 4-core machine, tsvet checks the
whole tree for all three GOOS values in 3m27s from an empty cache and
10s when nothing changed. Its cache for all three is 1.3 GB (176 MB
compressed), versus 5 GB for just linux when vet compiles with Go
1.27. Dropping golangci-lint also removes 161 lines from go.mod.

Fixes #22645
Fixes #22653

Signed-off-by: Brad Fitzpatrick <[email protected]>
Change-Id: Idf8779d8d3e1f5e87a8a431a53949db9c143d236
2026-12-03 05:33:36 -08:00
BeckyPauley 08caf267a0 Add e2e test for upgrading k8s operator (#22360)
* cmd/k8s-operator/e2e: consolidate shared test helpers and fix PeerRelay test

Move the readiness and reachability checks for ingress, ProxyGroup and API
server proxy tests into shared helpers in helpers_test.go so the upcoming
upgrade/downgrade suite can reuse them.

Also change the PeerRelay verify helpers from exact-equality to subset
checks so this does not fail in real clusters once the Service gets a
LoadBalancer address.

Updates tailscale/corp#34562

Signed-off-by: Becky Pauley <[email protected]>

* cmd/k8s-operator/e2e: add test for upgrade/downgrade of the operator

TestOperatorVersionChange installs the operator at one version, performs
baseline checks, changes the operator to another version, and asserts the
resources stay healthy across the change.

Tests can be run as an upgrade, downgrade or a round-trip (upgrade then
rollback). After each version change, the test re-verifies every managed
resource (ingress, egress, ProxyGroup, API server proxy, PeerRelay),
confirms the operator and proxy workloads actually rolled to the new image,
and performs connectivity checks.

Also skip rebuilding and side-loading a kind image when the node already has
the tagged image, matching the existing EnsurePushed logic when using the
--registry path.

Updates tailscale/corp#34836

Change-Id: Id643255f99a06cf9fbabb722dd37293c8f097c61
Signed-off-by: Becky Pauley <[email protected]>

---------

Signed-off-by: Becky Pauley <[email protected]>
2026-12-03 08:53:00 +00:00
Jimmyman1465andBrad Fitzpatrick 945494e329 cmd/tailscaled: skip logtail initialization on --cleanup
The Linux systemd unit runs "tailscaled --cleanup" as ExecStopPost
without $FLAGS, so --no-logs-no-support in FLAGS wasn't seen and
cleanup started logtail on every stop or restart, contacting
log.tailscale.com and falling back to bootstrap DNS. Cleanup only
tears down local DNS and router state, so skip logtail setup for it.

TestCollectPanic relied on --cleanup uploading the previous run's
panic, so it now uploads it from a normal daemon start instead.

Fixes #22836

Change-Id: Ie7a9cbd7be29aae37613b49deac1285f4a0aaa6d
Signed-off-by: Jimmyman1465 <[email protected]>
Co-authored-by: Brad Fitzpatrick <[email protected]>
2026-12-02 20:42:57 -08:00
Brad Fitzpatrick c277dd1791 net/memnet: add UDP support
Add Network.ListenPacket, making Network a nettype.PacketListener with
in-memory UDP sockets. Packets go by exact destination address and
port. Sending never blocks; packets to an address without a socket, or
to a full receive queue, are dropped. An unspecified or empty listen IP
binds the family's loopback address, and port zero picks the next
ephemeral port in rotation, so a just-closed socket's port isn't handed
right back out, as with an OS.

Reads block only on channels and timers, including for read deadlines,
so the sockets work in testing/synctest bubbles. That's for running
magicsock (via its TestOnlyPacketListener) and STUN (via
stuntest.ServeWithPacketListener) on an in-memory network with fake
time.

Updates #22831

Change-Id: Id7043412ca036b075927c6352c663d73f2b8657f
Signed-off-by: Brad Fitzpatrick <[email protected]>
2026-12-02 18:06:59 -08:00
Brad Fitzpatrick 24feea8da5 wgengine, wgengine/magicsock, derp/derphttp: add memnet test hooks
To enable synctest across more and more Tailscale tests, this wires up
some existing test-only hooks more, and adds another.

With them and a memnet.Network (and #22833 for memnet UDP support), a
test can run full userspace engines, their DERP server and a STUN
server in a testing/synctest bubble.
 
Updates #22831

Change-Id: I751775a1b3d8c89cbc9d669951f0ec22a00d9696
Signed-off-by: Brad Fitzpatrick <[email protected]>
2026-12-02 17:39:02 -08:00
Brad Fitzpatrick ebb46e100d net/memnet: accept tcp4 and tcp6 in Listener.Dial
Listener.Dial checked strings.HasSuffix(network, "tcp"), so it rejected
"tcp4" and "tcp6", which Network.Dial accepts and passes through. A
derphttp region client dials each DERP node with "tcp4" or "tcp6", so
it couldn't reach a DERP server on a memnet Network.

Accept exactly "tcp", "tcp4" and "tcp6".

Updates #22831

Change-Id: I699c40ed9c0b4a41fa3509514bd1f1bf828adb25
Signed-off-by: Brad Fitzpatrick <[email protected]>
2026-12-02 16:17:28 -08:00
Mazdak Nasab 667f2ffce4 feature/conn25: enforce the grant's proto/port ranges in the filter (#22605)
A conn25 app grant reaches the connector as a peer capability keyed
tailscale.com/cap/conn25/<app>, and peercap.Conn25Prefix already documents
that each value under such a key is a tailcfg.ProtoPortRange whose union is
what the peer may reach. Nothing implemented that: both consumers only called
PeerCapMap.HasCapability, so once a client had registered a transit IP, the
connector accepted any protocol on any port to any address in the transit
pool.

Decode the values when the client registers a transit IP, store them with the
mapping, and check every inbound packet against them in the connector's
ingress filter hook. A packet from WireGuard addressed to a transit IP always
falls through to IngressAllowHooks, since a transit IP is never in localNets,
so the check sees every packet rather than just TCP SYNs, and a denial gets
the usual RejectedDueToACLs TSMP reply.

Split packetFilterAllow in two along the way. linkLocalAllow keeps the old
pool-membership behaviour, which exists only to lift the filter's blanket drop
of link-local unicast destinations; ingressAllow makes the access decision. A
transit IP with no registered mapping still passes ingressAllow, so that the
datapath can drop it and answer with the TSMP that prompts the client to
re-register. Nothing is forwarded on its behalf.

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

Change-Id: Ic7abc89be12afe2be758fac7700fc21f89465be5

Signed-off-by: Mazdak Nasab <[email protected]>
2026-12-02 13:36:27 -07:00
Nick Khyl e3ddebe50c tstest/integration: fail tests when tailscaled logs an [unexpected] line
tailscaled uses the [unexpected] log prefix for conditions that should
never happen. Record such lines as the log catcher receives them and
report each one as a test error when the test environment shuts down.
Run tailscaled with IN_TS_TEST=1 so logs are uploaded as they are
written, rather than batched every two seconds and partly lost when the
process is killed at the end of the test.

Updates #22307

Signed-off-by: Nick Khyl <[email protected]>
2026-12-02 07:45:55 -08:00
Nick Khyl d55ba7218e tstest/integration/testcontrol: send a ControlTime after the peer expiry epoch
The fixed ControlTime of 2020-08-03 is before the epoch that ipnlocal's
peer expiry code uses to reject implausible control times, so every
tailscaled in the integration suite logged an [unexpected] warning on
each netmap update and skipped peer expiry handling. Move it to
2024-01-01, keeping it fixed so TestControlTimeLogLine can still match
it exactly.

Updates #22307

Signed-off-by: Nick Khyl <[email protected]>
2026-12-02 07:45:55 -08:00
Nick Khyl 54da9f7868 health: don't restart DERP warnables' TimeToVisible while not in map poll
Since bd9725c5f, every self-check made while out of a map poll marked
no-derp-connection and derp-timeout healthy and then unhealthy again,
restarting their TimeToVisible. As failed DERP reconnects and engine
status updates each run a self-check every few seconds,
no-derp-connection rarely became visible, and captive portal detection
was not triggered or had its warning cleared right away.

Determine each DERP warnable's state once per self-check.

Updates #15396
Updates #14687
Updates #1634
Updates tailscale/corp#27985

Change-Id: Id6d43ece267765b064956167c3d359138b0faeff
Signed-off-by: Nick Khyl <[email protected]>
2026-12-02 07:41:23 -08:00
Nick Khyl 45098febab ipn/auditlog: don't restore logs for a profile without an ID
The extension starts a logger when the control client is created,
which for a new profile happens before the profile has an ID.
Start then tried to load stored logs with an empty key and logged
"[unexpected] failed to restore logs: empty key" on every fresh start,
as seen in the Windows integration tests.

A profile without an ID has no stored logs, so skip the restore.

Updates #cleanup
Updates #22309 (the only [unexpected] log line in integration tests)

Signed-off-by: Nick Khyl <[email protected]>
2026-12-02 07:19:55 -08:00
Tom Meadows 7edc089a07 cmd/k8s-operator,k8s-operator: give ProxyGroups the chart imagePullSecrets (#22785)
* cmd/k8s-operator,k8s-operator: give ProxyGroups the chart imagePullSecrets

The operator copies the Helm chart imagePullSecrets value from the proxies
ServiceAccount onto the ServiceAccount of each Service, Ingress, Connector
and PeerRelay proxy, but not onto the one it creates for each ProxyGroup,
so with a private registry ProxyGroup Pods cannot pull the proxy image.
Its update of that ServiceAccount also removed all annotations, while
OpenShift adds an annotation and a pull secret to every ServiceAccount,
adds them again when they are removed, and the operator watches this one.
This fixes this by adding the imagePullSecrets of the proxies
ServiceAccount to the ProxyGroup ServiceAccount and keeping the
annotations and pull secrets that others add. Entries removed from the
chart value stay on existing ProxyGroup ServiceAccounts.

Fixes #22783
Fixes #22784

Change-Id: Ided67a2972b81c1a95281cf8ef85eae34fee4a3c
Signed-off-by: chaosinthecrd <[email protected]>

* cmd/k8s-operator: test ProxyGroup ServiceAccount pull secrets and annotations

Adds a test that egress, ingress and kube-apiserver ProxyGroups get the
imagePullSecrets of the proxies ServiceAccount without losing entries or
annotations that others add, and that kube-apiserver ProxyGroups in auth
mode leave the static ServiceAccount alone. It also checks that reconcile
fails without creating the ServiceAccount when the proxies ServiceAccount
cannot be read.

Updates #22783
Updates #22784

Change-Id: Ibf73086cdf0f622cc7761cc5f0a6cee482a3b5c8
Signed-off-by: chaosinthecrd <[email protected]>

---------

Signed-off-by: chaosinthecrd <[email protected]>
2026-12-02 10:59:06 +00:00