broker: /point and /offboard accept any caller — a live community's DNS can be repointed or deleted #322

Closed
opened 2026-08-07 17:32:29 +00:00 by ben · 2 comments
Owner

NewHandler builds a bare http.ServeMux with no middleware (broker/internal/broker/http.go:46-103) and main.go serves it directly (broker/cmd/broker/main.go:31-38). brokerclient sends only Content-Type — no token, no signature, no ownership proof (internal/brokerclient/client.go:100-113).

Route Checks performed Missing
/v1/subdomains/claim slug free, not in reservedSlugs — (open by design)
/v1/subdomains/point host + ip non-empty, host previously claimed proof the caller owns the host
/v1/subdomains/offboard host non-empty, host previously claimed proof the caller owns the host

Any caller who knows a claimed host can:

  • repoint a live community's A record at an address they control — and then obtain a publicly-trusted certificate for that name via HTTP-01, which does not need acme-dns — i.e. a full MITM of the community's web surface; or
  • delete the community's entire record set and release its slug.

reservedSlugs does not help: it fences Matou's own infra labels, not community-owned names (broker/internal/broker/broker.go:99-112, ADR 0128). The Cloudflare token is zone-scoped to idss.nz with no per-subname fence, so the application layer is the only guard — and it currently checks nothing about the caller.

Relationship to #278

This issue originally also covered the in-memory reservation ledger. That half is #278 (closed) — its durable ReservationStore fix is in the working tree (broker/internal/broker/store.go). Persistence closes the "restart hands the name away" path; it does not close this one. An attacker never needed a restart: point and offboard accept any caller for an already-claimed host, which is the normal steady state.

Narrowed 2026-08-07 once #278 was found.

