Commit Graph
4918 Commits
Author SHA1 Message Date
Kristoffer Dalby 162fa4ccc9 mapper: keep an expired node authorised in its own entry
Tailscale SaaS sends an expired node MachineAuthorized and no Expired
flag; its past KeyExpiry already moves the client to NeedsLogin.
2026-11-02 19:15:40 +01:00
Kristoffer Dalby eaeb6b3192 .github: regenerate integration test workflow 2026-11-02 19:15:40 +01:00
Kristoffer Dalby 06a0dcd62d state: apply requested tags on a key login that owns them
A requested tag the key's user owns directly, or the key's tags own one
hop away, replaces the key's tags instead of refusing the login.
2026-11-02 19:15:40 +01:00
Kristoffer Dalby 6876bcfa7f state: maintain auto-approvals across route and tag changes
Withdrawal removes approvals granted only by policy; manual and migrated
approvals remain. Recheck routes after policy learns an administrator's
new tags.
2026-11-02 19:15:40 +01:00
Kristoffer Dalby bdfe6fc380 db, types: add a column for auto-approved routes
It starts empty: the current policy cannot tell which earlier approvals
were automatic, so all of them stay as an admin's.
2026-11-02 19:15:40 +01:00
Kristoffer Dalby 6fe62dec62 state: auto-approve on registration only when the node key rotates
Registration runs the approval itself, once the policy manager knows the
node's owner, for a new node key or a change to the announced routes.
2026-11-02 19:15:40 +01:00
Kristoffer Dalby e84615049e auth, state: preserve client expiry and require expired node key rotation
Return NodeKeyExpired for same-key login so the client rotates its key;
the machine stays authorized. Store earlier client expiry and expire
tagged nodes at logout.
2026-11-02 19:15:40 +01:00
Kristoffer Dalby ba319ba8c4 state: invalidate SSH check approvals on owner changes and expiry
Honor approval only while its source keeps the same owner and is live.
2026-11-02 19:15:40 +01:00
Kristoffer Dalby b1ab98bde9 state: let a pre-auth key that is no longer valid only wake its node
A login that keeps its node key leaves a live node's expiry alone, even
with a valid key, and a wake-up is not refused for the tags it requests.
2026-11-02 19:15:40 +01:00
Kristoffer Dalby d67ee0bd75 state: serialise registrations presenting an unused single-use key 2026-11-02 19:15:40 +01:00
Kristoffer Dalby 3e9195e4d6 state: auto-approve routes in the NodeStore writer, not on reload
Registration approval runs on the node the writer replaces. A policy
reload approves nothing, and a map request only when its announced
routes change, so neither re-grants a route an admin revoked.
2026-11-02 19:15:40 +01:00
Kristoffer Dalby bd74ce670e state: persist current NodeStore rows and roll back only failed writes
Read current NodeStore rows under persistMu. Roll back only fields still
matching the failed registration, preserving concurrent node changes.
2026-11-02 19:15:40 +01:00
Kristoffer Dalby 221a387b2b state: apply map requests only under the node key that authorised them 2026-11-02 19:15:40 +01:00
Kristoffer Dalby 256a67e86b policy: offer exit routes only to viewers whose rules reach the internet
Every destination overlaps /0, so any rule offered a peer's exit routes.
They now need a rule to the internet, the test exit-node visibility
uses; via steering defers them to a regular grant only on that test.
2026-11-02 19:15:40 +01:00
Kristoffer Dalby 505eb1c1ed mapper: send a router all of its own routes
Its AllowedIPs held only the primaries the policy let it reach. It now
holds every approved route, and PrimaryRoutes the ones it serves.

