Repository navigation
Release v1.5.9 - #354
Merged
Merged
Release v1.5.9#354
Conversation
The auto-added AD split rules route corp names to upstream.os, but a rule match skipped the LAN-query classification in proxy(), so osResolver raced the domain controller against 76.76.2.0 and sent every AD lookup (DC hostnames, DC-locator SRV names carrying the machine name, WPAD) there in plaintext. Mark a rule-matched query under the machine's AD domain (p.adDomain) whose upstreams are the OS resolver alone as a LAN query, which drops 76.76.2.0 for it. Explicit-resolver rules are unchanged.
The previous change marked a rule-matched AD query as a LAN query, but
two paths still reach the OS resolver without that mark, so osResolver
raced the domain controller against 76.76.2.0 in plaintext:
- the DNS-intercept recovery bypass, which forwards queries before
rule handling runs
- the OS-resolver retry catch-all after an explicit upstream fails
with leak_on_upstream_failure enabled
Mark a query under the detected AD domain on both paths. Other names
keep the public fallback, and an explicit upstream is still tried first.
Build resolvers in proxy() through newResolverFn, so tests drive proxy()
and assert the LAN mark that reaches each resolver, instead of testing
the predicate alone.
During the reported incident the API answered "Maintenance is in progress. Please try again later." after a successful DNS resolution and TCP connection, and ctrld reported it as API_UNREACHABLE. Nothing in the client could tell that answer apart from the API refusing the request, so callers had to guess from an HTTP status that does not carry the distinction. Add IsMaintenance. The API answers every public request in hard maintenance mode with HTTP 503 and error.code 50302 (Application::ERROR_HARD_MAINTENANCE), exported as MaintenanceCode, and IsMaintenance classifies on that code. It falls back to the message for deployments that answer without the code, which a test covers so that path cannot silently drop. The answer's "body" is an empty JSON array; a test pins that the error decode does not depend on it. 50301 (service unavailable) and 50003 (read-only mode) are deliberately not maintenance: the first is a failure, and read-only only gates authenticated controllers, so it never answers /utility or /logs. Maintenance is temporary and says nothing about the configuration that was asked for. The HTTP status cannot classify it on its own, because a maintenance answer can arrive with a client-error status that otherwise means the same request will be refused again, so callers must ask this question before they act on a status.
A hard maintenance window took DNS down on endpoints that already had a working configuration: the bootstrap preflight read the maintenance answer as a failed fetch and exited, turning a temporary API outage into an endpoint outage. Startup now falls back to the configuration on disk, which keeps resolving until the API returns. Eligibility is not file presence: a start with no configuration writes the seeded freedns default before the API is ever reached, so a marker records that the API produced the file, bound to both the identity and the file's contents - an identity-only marker outlives the file it vouched for, and would certify the default regenerated in its place. Because that binding follows the contents, every managed write refreshes it, or one API-driven config change would leave the host ineligible for the fallback its own configuration is meant to provide. Generated defaults, NextDNS configurations and failed writes certify nothing. Without a matching marker ctrld still stops, now with API_MAINTENANCE (exit 37) and a message naming what cannot be done rather than reporting a fetch failure that reads as broken connectivity. Also: - Maintenance is never a permanent rejection or a deleted device, so it cannot stop the service for good or trigger a self-uninstall. - A run that started on disk retries every 5-7 minutes until it has an answer. refetch_time is untouched, and the jitter keeps hosts that fell back together from returning as one burst. - Recovery is acknowledged where the configuration takes effect, not where the fetch returns or the reload is triggered: the receiver fetches again and can fail. Until then the run stays pending and its answers keep reaching the apply path, instead of comparing equal to a response that was stored but never applied. - Such a run never asked about the deactivation PIN, and the value meaning "no PIN" is the one it starts with, so deactivation is refused with 503 while the PIN cannot be verified.
`ctrld start --cd-org <code>` logged its arguments as-is in the debug line `intercept upgrade check: args=[--cd-org <code> ...]`, so the code reached the console with -v/-vv and any log that keeps debug lines. A provision code enrolls endpoints into the organization until it expires or runs out. redactedArgs formats the arguments through redactSecrets with provisionSecrets, which covers --cd-org and both parts of --cd, in either flag form. The line keeps the other arguments.
…LAT starts On macOS in Intercept mode, an IPv6-only network that offers no DHCPv4 and no PREF64 ended in a DNS outage. The DHCP option-6 read fails there because no lease exists, and the native-CLAT evidence does not exist yet because macOS starts its CLAT only after RFC 7050 prefix discovery (ipv4only.arpa) succeeds. pf blocks IPv6 port 53 and the service has no IPv4 DNS, so that lookup can never be sent. ctrld waited for evidence that only DNS could produce. A failed DHCP read now admits the target with a second kind of positive native evidence: configd publishes no global or per-service IPv4 state, the IPv6 primary service is this device, and the interface holds only IPv6 addresses (at least one routable). The service mapping, unique enabled networksetup name, two-second shared budget, tuple recheck, validated snapshot backup and ownership rules are the same as on the CLAT path. Unknown or changing state still admits nothing. A readable DHCP lease never consults the new evidence, and CLAT evidence keeps precedence. The journal line records which evidence admitted the target.
The test for #632 covered redactedArgs, but not the debug line that uses it: putting osArgsEarly back into that Msgf would have leaked the provision code again with every test passing. Build the line in interceptUpgradeCheckLine and test it directly, for --cd-org and --cd in both flag forms. Reverting the line to the raw arguments fails the test.
"No IPv4 yet" is also the state of a dual-stack network whose router advertisement arrived before the DHCPv4 ACK. In that window the DHCP read fails, configd has no IPv4 state, and the interface holds only SLAAC IPv6, so a single IPv6-only observation could write 127.0.0.53 on a service that provides IPv4 DNS seconds later. The IPv6-only evidence must now hold on the same service and device for 15 seconds before it admits a target. The first observation starts the clock and schedules one confirming reconcile. Any pass that reads the evidence and finds a readable lease, IPv4 state, CLAT, or a different service ends the confirmation without a write. Shutdown drops a pending confirmation. CLAT evidence still admits immediately. Review follow-ups: the service-name and networksetup mapping tail is a shared reader helper, the IPv6 interface check uses an escaped tab, and nativeIPv6OnlyAddresses has its own table test.
When DHCPv4 gives up, macOS self-assigns a 169.254.0.0/16 address on the service. On the ctrld-qa macOS 26 guest (v6-only personality, IPv6 port 53 blocked so no CLAT) it appears about 22-26 s after joining: en0 holds 169.254.x.x and State:/Network/Service/<id>/IPv4 holds only that address, with no Router and no CLAT46, while Global/IPv4 stays absent. The 15 s IPv6-only confirmation could finish after that point and then never admit. The IPv6-only evidence now treats a link-local-only IPv4 configuration of the same device as no usable IPv4. Any router, CLAT, primary, routable address, other device or unknown field still rejects. It only appears after DHCPv4 has given up, so it does not reopen the dual-stack window. Tests: reader cases for the captured link-local state and its unsafe variants; the harness now keeps the scheduled confirmation and runs it to cover admission, closed network activity and stopped intercept.
TestNetworkShutdownCancelsIndefiniteRecoveryWait relied on an empty upstream map never recovering. Since 73db7adc an empty pool checks upstream.os instead, so the test probed the host's real OS resolver. On a host with working DNS that check succeeds, recovery completes, and it reads the upstream monitor the test never built. Recover against a loopback port nothing listens on, so the wait can never end on its own, and give the prog the upstream monitor that run always creates before network monitoring can start a recovery. The panic is test-only: production never reaches recovery without one.
When no intercept mode is selected by flag or config, a new installation on macOS or a Windows desktop edition now uses "dns". Windows Server, iOS and other platforms keep interface DNS mode unless intercept is selected explicitly, and so does a config that cannot run in intercept mode. Existing Standard installations are not switched on upgrade. ctrld start marks the services it installs fresh, and the service applies the default below service.intercept_mode against the config it fetches, so a service with neither a mode nor the marker predates the default and keeps interface DNS mode, whichever path upgrades it; the macOS package also pins such a service to "off" explicitly. An explicit "off" stays final and is persisted.
TestCustomListener5353Binding bound 127.0.0.x:5353, the mDNS port, so it failed on any Linux host running an mDNS responder such as avahi, which holds *:5353, before the code under test ran. Nothing in the listener code treats 5353 specially. Use ports the test holds itself, and rename the test and its file after what they cover: an explicit intercept listener binds unchanged, and an occupied one, by UDP, TCP or both, fails instead of falling back.
…OS intercept mode
The build stage ran on the target platform, so a multi-platform build ran the Go toolchain under qemu. On hosts with an older qemu-user (Ubuntu 22.04 ships 6.2) Go crashed building linux/arm/v7, and the image still built: scripts/build.sh did not fail on a build error, and the COPY of ctrld-linux-*-nocgo matched nothing, so the image shipped without ctrld. In both docker/Dockerfile and docker/Dockerfile.debug, run the build stage on BUILDPLATFORM and cross-compile for the target with scripts/build.sh linux/amd64, linux/arm64 or linux/armv7. Then move the binary built for that target, by its exact name, to a fixed path, and fail when it is missing. scripts/build.sh now exits non-zero when go generate or go build fails, and .dockerignore keeps ctrld-* files from the host out of the build context, so a leftover binary can never stand in for a failed build. Drop the outdated CTRLD_NO_QF variable.
A bootstrap lookup that returned only one address family, such as an AAAA-only answer for a split-stack Control D upstream, was accepted as is, and re-bootstrap rebuilt the transports from the same lists, so A queries failed with "empty addresses" until a restart. Bootstrap now checks the result against what the ip_stack needs and fills a missing family from the Control D direct-IP table and bootstrap server. If it is still missing, the next re-bootstrap looks it up again, and a split transport borrows the other family meanwhile. After the DoH direct-IP fallback fires, DoH and DoH3 also dial the Control D direct IPs for the ip_stack's families when the bootstrap addresses are empty or fail, keeping the domain for TLS. A working list always wins, so nothing is pinned. DoT always verifies the server as the upstream domain.
…ange After a network change, the OS resolver keeps the previous network's nameservers until a read finds the new ones. In Standard mode that usually waits for the recovery to remove ctrld's DNS settings: while 127.0.0.1 is configured, the system reports nothing else, and on macOS an RDNSS-only IPv6 network has no other source. macOS resolves ipv4only.arpa through ctrld right after the change to discover the NAT64 prefix; a fast SERVFAIL from the stale set ends that discovery, macOS never starts its CLAT, and an IPv4-only upstream never recovers. On every accepted network change, on all platforms and in both Standard and intercept mode, mark the OS resolver stale and read the nameservers once before the re-bootstrap, without the scutil retry loop. While the set is stale, a failed ipv4only.arpa AAAA lookup gets no reply, so the host retries it. A read that finds nameservers clears the mark, and the mark expires after 30s. Network-change recovery also re-reads the nameservers right after the reset and then at 1s, 2s, 5s and every 30s while it waits, for networks that publish their resolvers late.
…laintext fallback After a wake or a network change, a query to an encrypted upstream can ride a connection opened before the sleep or on the previous network. It times out there, and the query falls back to the OS resolver, which sends it in plaintext on port 53, although a new connection would be answered at once. Every query now checks whether the host slept since the previous one, and if so renews the upstream connections before it is sent. A sleep shows as the wall clock moving ahead of a clock that stops while the host sleeps: Go's monotonic clock on Linux and macOS, and the unbiased interrupt time on Windows, where Go's monotonic clock keeps running. This does not wait for netmon or a wake detector. A wake now also re-bootstraps the upstreams. Before the fallback, a query whose upstreams all failed is retried once on fresh connections when the network epoch moved while it ran: a network change or a wake was handled, or a sleep was found then.
cuonglm
force-pushed
the
release-branch-v1.5.9
branch
from
October 22, 2026 13:25
36aebed to
01f0c0a
Compare
added 2 commits
October 23, 2026 00:05
getActiveConsoleUser looked up WTSGetActiveConsoleSessionId in wtsapi32.dll. Windows exports it from kernel32.dll, so Find failed on every host and console-session discovery always returned no user. Previously, the registry fallbacks hid this. Daemon start now uses session-only discovery, so on Windows every managed start omitted username even with a user signed in at the console. Use windows.WTSGetActiveConsoleSessionId from golang.org/x/sys, which binds the kernel32 export. Add a Windows test that compares discoverSessionUser with the active console row of quser.
On Windows, `ctrld stop` in Intercept mode sometimes ended with SCM event 7031 and an automatic restart, which put the NRPT catch-all back (#652). Service Stop closes stopCh and returns; kardianos/service then reports SERVICE_STOPPED from the s.Run goroutine. run() returned as soon as finishRun completed, and main called os.Exit(0) right away. If that beat s.Run, the process was gone while the service was still StopPending, and SCM treated it as a crash. The ordering race is older, which fits #492. 9ad42622 (#627) moved the control-server Shutdown from finishRun into Stop, so finishRun no longer spends that time before the process exits, and the exit wins far more often. Lab, service-stop-start Intercept: 1.5.8 0/21, 633689c 13/23, 633689c without the early call 0/15. Keep the early control-server stop that #627 needs, and make run() wait, bounded at 5 s, for s.Run to return before the process exits.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Minor Release
This contains new features, security hardening and bug fixes.
Security
intercept upgrade checkdebug line, soctrld start --cd-org <code>no longer prints a reusable enrollment code to the console with-v/-vvor into logs that keep debug linesAdded
API_MAINTENANCEcode (exit 37) instead of reportingAPI_UNREACHABLE. Maintenance never counts as a permanent rejection or a deleted device, so it cannot stop the service for good or trigger a self-uninstall. Deactivation is refused while the PIN cannot be verifieddns. Windows Server, iOS and other platforms keep interface DNS mode. Existing Standard installs are not switched on upgrade, and an explicitoffstays final100.100.100.100. A route is taken only when it cannot loop back through ctrld; otherwise it stays on Control Dctrld log sendfor standard macOS users. An administrator enablesservice.allow_unprivileged_log_sendin the device's custom ctrld configuration in the Control D dashboard and restarts the service, so standard users can upload diagnostics withoutsudo. The socket accepts only a bodyless upload request. Every upload comes from checked, root-owned log files, and uploads share a one-minute cooldown.--fulland other privileged commands still need administrator rightsusernameis omitted, so the API keeps the stored value instead of a guess orunknownChanged
ipv4only.arpa) gets no reply while the nameserver list is stale, so the host retries it instead of giving upgolang.org/x/netto v0.60.0 with Go 1.26Fixed
ctrld upgradewhen the new binary never becomes ready. The upgrade used to report success for a service that was running but had never finished startingempty addressesuntil a restart. ctrld now fills the missing family from Control D's direct IPs and looks it up again on the next re-bootstrap