console: catch-all checks hold under the write's mutex (H5-M1 r2)
attachDomainClaim re-asks underForeignCatchall under regionalMu, where the capability doors decide, so a catch-all turned on after the door's first check is seen before the child's write. The holder's allowance under a foreign catch-all needs a verified claim, not a pending one. Verifying a pending parent that carries wildcard and catch-all, and a placements PUT creating one, meet foreignChildRefusal. That refusal now says why and names the parent's domain challenge; an owner whose DNS carries it passes (the child keeps its exact claim).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
8 files changed,
+299
−29
internal/console/apidomains.go+3 −0internal/console/apiplacements.go+9 −0internal/console/apiplacements_put_test.go+27 −0internal/console/catchallchild_test.go+150 −6internal/console/claim_alias.go+5 −0internal/console/domainattach.go+3 −0internal/console/domaincatchall.go+82 −13internal/console/domainpolicy.go+20 −10
diff --git a/internal/console/apidomains.go b/internal/console/apidomains.go| index b79272a9d..a6344a6bd 100644 |
| --- a/internal/console/apidomains.go |
| +++ b/internal/console/apidomains.go |
| @@ -624,6 +624,9 @@ func (s *Server) handleAPIDomainAttach(w http.ResponseWriter, r *http.Request) { |
| // The claim the namespace decision admitted has gone or changed. |
| jsonError(w, pe.ref.Status, pe.ref.Msg) |
| return |
| + } else if de := (*claimDoorError)(nil); errors.As(err, &de) { |
| + jsonError(w, de.ref.Status, de.ref.Msg) |
| + return |
| } else if errors.Is(err, domains.ErrHostUnavailable) { |
| // Exactly these bytes, whoever holds it: naming the holder — or even |
| // distinguishing "held by another app of yours" from "held by a |
diff --git a/internal/console/apiplacements.go b/internal/console/apiplacements.go| index 0c269395d..a1d7d9c90 100644 |
| --- a/internal/console/apiplacements.go |
| +++ b/internal/console/apiplacements.go |
| @@ -639,6 +639,15 @@ func (s *Server) handleAPIDomainPlacementsPut(w http.ResponseWriter, r *http.Req |
| return |
| } |
| } |
| + // First claim wins (security hunt H5-M1, review round 2): a claim |
| + // created with wildcard and catch-all meets the capability door's |
| + // foreign-child refusal. After the regional scan, as there. |
| + if create && wantWildcard && wantCatchall { |
| + if ref := s.foreignChildRefusal(ctx, host, acct.Sqid); ref != nil { |
| + jsonError(w, ref.Status, ref.Msg) |
| + return |
| + } |
| + } |
| // Step 7. |
| if ref := regionalReadyRefusal(boxes, now); ref != nil { |
diff --git a/internal/console/apiplacements_put_test.go b/internal/console/apiplacements_put_test.go| index 2a96f2329..30fb26348 100644 |
| --- a/internal/console/apiplacements_put_test.go |
| +++ b/internal/console/apiplacements_put_test.go |
| @@ -1067,3 +1067,30 @@ func TestPlacementsPutPlanCapComesFirst(t *testing.T) { |
| w.mustPut(t, rdHost, rdSet("uk="+rdUK)) |
| w.requireNoClaim(t, "free.example.com", "a capped create") |
| } |
| + |
| +// TestPlacementsPutCatchallOverForeignChild (review round 2, Fable N3): |
| +// the placements PUT that creates a claim with wildcard and catch-all |
| +// meets the capability door's foreign-child refusal, and writes nothing. |
| +func TestPlacementsPutCatchallOverForeignChild(t *testing.T) { |
| + const zone = "acme.example.org" |
| + w := newRegionalWorld(t, "code-rdput-foreign-child") |
| + w.fx.srv.delegationZone = zone |
| + w.fx.srv.lookupCNAME = func(_ context.Context, name string) (string, error) { |
| + return name + "." + zone + ".", nil |
| + } |
| + noCatchallProof(w.fx) |
| + const parent = "fox.example.com" |
| + if _, _, err := domains.AttachClaim(context.Background(), w.fx.rel, domains.Claim{Host: "kid." + parent, Account: "zzz", |
| + App: "blog", Route: "blog.example.net", CreatedAt: time.Now().UTC().Format(time.RFC3339)}); err != nil { |
| + t.Fatal(err) |
| + } |
| + both := rdBoth() |
| + both.Wildcard, both.Catchall = boolp(true), boolp(true) |
| + code, out := w.put(t, parent, both) |
| + if proof := w.fx.srv.domainChallenge(parent, w.fx.sqid); code != http.StatusConflict || !strings.Contains(out, proof.Name) { |
| + t.Fatalf("PUT with catch-all over a foreign child = %d %s, want 409 naming %s", code, out, proof.Name) |
| + } |
| + w.requireNoClaim(t, parent, "a catch-all over a foreign child") |
| + // Without the catch-all, the same PUT creates. |
| + w.mustPut(t, parent, rdBoth()) |
| +} |
diff --git a/internal/console/catchallchild_test.go b/internal/console/catchallchild_test.go| index d5bd81a1a..53e3b971f 100644 |
| --- a/internal/console/catchallchild_test.go |
| +++ b/internal/console/catchallchild_test.go |
| @@ -2,7 +2,9 @@ package console |
| import ( |
| "context" |
| + "errors" |
| "net/http" |
| + "strings" |
| "testing" |
| "time" |
| @@ -32,18 +34,41 @@ func catchallChildWorld(t *testing.T, code, childAccount string) (*consoleFixtur |
| } |
| // TestCatchallRefusedOverForeignChild: turning on wildcard and catch-all |
| -// over a parent is the neutral 409 while another account holds a verified |
| -// child, and nothing changes. |
| +// over a parent is a 409 while another account holds a verified child, and |
| +// nothing changes. The refusal says why and names the way through (review |
| +// round 2, Fable N4): the parent's domain challenge. Once the owner's DNS |
| +// carries it, the catch-all turns on; the child keeps its exact claim. |
| func TestCatchallRefusedOverForeignChild(t *testing.T) { |
| fx, owner := catchallChildWorld(t, "code-h5-child-foreign", "cdef") |
| - code, _, out := rawReq(t, http.MethodPost, domainsURL(fx, "bab", "titogo"), owner, |
| - `{"host":"victim.example","route":"go.tito.io","wildcard":true,"catchall":true}`) |
| - if code != http.StatusConflict || cutoverErrorOf(out) != hostUnavailableMsg { |
| - t.Fatalf("catch-all over a foreign child = %d %s, want 409 %q", code, out, hostUnavailableMsg) |
| + noCatchallProof(fx) |
| + body := `{"host":"victim.example","route":"go.tito.io","wildcard":true,"catchall":true}` |
| + code, _, out := rawReq(t, http.MethodPost, domainsURL(fx, "bab", "titogo"), owner, body) |
| + proof := fx.srv.domainChallenge("victim.example", "bab") |
| + msg := cutoverErrorOf(out) |
| + if code != http.StatusConflict || !strings.Contains(msg, proof.Name) || !strings.Contains(msg, proof.Value) { |
| + t.Fatalf("catch-all over a foreign child = %d %s, want 409 naming TXT %s = %s", code, out, proof.Name, proof.Value) |
| + } |
| + if strings.Contains(msg, "shop.victim.example") || strings.Contains(msg, "cdef") { |
| + t.Fatalf("the refusal %q names the child or its holder", msg) |
| } |
| if c := claimOf(t, fx, "victim.example"); c.Wildcard || c.Catchall { |
| t.Fatalf("parent after the refusal = %+v, want unchanged", *c) |
| } |
| + fx.srv.lookupTXT = func(_ context.Context, name string) ([]string, error) { |
| + if name == proof.Name { |
| + return []string{proof.Value}, nil |
| + } |
| + return nil, errors.New("no such record") |
| + } |
| + if code, _, out := rawReq(t, http.MethodPost, domainsURL(fx, "bab", "titogo"), owner, body); code != http.StatusOK { |
| + t.Fatalf("catch-all with the parent's challenge published = %d %s, want 200", code, out) |
| + } |
| + if c := claimOf(t, fx, "victim.example"); !c.Wildcard || !c.Catchall { |
| + t.Fatalf("parent = %+v, want wildcard and catch-all on", *c) |
| + } |
| + if c := claimOf(t, fx, "shop.victim.example"); c.Account != "cdef" || c.Pending { |
| + t.Fatalf("child = %+v, want cdef's verified claim kept", *c) |
| + } |
| } |
| // TestCatchallOverOwnChildAllowed: the same account's child is no bar. |
| @@ -81,3 +106,122 @@ func TestChildPredatingCatchallReattaches(t *testing.T) { |
| t.Fatalf("the earlier child's re-attach = %d %s, want 200", code, out) |
| } |
| } |
| + |
| +// bobWidgets makes account cdef with app widgets and returns bob's token. |
| +func bobWidgets(t *testing.T, fx *consoleFixture, code string) string { |
| + t.Helper() |
| + now := time.Now() |
| + if err := fx.st.CreateAccount(42, "cdef", "widgets", "bob@keymail.dev", now); err != nil { |
| + t.Fatal(err) |
| + } |
| + if _, err := fx.st.CreateAppIn(42, "widgets", "bob@keymail.dev", now); err != nil { |
| + t.Fatal(err) |
| + } |
| + return cliToken(t, fx, "bob@keymail.dev", code) |
| +} |
| + |
| +// TestPendingChildUnderForeignCatchallStaysPending (review round 2, Astra |
| +// finding 3): a child reservation that is only pending does not bar the |
| +// parent's catch-all, so it gets no holder's allowance under it either: |
| +// once the catch-all is on, publishing the child's proof and re-attaching |
| +// is the neutral 409, and the reservation stays pending. |
| +func TestPendingChildUnderForeignCatchallStaysPending(t *testing.T) { |
| + const zone = "acme.oncarlos.com" |
| + fx, owner := domainOwnerFixture(t, "code-h5-pending-child") |
| + fx.srv.delegationZone = zone |
| + fx.srv.lookupCNAME = func(_ context.Context, name string) (string, error) { |
| + return name + "." + zone + ".", nil |
| + } |
| + noCatchallProof(fx) |
| + fx.srv.cfg.DomainProof = true |
| + ctx := context.Background() |
| + if _, _, err := domains.AttachClaim(ctx, fx.rel, domains.Claim{Host: "victim.example", Account: "bab", App: "titogo", |
| + Route: "go.tito.io", CreatedAt: time.Now().UTC().Format(time.RFC3339)}); err != nil { |
| + t.Fatal(err) |
| + } |
| + bob := bobWidgets(t, fx, "code-h5-pending-child-bob") |
| + child := attachBody("shop.victim.example", "w.attacker.example") |
| + if code, _, out := rawReq(t, http.MethodPost, domainsURL(fx, "cdef", "widgets"), bob, child); code != http.StatusOK { |
| + t.Fatalf("the child's reservation = %d %s", code, out) |
| + } |
| + if c := claimOf(t, fx, "shop.victim.example"); !c.Pending { |
| + t.Fatalf("test bug: the child = %+v, want pending", *c) |
| + } |
| + if code, _, out := rawReq(t, http.MethodPost, domainsURL(fx, "bab", "titogo"), owner, |
| + `{"host":"victim.example","route":"go.tito.io","wildcard":true,"catchall":true}`); code != http.StatusOK { |
| + t.Fatalf("catch-all over a pending child = %d %s, want 200", code, out) |
| + } |
| + proof := fx.srv.domainChallenge("shop.victim.example", "cdef") |
| + fx.srv.lookupTXT = func(_ context.Context, name string) ([]string, error) { |
| + if name == proof.Name { |
| + return []string{proof.Value}, nil |
| + } |
| + return nil, errors.New("no such record") |
| + } |
| + code, _, out := rawReq(t, http.MethodPost, domainsURL(fx, "cdef", "widgets"), bob, child) |
| + if code != http.StatusConflict || cutoverErrorOf(out) != hostUnavailableMsg { |
| + t.Fatalf("the pending child's proven re-attach = %d %s, want the neutral 409", code, out) |
| + } |
| + if c := claimOf(t, fx, "shop.victim.example"); !c.Pending { |
| + t.Fatalf("the child under the foreign catch-all = %+v, want still pending", *c) |
| + } |
| +} |
| + |
| +// TestChildWriteRechecksTheCatchallUnderTheMutex (review round 2, Astra |
| +// finding 2): the attach doors' catch-all check (heldElsewhere) runs |
| +// before regionalMu, so a parent's catch-all can come on between it and |
| +// the write. attachDomainClaim, the write both attach doors share, judges |
| +// the parent again under the mutex: a child that reaches it after another |
| +// account's catch-all came on writes nothing. |
| +func TestChildWriteRechecksTheCatchallUnderTheMutex(t *testing.T) { |
| + fx, _ := catchallChildWorld(t, "code-h5-child-race", "bab") |
| + ctx := context.Background() |
| + if _, err := domains.SetClaimCapabilities(ctx, fx.rel, "victim.example", "bab", "titogo", true, true); err != nil { |
| + t.Fatal(err) |
| + } |
| + bobWidgets(t, fx, "code-h5-child-race-bob") |
| + acct, err := fx.st.AccountBySqid("cdef") |
| + if err != nil || acct == nil { |
| + t.Fatalf("account cdef: %+v %v", acct, err) |
| + } |
| + _, _, _, err = fx.srv.attachDomainClaim(ctx, acct, "widgets", domains.Claim{Host: "late.victim.example", Account: "cdef", |
| + App: "widgets", Route: "w.attacker.example", CreatedAt: time.Now().UTC().Format(time.RFC3339)}, time.Now(), nil) |
| + if !errors.Is(err, domains.ErrHostUnavailable) { |
| + t.Fatalf("a child write under another account's live catch-all = %v, want ErrHostUnavailable", err) |
| + } |
| + claimAbsent(t, fx, "late.victim.example") |
| +} |
| + |
| +// TestVerifyingAPendingCatchallScansItsChildren (review round 2, Astra |
| +// finding 3): a pending parent may carry wildcard and catch-all, and the |
| +// re-attach that verifies it turns the catch-all on without the capability |
| +// door. That re-attach meets the same foreign-child refusal: here a pending |
| +// parent left from when domain proof was on, verified by a bare re-attach |
| +// once it is off, while another account holds a verified child. |
| +func TestVerifyingAPendingCatchallScansItsChildren(t *testing.T) { |
| + fx, owner := domainOwnerFixture(t, "code-h5-pending-parent") |
| + noCatchallProof(fx) |
| + ctx := context.Background() |
| + if _, _, _, err := domains.AttachClaimProven(ctx, fx.rel, domains.Claim{Host: "victim.example", Account: "bab", App: "titogo", |
| + Route: "go.tito.io", CreatedAt: time.Now().UTC().Format(time.RFC3339)}, time.Now(), func() bool { return false }); err != nil { |
| + t.Fatal(err) |
| + } |
| + if _, err := domains.SetClaimCapabilities(ctx, fx.rel, "victim.example", "bab", "titogo", true, true); err != nil { |
| + t.Fatal(err) |
| + } |
| + if _, _, err := domains.AttachClaim(ctx, fx.rel, domains.Claim{Host: "shop.victim.example", Account: "cdef", App: "widgets", |
| + Route: "w.attacker.example", CreatedAt: time.Now().UTC().Format(time.RFC3339)}); err != nil { |
| + t.Fatal(err) |
| + } |
| + if c := claimOf(t, fx, "victim.example"); !c.Pending || !c.Wildcard || !c.Catchall { |
| + t.Fatalf("test bug: parent = %+v, want pending with both capabilities", *c) |
| + } |
| + code, _, out := rawReq(t, http.MethodPost, domainsURL(fx, "bab", "titogo"), owner, attachBody("victim.example", "go.tito.io")) |
| + proof := fx.srv.domainChallenge("victim.example", "bab") |
| + if code != http.StatusConflict || !strings.Contains(cutoverErrorOf(out), proof.Name) { |
| + t.Fatalf("verifying a pending catch-all over a foreign child = %d %s, want 409 naming %s", code, out, proof.Name) |
| + } |
| + if c := claimOf(t, fx, "victim.example"); !c.Pending { |
| + t.Fatalf("parent after the refusal = %+v, want still pending", *c) |
| + } |
| +} |
diff --git a/internal/console/claim_alias.go b/internal/console/claim_alias.go| index 94ede5240..22beeae03 100644 |
| --- a/internal/console/claim_alias.go |
| +++ b/internal/console/claim_alias.go |
| @@ -44,6 +44,11 @@ func (s *Server) attachDomainClaim(ctx context.Context, acct *Account, app strin |
| if !s.cfg.HostClaim { |
| s.regionalMu.Lock() |
| defer s.regionalMu.Unlock() |
| + // The catch-all checks again, under the mutex the capability |
| + // doors decide under (security hunt H5-M1, review round 2). |
| + if err := s.attachCatchallRefusalLocked(ctx, acct.Sqid, app, incoming.Host); err != nil { |
| + return false, false, false, err |
| + } |
| return domains.AttachClaimProven(ctx, store, incoming, now, prove) |
| } |
| a := s.cfg.ClaimAuthority |
diff --git a/internal/console/domainattach.go b/internal/console/domainattach.go| index 765d8f848..ec4ae85eb 100644 |
| --- a/internal/console/domainattach.go |
| +++ b/internal/console/domainattach.go |
| @@ -847,6 +847,9 @@ func claimRefusal(host string, err error) *doorRefusal { |
| if pe := (*claimPinError)(nil); errors.As(err, &pe) { |
| return pe.ref |
| } |
| + if de := (*claimDoorError)(nil); errors.As(err, &de) { |
| + return de.ref |
| + } |
| if msg, ok := claimAliasRefusal(err); ok { |
| return &doorRefusal{Status: http.StatusConflict, Msg: msg} |
| } |
diff --git a/internal/console/domaincatchall.go b/internal/console/domaincatchall.go| index 75f9e38d5..657a204a9 100644 |
| --- a/internal/console/domaincatchall.go |
| +++ b/internal/console/domaincatchall.go |
| @@ -224,8 +224,14 @@ func (s *Server) heldElsewhere(ctx context.Context, host, sqid, app string) *doo |
| // capability door refuses turning a catch-all on over another account's |
| // existing child (foreignChildRefusal), so a child that predates the |
| // catch-all keeps its name, and its holder's re-attach passes here, the |
| -// allowance catchallInstanceName makes. The parent's own account may carve |
| -// names out, as before. |
| +// allowance catchallInstanceName makes. Only a verified child: a pending |
| +// one did not bar the catch-all (foreignChildRefusal skips it), so it may |
| +// not be proved and served under it either (review round 2). The parent's |
| +// own account may carve names out, as before. |
| +// |
| +// attachDomainClaim asks again under regionalMu, where the capability |
| +// doors decide, so a catch-all turned on after the door's first ask is |
| +// still seen before the write. |
| // |
| // One GET (usually a 404), and a second only under such a catch-all. |
| func (s *Server) underForeignCatchall(ctx context.Context, host, sqid, app string) (bool, error) { |
| @@ -243,7 +249,7 @@ func (s *Server) underForeignCatchall(ctx context.Context, host, sqid, app strin |
| if c.Pending || !c.Wildcard || !c.Catchall || c.Account == sqid { |
| return false, nil |
| } |
| - if own, err := domains.GetClaim(ctx, s.cfg.Releases, host); err == nil && own.Account == sqid && own.App == app { |
| + if own, err := domains.GetClaim(ctx, s.cfg.Releases, host); err == nil && own.Account == sqid && own.App == app && !own.Pending { |
| return false, nil |
| } else if err != nil && !errors.Is(err, os.ErrNotExist) { |
| return false, err |
| @@ -251,13 +257,76 @@ func (s *Server) underForeignCatchall(ctx context.Context, host, sqid, app strin |
| return true, nil |
| } |
| -// foreignChildRefusal is the capability door's half of first-claim-wins |
| +// attachCatchallRefusalLocked is attachDomainClaim's catch-all check, |
| +// under regionalMu (security hunt H5-M1, review round 2), so the capability |
| +// doors cannot turn a catch-all on between it and the write: |
| +// |
| +// - host is one label below another account's live catch-all |
| +// (underForeignCatchall): domains.ErrHostUnavailable, the neutral 409 |
| +// heldElsewhere gives; |
| +// - host is the caller's own pending claim carrying wildcard and |
| +// catch-all: the re-attach that verifies it turns the catch-all on, so |
| +// it meets the capability door's foreignChildRefusal. |
| +// |
| +// A refusal with its own answer comes back as a *claimDoorError. |
| +func (s *Server) attachCatchallRefusalLocked(ctx context.Context, sqid, app, host string) error { |
| + held, err := s.underForeignCatchall(ctx, host, sqid, app) |
| + if err != nil { |
| + return err |
| + } |
| + if held { |
| + return domains.ErrHostUnavailable |
| + } |
| + cur, err := domains.GetClaim(ctx, s.cfg.Releases, host) |
| + if errors.Is(err, os.ErrNotExist) { |
| + return nil |
| + } |
| + if err != nil { |
| + return err |
| + } |
| + if cur.Account == sqid && cur.App == app && cur.Pending && cur.Wildcard && cur.Catchall { |
| + if ref := s.foreignChildRefusal(ctx, host, sqid); ref != nil { |
| + return &claimDoorError{ref} |
| + } |
| + } |
| + return nil |
| +} |
| + |
| +// claimDoorError is a claim write refused with its own door answer: both |
| +// attach doors answer ref as it stands (claimRefusal, handleAPIDomainAttach). |
| +type claimDoorError struct{ ref *doorRefusal } |
| + |
| +func (e *claimDoorError) Error() string { return "console: claim refused: " + e.ref.Msg } |
| + |
| +// catchallOverForeignChildMsg is the refusal of a catch-all over another |
| +// account's child (review round 2, Fable N4, the controller's ruling: keep |
| +// the refusal, but bounded and with its reason). It names the reason and |
| +// the one way through, proving control of parent with its domain |
| +// challenge, and never the child or its holder. |
| +func catchallOverForeignChildMsg(parent string, proof dnsRecord) string { |
| + return "another account already holds a name directly under " + parent + ", so a catch-all on " + parent + |
| + " is refused. To turn it on, show that " + parent + " is yours: publish TXT " + proof.Name + " = \"" + proof.Value + |
| + "\" and try again. The other account's name keeps working." |
| +} |
| + |
| +// foreignChildRefusal is the capability doors' half of first-claim-wins |
| // (security hunt H5-M1): turning on Wildcard and Catchall together over |
| // parent is refused while ANOTHER account holds a verified claim one label |
| // below it, or the listing shows such a name it could not read. The |
| // enabling CNAME check names no account and is made once, so it is no |
| -// reason for the parent to take a name someone else already serves. The |
| -// neutral 409, as heldElsewhere answers; a listing error is a retry. |
| +// reason for the parent to take a name someone else already serves. A |
| +// listing error is a retry. |
| +// |
| +// The refusal is bounded (review round 2, the controller's ruling on Fable |
| +// N4): an account whose parent's DNS carries its domain challenge right |
| +// now (domainChallengeHeld) has shown the domain is its own, and passes. |
| +// The child keeps its exact claim, which beats the catch-all's star at the |
| +// edge, so the catch-all takes nothing from it. Otherwise the 409 says |
| +// why and names that record (catchallOverForeignChildMsg), rather than the |
| +// neutral answer that left the owner with nothing to act on. Asked only |
| +// when there is a child to answer for, so the common case makes no lookup. |
| +// The doors: setDomainCapabilities, the placements PUT that creates a |
| +// catch-all, and attachDomainClaim verifying a pending one. |
| func (s *Server) foreignChildRefusal(ctx context.Context, parent, sqid string) *doorRefusal { |
| claims, unread, err := s.claims.ListWithUnread(ctx, s.cfg.Releases) |
| if err != nil { |
| @@ -268,17 +337,17 @@ func (s *Server) foreignChildRefusal(ctx context.Context, parent, sqid string) * |
| label, ok := strings.CutSuffix(h, "."+parent) |
| return ok && label != "" && label != "*" && !strings.Contains(label, ".") |
| } |
| + blocked := false |
| for _, c := range claims { |
| - if under(c.Host) && c.Account != sqid && !c.Pending { |
| - return claimRefusal(parent, domains.ErrHostUnavailable) |
| - } |
| + blocked = blocked || (under(c.Host) && c.Account != sqid && !c.Pending) |
| } |
| for _, u := range unread { |
| - if under(u.Host) { |
| - return claimRefusal(parent, domains.ErrHostUnavailable) |
| - } |
| + blocked = blocked || under(u.Host) |
| } |
| - return nil |
| + if !blocked || s.domainChallengeHeld(ctx, parent, sqid) { |
| + return nil |
| + } |
| + return &doorRefusal{Status: http.StatusConflict, Msg: catchallOverForeignChildMsg(parent, s.domainChallenge(parent, sqid))} |
| } |
| // catchallInstanceName reports whether host is a one-label name under |
diff --git a/internal/console/domainpolicy.go b/internal/console/domainpolicy.go| index 55fb123b0..1a5a4e5cb 100644 |
| --- a/internal/console/domainpolicy.go |
| +++ b/internal/console/domainpolicy.go |
| @@ -302,16 +302,26 @@ func (s *Server) domainProver(ctx context.Context, v namespaceView, host, accoun |
| if !s.cfg.DomainProof || s.domainProofExempt(v, host, account) { |
| return true |
| } |
| - want := domains.ChallengeToken(s.challengeDeployment(), account, host) |
| - got, err := s.lookupTXT(ctx, domains.ChallengeName(host)) |
| - if err != nil { |
| - return false |
| - } |
| - for _, v := range got { |
| - if strings.TrimSpace(v) == want { |
| - return true |
| - } |
| - } |
| + return s.domainChallengeHeld(ctx, host, account) |
| + } |
| +} |
| + |
| +// domainChallengeHeld reports whether ChallengeName(host) carries |
| +// account's token right now, whatever DomainProof says. Any lookup failure |
| +// is "not held". |
| +func (s *Server) domainChallengeHeld(ctx context.Context, host, account string) bool { |
| + if s.lookupTXT == nil { |
| return false |
| } |
| + want := domains.ChallengeToken(s.challengeDeployment(), account, host) |
| + got, err := s.lookupTXT(ctx, domains.ChallengeName(host)) |
| + if err != nil { |
| + return false |
| + } |
| + for _, v := range got { |
| + if strings.TrimSpace(v) == want { |
| + return true |
| + } |
| + } |
| + return false |
| } |