Commit Graph
505 Commits
Author SHA1 Message Date
Kristoffer Dalby 8b41925a1f nix: support systemctl reload in the headscale service
Fixes #3027

Claude-Session: https://claude.ai/code/session_01RHEZM1qJ2hgndiXio7P56h
2026-11-03 15:52:52 +01:00
Kristoffer Dalby b3ffec4269 hscontrol: reload manual TLS certificate on SIGHUP
Files that fail to load or are not valid now keep the previous certificate.

Fixes #3027

Claude-Session: https://claude.ai/code/session_01RHEZM1qJ2hgndiXio7P56h
2026-11-03 15:52:52 +01:00
Igor Serganov d0e10f2d46 util: read .json files as HuJSON in UnmarshalByExt (#3634)
dns.extra_records_path and derp.paths files ending in .json were decoded
with encoding/json, so a comment or trailing comma in otherwise valid
JSON made headscale refuse to load the file. Policy files already accept
HuJSON regardless of extension. HuJSON is a superset of JSON, so
standardizing .json input the same way as .hujson keeps every valid JSON
file decoding exactly as before.

Add tests for comments and trailing commas in extra records, in generic
.json decoding and in ACL policies, and for comment markers inside
string values.

Fixes #3627
2026-11-02 20:35:24 +01:00
Michael Lopez 42a97be25f state: validate the new name and refuse OIDC users in RenameUser (#3642)
State.RenameUser went through UpdateUser and skipped the checks
db.RenameUser applies, so the API could rename an OIDC user, whose
name the identity provider owns, or rename any user to an invalid
name. Apply both checks in the update function and map the username
validation errors to 400.
2026-11-02 20:22:23 +01:00
Kristoffer Dalby 697eff7474 CHANGELOG: enumerate policy, lifetime and API compatibility breaks 2026-11-02 19:15:40 +01:00
Kristoffer Dalby 7721d8c299 hscontrol: keep a re-keyed node from its stale ephemeral GC timer
Re-registering with a permanent key left the timer armed, and the poll
path only cancels for ephemeral nodes. Recheck when the timer fires.
2026-10-30 17:05:36 +01:00
Igor SerganovandClaude Opus 5.5 1ff8e368b6 hscontrol: arm ephemeral GC when a node registers with an auth key
The ephemeral garbage collector was only armed when a long-poll
session ended, or for every ephemeral node at startup. A client that
registered and went away before its first long-poll reached Connect,
for example a pod killed right after login, never ended a session,
so no deletion timer was armed. The node then stayed until headscale
restarted, well past node.ephemeral.inactivity_timeout.

Schedule the GC right after the auth-key registration, before the
error check: a failed policy refresh still returns the saved node. The
existing Cancel in serveLongPoll stops the timer once the node
connects. A timer that fires while a session is live is still skipped
by the ActiveSessions check.

TestEphemeralGCDoesNotDeleteReconnectedNode now checks that
registration arms the timer and cancels it before replaying its
sessions. Otherwise the 50ms timer could fire while the test's Connect
was still waiting for a NodeStore flush.

TestFailedReconnectDoesNotCancelEphemeralGC and
TestDeleteNodeCancelsEphemeralGC ran with a zero inactivity timeout,
so the registration timer deleted the node at once, and the delete
cancelled the timer the tests armed themselves. They now use 5s, which
outlasts the tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 17:05:36 +01:00
Kristoffer Dalby 8e45958341 CHANGELOG: align the 0.29.x sections with the releases
0.29.7 now matches what ships; 0.30.0 drops entries 0.29.7 already
released. #3398 never shipped in 0.29.3, #3236 missed 0.29.0.
2026-10-30 10:35:22 +01:00
Kristoffer Dalby c0925962c2 hscontrol: bound pending authentication without evicting sessions 2026-10-29 20:51:50 +01:00
Kristoffer Dalby a9508935b9 CHANGELOG: document SSH acceptEnv fix
Updates #3559
2026-10-29 20:51:36 +01:00
Kristoffer Dalby c285eff776 CHANGELOG: list the oss-scanner findings for 0.29.7
Move the #3603 entries to 0.29.7 and link the pull request.
2026-10-29 14:00:02 +01:00
Kristoffer Dalby 208043c88d oidc: keep email_verified with the address it came with
Fixes ANT-2026-MX8FKG4K
2026-10-29 14:00:02 +01:00
Kristoffer Dalby b5bebf9b32 db, state: let only the delete that removed a node free its addresses
Fixes ANT-2026-NWTIBB02
2026-10-29 14:00:02 +01:00
Kristoffer Dalby c9e9f72857 state: drop registration locks once unused
The lock is taken before any credential check, so client-chosen machine
keys grew the map forever. Ref-count entries; delete at zero.

Fixes ANT-2026-ZC18AF82
2026-10-29 14:00:02 +01:00
Kristoffer Dalby b833be283c types, auth, noise: let one request wait on each auth session
One verdict per session, so one waiter: the newest. A displaced one
returns at once (register error, SSH re-delegate), not at session end.
A waiter keeps only the follow-up URL and the cached registration.

Fixes ANT-2026-NM50ZP4N
2026-10-29 14:00:02 +01:00
Kristoffer Dalby 7892a8462c auth: check the follow-up's machine key before it waits
A session has one verdict; another machine holding the URL could take
it.

Fixes ANT-2026-NM50ZP4N
2026-10-29 14:00:02 +01:00
Kristoffer Dalby 28959cb27c noise: time out stalled bodies and idle tunnels
The hijack drops the outer server's deadlines; any machine key gets a
tunnel.

Fixes ANT-2026-K903ZEUA
2026-10-29 14:00:02 +01:00
Kristoffer Dalby 5a4d366ce1 auth, state: keep only hostname, OS and tags in pending registrations
The rest arrives with the first MapRequest. A relogin keeps the node's
current Hostinfo, endpoints and disco key; an oversized merge is a 400.

Fixes ANT-2026-RQS7JAPP
2026-10-29 14:00:02 +01:00
Kristoffer Dalby 4ce928411e state: bound client reports of nodes loaded at startup
Rows stored before the bounds are trimmed the same way at load; a
Hostinfo still over budget is dropped until the node reports again.

Fixes ANT-2026-RQS7JAPP
Fixes ANT-2026-5B6KE87K
Fixes ANT-2026-KFCFFM34
2026-10-29 14:00:02 +01:00
Kristoffer Dalby 2e563635d0 types, noise: bound the Hostinfo and endpoints a client reports
Keep the first 256 endpoints and 4096 routes; refuse longer hostnames,
too many tags, zoned endpoints and >64 KiB NetInfo or other Hostinfo.
The body limit counted wire bytes, not what NodeStore and peers keep.

Fixes ANT-2026-RQS7JAPP
Fixes ANT-2026-5B6KE87K
Fixes ANT-2026-KFCFFM34
2026-10-29 14:00:02 +01:00
Kristoffer Dalby 15a8c7584e hscontrol: refuse a key expiry that cannot be encoded
handleRegister, the OIDC auth path and SetNodeExpiry refuse it. Expiries
are stored in UTC, which SQLite can read back, and loaded in UTC, as
PostgreSQL returns the server's zone. The v1 API answers 400.

Fixes ANT-2026-QMCAFJ1Q
2026-10-29 14:00:02 +01:00
Kristoffer Dalby e3c1bfd68e mapper: skip peers whose key expiry cannot be encoded
json.Marshal refuses a year outside [0,9999], so one stored expiry
failed every map with that node. TailNode and key patches send UTC, the
builder drops what fails and the boot scan names the node.

Fixes ANT-2026-QMCAFJ1Q
2026-10-29 14:00:02 +01:00
Kristoffer Dalby e1de83cbdf state: give another user's key on a tagged machine a new device
Only a key that speaks for a tagged node re-authenticates it: a tagged
key, or one of the user it was tagged from. Another user's key or login
adds that user's own device, or only wakes the node under its node key.

Fixes ANT-2026-AWGRB7O1
2026-10-29 14:00:02 +01:00
Kristoffer Dalby e67ef8619a state: need a valid pre-auth key to re-register an expired tagged node
Fixes ANT-2026-LYVGXVSW
2026-10-29 14:00:02 +01:00
Kristoffer Dalby 47d82023e7 state: never serve a single address inside the node ranges
Such a route names a node, not a subnet: it stays approved and listed
but no viewer gets it. Via inclusions skip the election, so the rule
sits on everything RoutesForPeer returns.

Fixes ANT-2026-MLP8ZR5T
2026-10-29 14:00:02 +01:00
Kristoffer Dalby cd66e2414a noise: restrict metrics to the metrics listener
Fixes #3571
2026-10-29 13:05:56 +01:00
Kristoffer Dalby 1a48b276ef docs: explain how to disable SSH forwarding 2026-10-29 12:43:14 +01:00
Kristoffer Dalby 998c4b0619 policy: pin SSH forwarding behavior and recommend upgrades 2026-10-29 12:43:14 +01:00
Kristoffer Dalby a63ee3e032 api/v2: add the acl/validate endpoint
Checks a policy as a write would, without storing it. As on Tailscale,
a refused policy answers 200 with its reason; only an empty body is 400.
Terraform provider 0.29.3 calls it at plan time.
2026-10-29 11:04:05 +01:00
Kristoffer Dalby f3fc915b71 CHANGELOG: set the 0.29.6 release date 2026-10-24 15:43:39 +02:00
Kristoffer Dalby 33544f62cb CHANGELOG: document the 0.29.6 security and patch release
Updates #3579 and #3549.
2026-10-24 11:15:20 +02:00
Kristoffer Dalby e195ce9675 CHANGELOG: map session and churn fixes 2026-10-23 18:23:53 +02:00
Michael LopezandClaude Fable 5.1 494e2a6808 db: quote postgres connection parameters (#3477)
* db: quote postgres connection parameters

The DSN was built by string concatenation, so a password containing a
space, quote or backslash truncated it or injected extra parameters.
Build it with libpq keyword/value quoting and keep the password out of
the startup log line.

* db: mark the DSN test fixture password as not a credential

gosec G101 flags the literal assigned to Pass in TestBuildPostgresDSN.
The value exists to exercise quoting of spaces, quotes and backslashes
and is not a secret.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* types, db: build the postgres DSN as a URL from PostgresConfig

Review feedback: move the DSN construction onto types.PostgresConfig as
DSN(), so the database layer calls cfg.Postgres.DSN() and logs
redacted.DSN(), and build it as a postgres:// URL with net/url instead
of hand-rolled libpq quoting. Unix socket directories travel as the
host query parameter; bare IPv6 literals are bracketed. Tests parse the
URL back and check each component rather than the encoded string.

* types: silence gosec on the whole DSN test fixtures

gosec reports G101 on the composite literal that holds a Pass value, not
on the Pass line itself, so the previous nolint did not cover it. Place
the directive before each fixture element.

* db: drop imports left unused by the merge with main

The merge of main reintroduced the slices and strconv imports in db.go,
but the postgres DSN is now built by PostgresConfig.DSN and nothing in
the file uses them, so the package failed to compile and every CI check
failed on typecheck.

Also link the CHANGELOG entry to the PR.

* db: restore tests and formatting lost in the rebase onto main

Resolving the rebase conflicts in db_test.go kept this branch's side and
dropped the credential tests main had added, including the
requireCredentialConstraints helper another test still calls, so the db
test package no longer compiled. Restore the file from main; this branch
does not change it.

The resolution also indented the package clause in db.go and removed the
blank line between the standard library and module imports.

---------

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-22 22:36:04 +02:00
Kristoffer Dalby 54eedce658 all: build with Go 1.27.3
crypto/x509 security fixes.
2026-10-22 14:37:00 +02:00
Serhii Matsyshyn 8003de63a6 CHANGELOG: peer map build speed-up 2026-10-20 11:55:11 +02:00
Kristoffer Dalby 2ba21d2f8d CHANGELOG: add tls block and certmagic
Updates #2527
2026-10-18 20:53:18 +02:00
Kristoffer Dalby ee47638787 CHANGELOG: add TLS certificates for nodes
Updates #2137
2026-10-18 20:53:18 +02:00
Serhii Matsyshyn a777969027 CHANGELOG: one peer map build per policy write 2026-10-18 13:18:48 +02:00
Kristoffer Dalby 920b6fb8cd CHANGELOG: raise minimum Tailscale client to v1.84.0 2026-10-15 10:50:32 +02:00
Kristoffer Dalby b6ac75a343 CHANGELOG: move 0.29.5 backports out of 0.30.0
Align the 0.29.5 section with the release branch.
2026-10-13 14:38:29 +02:00
Martin -nexus- Mlynář a8d6f5be81 state: send a relogin as a whole node unless only its keys changed
A PeerChange patch cannot clear a peer's Expired flag or carry the
Hostinfo the relogin stored.

Fixes #3531
2026-10-09 11:44:37 +02:00
LuoChen aaf4ccd8c9 util, types: parse unix_socket_permission strictly
Default "0o770" failed the base-8 parse and silently became 0700.
Invalid, unquoted or above-0777 values now fail config load.

Fixes #3529
2026-10-09 11:42:53 +02:00
Jonas Schwartz 519b4621f3 policy/v2: add Grant.HasVia and tighten the changelog entry 2026-10-08 12:43:45 +02:00
Jonas Schwartz f8018f177a policy/v2: skip via resolution when the policy has no via grants
ViaRoutesForPeer runs for every peer of every map response. Before it
looks at Via, it converts every ACL to grants and resolves each grant's
sources and destinations against the whole node set. Only via grants
can add to the result and ACLs never carry via, so without a via grant
all of that work was discarded. On large tailnets it dominated map
generation. Return early instead.

BenchmarkViaRoutesForPeer, mean per peer (Apple M3 Pro):

	policy     nodes  before    after
	global     1000   21.8us    9ns, 0 allocs
	self       1000   45.0us    9ns, 0 allocs
	via        1000   8.1us     unchanged
	via-mixed  1000   69.0us    unchanged

Fixes #3512
2026-10-08 12:43:45 +02:00
Dan Cunningham 8798c9af83 hscontrol: never garbage collect an ephemeral node with a live session
A session arming the GC after a reconnect cancelled it left a stale timer.

Fixes #3535
Signed-off-by: Dan Cunningham <dan@digitaldan.com>
2026-10-08 12:14:58 +02:00
Kristoffer Dalby b7aa328e0c CHANGELOG: note SSH rule removal fix
Updates #3508
2026-10-08 10:29:23 +02:00
Kristoffer Dalby 2cd82ceb0c CHANGELOG: note the own approved routes fix
Updates #3502
2026-10-07 23:36:16 +02:00
Kristoffer Dalby 31582dd2c2 CHANGELOG: link derp-admit to pull request 2026-10-07 22:55:03 +02:00
Kristoffer Dalby e7bb90bac1 CHANGELOG: name both DERP verify paths
Embedded DERP verifies in-process, not through /verify.
2026-10-07 22:55:03 +02:00
Kristoffer Dalby 7ffdba7175 hscontrol: admit DERP clients via NodeKey index
/verify scanned every node per DERP connect; use GetNodeByNodeKey.
2026-10-07 22:55:03 +02:00