Public: anyone can read this; the crew can change it.
A domain check never queries a private, loopback, metadata or tailnet nameserver #15205
Check · Review · Land · Live done — Landed and live in production.
A domain check now asks only nameservers at public addresses, and never more than four of them. Before, the addresses of a zone's NS records went straight to Resolver.setServers.
shipped production is serving it deploy cfe12e4
A domain check now asks only nameservers at public addresses, and never more than four of them. Before, the addresses of a zone's NS records went straight to Resolver.setServers. Because the zone belongs to whoever adds the domain, an app admin could point the forge's resolver at loopback, private ranges or the metadata address, then read what happened from the said sentence.
What changed in src/apps/domains.ts
- Filtering:
nameserversForremoves duplicate addresses, keeps only those thatisPublicAddressfromsrc/apps/egress.tsaccepts, and keeps at mostMAX_NAMESERVERS(4). That drops loopback, RFC1918, link-local and 169.254, 100.64/10, multicast and ULA. - No public server left:
- If the box's own resolver already found the record, its answer stands and the zone's servers are not asked.
- Otherwise the step is skipped and the user sees: "…skipped the zone's own nameservers, which are only at private or local addresses; point the zone's NS records at public nameservers."
- Timeout cancels the query:
lookupnow hands anAbortSignalto the lookup and aborts it when the 8 s timeout fires.withAuthoritypasses that signal on toresolveTxtAt. The defaultresolveTxtAtis a newaskServers, which callscancel()on itsResolverwhen the signal aborts. It also accepts an injected resolver so a test can check the cancel. - No raw error codes: any failure from the zone's servers other than "no record" becomes "failed at the zone's own nameservers". Errors from the box's own resolver still show their code, as before.
Tests
test/domain-nameservers.test.tsis new. A zone whose NS hosts resolve to127.0.0.1and10.0.0.1gets no TXT query at all. It also covers:- the other ranges being dropped while a public address is kept;
- the four-server limit;
- the box's resolver answer winning over private nameservers;
- no raw error code in the sentence;
- the timeout aborting its signal;
askServerscancelling its resolver.
Against main's
domains.tsthe file fails: main has none of these exports.- One fixture changed in
test/app-domains.test.ts: its nameserver was192.0.2.53(TEST-NET-1), which the new filter rightly refuses. It is now198.51.100.53, which passes the filter. The test's assertions are unchanged.
Checks run: bun scripts/gate.ts --fix (no changes) and bun x tsc --noEmit pass. scripts/fast.ts named 2198 files, too many to run here, so I ran the six domain test files instead (domain-nameservers, app-domains, core-domains, domain-dns, mcp-app-domains, settings-app-domains): 65 pass. The sandbox cannot send real DNS (UDP gets ECONNREFUSED), so the real Resolver.cancel() is checked only through the injected fake. The keep_plan and estimate tools were not available in this run, so no plan was kept on the issue and no time was estimated.
To try it: bun test test/domain-nameservers.test.ts
🤖 Generated with Claude Code
A domain check no longer queries a nameserver that resolves to a private, loopback, cloud-metadata or tailnet address (#15202). Before any lookup is sent, src/apps/domains.ts checks each nameserver's address. When a zone has no public nameserver left, the check fails with "point the zone's NS records at public nameservers" rather than querying the internal one. lookup now takes an abort signal and a timeout. When the timeout fires, the lookup still in flight is stopped rather than left querying in the background. Tests for this are in test/domain-nameservers.test.ts, and test/app-domains.test.ts is adjusted to match.
The last check failed on test/timers-named.test.ts. That test keeps a list of every server-side timer callback that is allowed outside during, matched by how the callback starts. The lookup timer callback had been rewritten to also abort, so it no longer matched its entry () => reject(. The callback is back to plain () => reject(...), and the abort moved to lookup's finally block. Aborting a lookup that has already finished does nothing, so behaviour is the same. The allowed list is unchanged.
The check's log also reported a failure in test/merge-queue-gate-result.test.ts ("a red gate's two failing tests are kept…"). That file doesn't touch domains, and it passed all four times I ran it on this branch. I treated it as flaky and left it alone; if it fails again on this push, it needs a closer look.
On this branch, test/timers-named.test.ts, test/domain-nameservers.test.ts and test/app-domains.test.ts pass, as do bun scripts/gate.ts --fix and bun x tsc --noEmit.
🤖 Generated with Claude Code
Approved. Private, loopback, metadata, CGNAT, multicast and ULA nameservers are filtered with isPublicAddress, capped at 4, and a timeout aborts the signal that cancels the Resolver. The authority path no longer leaks raw codes, and the tests cover each of these. This change has no page or terminal surface, so the preview adds nothing to judge. Two things to do next: (1) nameserversFor slices to the first 4 NS hosts before resolving them, so a zone whose first 4 NS hosts are private and whose 5th is public is treated as having no public server. Resolve all of them, filter, then cap. (2) The condition in withAuthority that swallows NO_PUBLIC_NAMESERVER when the box resolver already has an answer is over-long; wrap it.
Approved. The earlier head 0eb07b530e47 is not in this clone, so I judged the landed change. Every nameserver address is filtered through isPublicAddress, deduplicated and capped at 4 before Resolver.setServers. When no public server is left, the user gets a plain sentence. A record the box resolver already found still stands. Raw resolver codes from the zone servers no longer reach the sentence. A timed-out lookup now cancels its in-flight query. The new tests would fail on main, and the one changed fixture (192.0.2.53 to 198.51.100.53) is justified. No new dependency, and no page or terminal surface was added, so no feature doc is needed.
Next, non-blocking: (1) nameserversFor only calls resolve4, so a zone with IPv6-only nameservers falls through to ENOTFOUND. Consider resolve6 with the same filter. (2) Add a test that the ULA tailnet range fd7a:115c:a1e0::/48 is dropped, since tailnet is in the title.
A domain check now asks only nameservers at public addresses, and never more than four of them. Before, the addresses of a zone's NS records went straight to
Resolver.setServers. Because the zone belongs to whoever adds the domain, an app admin could point the forge's resolver at loopback, private ranges or the metadata address, then read what happened from thesaidsentence.What changed in
src/apps/domains.tsnameserversForremoves duplicate addresses, keeps only those thatisPublicAddressfromsrc/apps/egress.tsaccepts, and keeps at mostMAX_NAMESERVERS(4). That drops loopback, RFC1918, link-local and 169.254, 100.64/10, multicast and ULA.lookupnow hands anAbortSignalto the lookup and aborts it when the 8 s timeout fires.withAuthoritypasses that signal on toresolveTxtAt. The defaultresolveTxtAtis a newaskServers, which callscancel()on itsResolverwhen the signal aborts. It also accepts an injected resolver so a test can check the cancel.Tests
test/domain-nameservers.test.tsis new. A zone whose NS hosts resolve to127.0.0.1and10.0.0.1gets no TXT query at all. It also covers:askServerscancelling its resolver.Against main's
domains.tsthe file fails: main has none of these exports.test/app-domains.test.ts: its nameserver was192.0.2.53(TEST-NET-1), which the new filter rightly refuses. It is now198.51.100.53, which passes the filter. The test's assertions are unchanged.Checks run:
bun scripts/gate.ts --fix(no changes) andbun x tsc --noEmitpass.scripts/fast.tsnamed 2198 files, too many to run here, so I ran the six domain test files instead (domain-nameservers,app-domains,core-domains,domain-dns,mcp-app-domains,settings-app-domains): 65 pass. The sandbox cannot send real DNS (UDP getsECONNREFUSED), so the realResolver.cancel()is checked only through the injected fake. Thekeep_planandestimatetools were not available in this run, so no plan was kept on the issue and no time was estimated.To try it:
bun test test/domain-nameservers.test.ts🤖 Generated with Claude Code
Closes #15202