#3

Prevent DNS setup host mismatches

MergedstylesshOwnermerged intofrom

Summary

  • show DNS host fields in registrar-safe relative form (@, _dmarc, and the DKIM selector)
  • detect records copied to doubled domain names and distinguish host, value, and combined mismatches
  • normalize chunked TXT responses so valid DKIM records do not remain falsely missing
  • add regression coverage for doubled hostnames, registrar host formatting, and chunked DKIM answers

Validation

  • corepack pnpm test (8 passed)
  • focused ESLint on all changed source and test files
  • corepack pnpm build
  • git diff --check origin/main...HEAD
  • browser-tested mismatch guidance and verified that copying the apex host writes @

Activity

4
mikeyreviewed3mo ago
mikey3mo ago

Reviewed the diff against main (base 8a1a3d7, head 37dbd21) plus the surrounding call sites in lib/dns/records.ts, lib/demo/provider.ts, and lib/stalwart/provider.ts.

What changed: verifyRecords now takes the domain apex, tries an exact-match lookup first (matchingAnswer), then re-queries a doubled hostname (host.domain) to distinguish "record copied to the wrong host" from "record present but value differs," and normalize now extracts and concatenates quoted TXT chunks so multi-string DKIM answers compare correctly against the unquoted DB value. The UI renders a relative host (@, _dmarc, etc.) via the new relativeDnsHost, consistent with the existing normalizeHost/isRequiredKind conventions in records.ts.

Correctness check:

  • doubledHost normalization matches normalizeHost semantics (trailing dot, case) used elsewhere, and both call sites (demo/provider.ts, stalwart/provider.ts) now pass current.name consistently, so verifyRecords/relativeDnsHost see the same apex string.
  • The status ternary in components/shell/dns-records.tsx (lines ~263-277) is misleadingly indented (the : optional ? "Not added" : "Missing" block reads as if it closes an earlier branch), but ternaries are right-associative regardless of whitespace — I traced the actual nesting and it falls through correctly when mismatch is undefined. Not a bug, just worth a reflow for readability if you touch this block again.
  • matchingAnswer replaces the old loose substring check (value.includes(expected) || expected.includes(value)) with strict post-normalize equality (plus an MX priority-suffix allowance). This is a real behavior tightening — any TXT answer that isn't an exact match to the stored value will now report as a mismatch instead of silently passing. That looks intentional here (it's what makes the doubled-host/chunked-TXT detection meaningful) and is covered by doh.test.mjs, so not flagging as blocking, but call it out in case any production domain currently relies on the old fuzzy matching to show "Live" for TXT records with extra content.
  • Chunked-TXT normalization and the doubled-host lookup both stay inside the existing try/catch, so a failed second lookup still falls back to { ok: false } rather than throwing.

Tests: doh.test.mjs covers doubled-host detection (host vs host-and-value mismatch) and chunked-DKIM acceptance; parse-zone.test.mjs adds coverage for relativeDnsHost. These exercise the new branches reasonably well.

No blocking correctness or security issues found. CI (Validate application) is green and the branch is mergeable.

Non-blocking observation: the wrongHostAnswers[0] used for the "host-and-value" mismatch could, in principle, pick up an unrelated pre-existing record at the doubled hostname (not necessarily the user's own misconfiguration) and still label it as a mismatch. Given this is a heuristic UX hint rather than an authoritative check, that seems acceptable, but worth being aware of if support tickets come in about a confusing "found a different record" message.

stylessh merged commit dd61b43 into main3mo ago

Branch stylessh/fix-dns-setup-mismatches has been merged.

Checking branch