Definition of done

  • A mutation of an existing host requires proof the caller owns it. Likely shape: a claim-time secret returned once to the claimant and required on every later point / offboard for that host. ADR 0118:66-69 rules that gateway credentials stay out of the apex zone, so a zone-scoped credential is not the answer.
  • A decision on hosts claimed before the secret existed (the durable ledger from #278 has no secret column).
  • Contract tests: unauthenticated point rejected; wrong-secret point rejected; correct-secret point accepted; same for offboard.

Ruled by a human — the auth model is a design decision, not an integration.


Found 2026-08-07 while scoping home-gateway reachability. Full trace in docs/research/2026-08-07-home-gateway-reachability-scope.md. Blocks #330 (the address heartbeat), which would call /point on a timer.

`NewHandler` builds a bare `http.ServeMux` with no middleware (`broker/internal/broker/http.go:46-103`) and `main.go` serves it directly (`broker/cmd/broker/main.go:31-38`). `brokerclient` sends only `Content-Type` — no token, no signature, no ownership proof (`internal/brokerclient/client.go:100-113`). | Route | Checks performed | Missing | |---|---|---| | `/v1/subdomains/claim` | slug free, not in `reservedSlugs` | — (open by design) | | `/v1/subdomains/point` | host + ip non-empty, host previously claimed | **proof the caller owns the host** | | `/v1/subdomains/offboard` | host non-empty, host previously claimed | **proof the caller owns the host** | Any caller who knows a claimed host can: - **repoint a live community's A record** at an address they control — and then obtain a publicly-trusted certificate for that name via HTTP-01, which does not need acme-dns — i.e. a full MITM of the community's web surface; or - **delete the community's entire record set** and release its slug. `reservedSlugs` does not help: it fences Matou's own infra labels, not community-owned names (`broker/internal/broker/broker.go:99-112`, ADR 0128). The Cloudflare token is zone-scoped to `idss.nz` with no per-subname fence, so the application layer is the only guard — and it currently checks nothing about the caller. ## Relationship to #278 This issue originally also covered the in-memory reservation ledger. **That half is #278 (closed)** — its durable `ReservationStore` fix is in the working tree (`broker/internal/broker/store.go`). Persistence closes the "restart hands the name away" path; it does **not** close this one. An attacker never needed a restart: `point` and `offboard` accept any caller for an already-claimed host, which is the normal steady state. Narrowed 2026-08-07 once #278 was found. ## Definition of done - A mutation of an existing host requires proof the caller owns it. Likely shape: a claim-time secret returned once to the claimant and required on every later `point` / `offboard` for that host. ADR 0118:66-69 rules that gateway credentials stay out of the apex zone, so a zone-scoped credential is not the answer. - A decision on hosts claimed before the secret existed (the durable ledger from #278 has no secret column). - Contract tests: unauthenticated point rejected; wrong-secret point rejected; correct-secret point accepted; same for offboard. Ruled by a human — the auth model is a design decision, not an integration. --- Found 2026-08-07 while scoping home-gateway reachability. Full trace in `docs/research/2026-08-07-home-gateway-reachability-scope.md`. Blocks #330 (the address heartbeat), which would call `/point` on a timer.
ben changed title from broker: /point and /offboard are unauthenticated, and the reservation ledger is in-memory to broker: /point and /offboard accept any caller — a live community's DNS can be repointed or deleted 2026-08-07 17:59:53 +00:00
Author
Owner

Ruled by Ben 2026-08-08 (decision sweep) → ADR 0135 (1716193, on main): a claim-time secret, returned once in the claim response, stored in community state, required on every later point/offboard for that host. Legacy hosts adopt on first caller (trust on first use) — the first-mover risk on the alpha-era test claims is knowingly accepted; no unauthenticated grandfather path survives adoption. Definition of done stands as written, plus legacy-adoption contract tests (secretless host + first presented secret binds; a second caller with a different secret is refused). → ready-for-agent. Unblocks #330 (now agent-blocked on this).

Ruled by Ben 2026-08-08 (decision sweep) → **ADR 0135** (`1716193`, on main): a claim-time secret, returned once in the claim response, stored in community state, required on every later `point`/`offboard` for that host. Legacy hosts **adopt on first caller** (trust on first use) — the first-mover risk on the alpha-era test claims is knowingly accepted; no unauthenticated grandfather path survives adoption. Definition of done stands as written, plus legacy-adoption contract tests (secretless host + first presented secret binds; a second caller with a different secret is refused). → `ready-for-agent`. Unblocks #330 (now `agent-blocked` on this).
Author
Owner

Done — shipped as ADR 0135's claim-secret model (on main, eba4d53..a0b67f7).

What landed

  • Registry.Claim mints a 32-byte CSPRNG secret, stores it against the slug, and returns it once in the claim response (a re-claim of a taken slug leaks no secret).
  • New Registry.Authorize gates every mutation: no secret -> ErrSecretRequired (401), wrong secret -> ErrSecretMismatch (403, constant-time compare), correct -> allowed. Issuer.Point/Offboard take the secret; the HTTP handler reads Authorization: Bearer.
  • Legacy hosts adopt on first caller (ADR 0135): a slug with an empty stored secret binds the first secret presented (TOFU) and durably refuses a different one after — no unauthenticated grandfather path survives adoption.
  • The durable ledger (#278) grew a secret column: ReservationStore persists a slug->secret map as schema v2; a pre-secret v1 document (bare slug list) still loads (every slug a secretless legacy name) and is rewritten v2 on next save; any other version still refused loudly.
  • brokerclient sends the secret and captures it at claim; founding threads it claim -> SubdomainClaim.Secret -> AddressChoice.Secret (persisted) -> wireName's PointSubdomain.

Contract tests (all requested + legacy adoption)

  • Broker HTTP seam: unauthenticated point/offboard -> 401, wrong-secret -> 403, correct-secret -> 204 (both verbs); legacy host adopts first secret over HTTP then refuses a second.
  • Registry seam: Authorize unknown/missing/wrong/correct; secret survives a restart; a v1 ledger loads and adopts on first caller (durable across restart).
  • Founding + brokerclient seams: the secret round-trips claim -> point.

go build/vet/test/gofmt/golangci-lint green across both modules (full go-ci gate ran on push). Hosts claimed before the secret existed are handled by first-caller adoption exactly as ADR 0135 rules. Unblocks #330.

Done — shipped as ADR 0135's claim-secret model (on main, `eba4d53..a0b67f7`). **What landed** - `Registry.Claim` mints a 32-byte CSPRNG secret, stores it against the slug, and returns it **once** in the claim response (a re-claim of a taken slug leaks no secret). - New `Registry.Authorize` gates every mutation: no secret -> `ErrSecretRequired` (**401**), wrong secret -> `ErrSecretMismatch` (**403**, constant-time compare), correct -> allowed. `Issuer.Point`/`Offboard` take the secret; the HTTP handler reads `Authorization: Bearer`. - **Legacy hosts adopt on first caller** (ADR 0135): a slug with an empty stored secret binds the first secret presented (TOFU) and durably refuses a different one after — no unauthenticated grandfather path survives adoption. - The durable ledger (#278) grew a secret column: `ReservationStore` persists a slug->secret map as **schema v2**; a pre-secret **v1** document (bare slug list) still loads (every slug a secretless legacy name) and is rewritten v2 on next save; any other version still refused loudly. - `brokerclient` sends the secret and captures it at claim; `founding` threads it claim -> `SubdomainClaim.Secret` -> `AddressChoice.Secret` (persisted) -> `wireName`'s `PointSubdomain`. **Contract tests (all requested + legacy adoption)** - Broker HTTP seam: unauthenticated point/offboard -> 401, wrong-secret -> 403, correct-secret -> 204 (both verbs); legacy host adopts first secret over HTTP then refuses a second. - Registry seam: `Authorize` unknown/missing/wrong/correct; secret survives a restart; a v1 ledger loads and adopts on first caller (durable across restart). - Founding + brokerclient seams: the secret round-trips claim -> point. `go build`/`vet`/`test`/`gofmt`/`golangci-lint` green across both modules (full go-ci gate ran on push). Hosts claimed before the secret existed are handled by first-caller adoption exactly as ADR 0135 rules. Unblocks #330.
ben closed this issue 2026-08-08 21:13:31 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
Matou/idss#322
No description provided.