Fixes #3626
2026-11-02 19:15:40 +01:00
Kristoffer Dalby 1cd93ec432 policy: reduce merged destination prefixes to the node's own addresses
Adjacent node addresses merge into one prefix, and each node's filter
kept all of it. A prefix made only of node addresses now shrinks to the
node's own; a prefix the policy wrote, or one the node routes, stays.
2026-11-02 19:15:40 +01:00
Kristoffer Dalby 6dd0656f17 api, policy/v2: refuse route prefixes with host bits
Routes are matched as written, so such a prefix never equals the one a
client announces. The approval APIs answer 400 and autoApprovers refuses
it at load and write, with Tailscale's text.
2026-11-02 19:15:40 +01:00
Kristoffer Dalby 05039d3398 policy, state: log only the routes auto-approval adds 2026-11-02 19:15:40 +01:00
Kristoffer Dalby c8b8ce89e8 poll: hold the map session's node as a view 2026-11-02 19:15:40 +01:00
Kristoffer Dalby 836d03dee2 policy/matcher: compare cached policy and node route ranges
Binary-search immutable policy ranges and normalize node routes once.
Large misses and self/via scans improve; small or early matches can slow,
and global policies pay extra normalization and allocation costs.
2026-11-02 19:15:40 +01:00
Kristoffer Dalby 452e14d461 policy: look up approved routes in a set when auto-approving
Avoid scanning the growing approval list for every announcement.
Use the sorted current routes when identifying additions.
2026-11-02 19:15:40 +01:00
Kristoffer Dalby 71dc0c1c58 types, state: derive and reduce approved routes once
Derive subnet and exit routes together, once each in announcement order.
Reuse matcher membership while preserving HA co-router visibility.
2026-11-02 19:15:40 +01:00
Kristoffer Dalby 0e7515eab9 state, policy/v2: classify only effective route changes
Compare announced-and-approved routes only when immutable route inputs
change. Publish Hostinfo without unnecessary peer adjacency rebuilds.
2026-11-02 19:15:40 +01:00
Kristoffer Dalby 4342883bd4 policy/v2, state: elect primaries by oldest control session
A router that reconnects joins as a standby; one that kept its session
takes its routes back once available again, as on Tailscale. Both the
global and the via election use it, in place of anti-flap stickiness.
2026-11-02 19:15:40 +01:00
Kristoffer Dalby 555caf7c2b types: add when a node's run of control sessions began 2026-11-02 19:15:40 +01:00
Kristoffer Dalby e0717bc116 state, policy/v2: elect available routers and retain unavailable routes
Recompute via elections on health changes and check online state and expiry.
With no available router, retain the previous primary or lowest-ID approver;
exclude routers the prober marked unreachable.
2026-11-02 19:15:40 +01:00
Kristoffer Dalby 25a01070e9 state: keep HA health probes active without delaying unrelated routers
Probe lone unhealthy advertisers. Defer results only for routers whose
routes tie them to a router still awaiting its probe.
2026-11-02 19:15:40 +01:00
Kristoffer Dalby 8e876eef32 hscontrol, types: strip trailing slashes from server_url 2026-11-02 19:15:40 +01:00
Kristoffer Dalby 41067c7e6e db: bound legacy hash verification and reload verified credentials
Limit the wait for a verification slot and reload the credential after
verification so concurrent revocation or deletion remains effective.
2026-11-02 19:15:40 +01:00
Kristoffer Dalby 34653a1bd9 db: disable GORM's prepared statement cache on SQLite
database.gorm.prepare_stmt is now ignored, with a startup warning.
2026-11-02 19:15:40 +01:00
Kristoffer Dalby d4ce109806 policy/v2: refuse check SSH rules with tag sources
A check asks the source's user to log in again, and a tagged node has
none. Tailscale SaaS refuses the rule; headscale accepted it.
2026-11-02 19:15:40 +01:00
Kristoffer Dalby 79daa3142f policy/v2: bound grant destination expansion
Require one port or range per grant IP entry. Reject more than 100,000
declared destination/port-range combinations on every parse.
2026-11-02 19:15:40 +01:00
Kristoffer Dalby 1c833ba394 policy/v2: evaluate policy tests from compiled snapshots
Parse filters once and index SSH rules by source. Evaluate tests against
user and node snapshots before taking the write lock.
2026-11-02 19:15:40 +01:00
Kristoffer Dalby 33b57fdeb2 policy/v2: need every dst node for a tests accept, no range sources
An accept passes only when each node behind the dst is reached, as on
Tailscale SaaS; a deny keeps its rule. A CIDR, "*" or autogroup:tagged
src names no user or host, so its test fails.
2026-11-02 19:15:40 +01:00
Kristoffer Dalby 0cdd52068b policy/v2: bound failure reports and name SSH test aliases
Keep source/destination labels and repeated destination occurrences.
Limit reports to 100 lines and labels to 256 bytes.
2026-11-02 19:15:40 +01:00
Kristoffer Dalby cebe5fc903 policy/v2: validate SSH test sources and destinations like SaaS
Reject address-range sources and autogroup:member destinations.
2026-11-02 19:15:40 +01:00
Kristoffer Dalby e6d04cd79a policy/v2: map login 0 to no local user in SSH rules
Every rule that maps root now carries "0": "", as Tailscale SaaS writes
it, also when the policy lists "0".
2026-11-02 19:15:40 +01:00
Kristoffer Dalby 0bfae13d6d policy/v2: normalize emitted ACL and via destinations
Write single-address via destinations bare. Deduplicate repeated ACL
destination/port pairs while preserving grant duplicates.
2026-11-02 19:15:40 +01:00
Kristoffer Dalby f2df44295a state, db: validate and store the current policy before installing it
Reject empty input. Validate without changing live state, then store and
install under one lock; prune old rows only with a successful write.
2026-11-02 19:15:40 +01:00
Kristoffer Dalby 4c8330c936 policy/v2: resolve tag owners one hop deep
A user claims only the tags it owns directly, and a tag owns only the
tags that list it, as on Tailscale SaaS. With no walk left, validate
names an undefined owner once, with the tag that lists it.
2026-11-02 19:15:40 +01:00
Kristoffer Dalby 6fd3dbd0a2 policy/v2: evaluate sshTests sources through the nodes they cover
A src was expanded to every address it names, so "*" or ::/0 never
finished. Principals are node addresses: keep those plus one stand-in.
2026-11-02 19:15:40 +01:00
Kristoffer Dalby 2c7a9a22f6 policy/v2: reuse compiled policy data across rules and nodes
Cache shared source keys, compile SSH rules and principals once, and
resolve groups once on a policy copy.
2026-11-02 19:15:40 +01:00
Kristoffer Dalby 361b5e6556 policy/v2: keep via steering bounded across route and user changes
Refresh clients when the last via grant disappears. Match each ACL once,
deduplicate routes, and elect once per route the peer actually serves.
2026-11-02 19:15:40 +01:00
Kristoffer Dalby 033dcdf43b state: serialise policy reloads
Load and install the stored policy as one step, so an older
reload cannot install its document over a newer one.
2026-11-02 19:15:40 +01:00
Kristoffer Dalby 18791456a3 integration: keep HA cable-pull routers off each other's routes
A router holding the other's route for its docker subnet in table 52
cannot be reattached: docker resolves the gateway through tailscale0.
Replaces the phase 4a wait that covered one case of it.
2026-11-02 19:15:40 +01:00
Kristoffer Dalby 99d8997e47 mapper: count only the batcher's goroutines in lifecycle tests
runtime.NumGoroutine deltas moved when goroutines left by earlier
tests exited mid-test. Label the batcher's goroutines and count those.
2026-11-02 16:09:00 +01:00
Kristoffer Dalby 5b578fe95f policy/v2: recapture SSH data captures
Every ssh_results row captured again from SaaS. SaaS now maps login "0"
to no local user in rules that map root, quotes a refused checkPeriod as
written and rewords its tailnet-domain refusal.
2026-11-02 16:09:00 +01:00
Kristoffer Dalby 363ba7be44 hscontrol, servertest: add key list scope golden data
Read-only and key-making OAuth tokens of each tag set list auth keys
with and without all=true, over admin- and token-made keys of every tag
relation, one admin key made after the token-made ones.
2026-11-02 16:09:00 +01:00
Kristoffer Dalby e8b44c653f servertest: add user role dispatch golden data
An admin role change under autogroup:admin, mirrored as a user rename;
peers, filter and frames per node per step, and v2 device users.
2026-11-02 16:09:00 +01:00
Kristoffer Dalby 1318f2802f servertest, state: add node name golden data
Labels under taken hostnames, case-only renames, hostname changes, long
hostnames and a Service's name; API, peer and self per step, and State
labels as a restart would load them.
2026-11-02 16:09:00 +01:00