Skip to content

feat(worker): reject non-canonical-case /api, /auth, /live paths and run the Worker first at the Access phase #50

Open

Description

@aRustyDev

Context

crates/thrust-worker/wrangler.toml has no [assets] block yet; static assets arrive with the React build (#44). ADR-0011 (round 26) sets two rules for them. assets.run_worker_first lists both forms of every path the Worker handles (/api, /api/*, /auth, /auth/*, /live, /live/*), and the SPA fallback is not_found_handling = "single-page-application" (adrs/ui/0011-static-asset-hosting.md:76). At the Access phase, Access gates the UI paths and bypasses /api, /auth and /live, which the application authenticates itself (ADR-0090 round 25, adrs/infra/0090-cloudflare-topology.md:88).

Problem

Spike 0004 run 2 (real platform, Access on) found that Access matches bypass paths case-insensitively, while run_worker_first patterns are case-sensitive.

  • So /Api/, /API/ping, /AUTH/callback and /LIVE/echo skipped Access, missed the Worker, and got the 1,712-byte gated root shell with a 200 and no credentials (research/0006 §13.3 line 591, §13.4 line 604; ADR-0050 :117; ADR-0011 :80; ADR-0141 :78 item 1).
  • Access matches whole path segments: the lookalikes /apix, /api-v2 and /apiary/x stayed gated (§13.3, line 574).
  • Case variants of the gated targets stay gated, and the edge normalises dot-segments before Access matches (§13.4, line 597).
  • Q-0050.7 is open (QUESTIONS.md:304). It matters from the Access phase (P1), not at P0.

Proposal

  • Worker first. At the Access phase set run_worker_first = ["/*", "!/assets/*"]; negative patterns win, and a config takes at most 100 patterns (research/0006 §3.6, line 191). The Worker then serves non-API navigations through the ASSETS binding.
  • Reject case variants. Before routing, and before any asset fetch, percent-decode the first path segment. If its lower-case form is api, auth or live but the exact form is not, answer 404 with a body that is not the shell. Compare the first segment, not a string prefix, matching Access's segment rule above, so /apiary/... and slugs such as /Api-team/... still reach the SPA.
  • Cost. Navigations become Worker invocations. At about 5 M requests a month, that stays inside the included 10 M (research/0004 §9; FR-13).
  • Alternative, if the owner prefers no path-scoped bypass: the API on its own hostname, at the price of cross-origin cookies.
  • Answer Q-0050.7 in ADR-0050 and ADR-0011.

Acceptance criteria

  • Router-level tests (axum, per the rust-test-app skill):
    • /Api/x, /API, /aPi/, /AUTH/callback, /Live/x and /%41pi/x answer 404 with a body that is not the shell;
    • /api/..., /auth/... and /live reach their handlers;
    • /apiary/x and /Api-team/x reach the asset fallback.
  • Control: with the check disabled, the case-variant tests fail because the requests reach the asset fallback.
  • The Access-phase environment's wrangler config carries run_worker_first = ["/*", "!/assets/*"], and under wrangler dev a hashed /assets/* file is still served as the file.
  • Re-running spike 0004's case-variant probes on the real edge with Access on returns 404 for every BF3 path. Control: with the check disabled, the run reproduces the 200 shell. The probe scripts are off-repo (spikes/README.md:54; chore(plans): bring the compat-inventory and spike-0004 scripts into this repository under tools/ #55).
  • Q-0050.7 is answered, citing FR-13.

References

  • Review: .agents/plans/contrail/reviews/2026-10-19-fable-architecture-review.md (FR-13)
  • research/0006-topology-public-half.md §3.6 (line 191), §13.3 (lines 574, 591), §13.4 (lines 593-609)
  • ADR-0011 (:76, :80), ADR-0050 (:117), ADR-0090 (:88), ADR-0141 (:78)
  • Q-0050.7, Q-0050.2; research/0004-rust-on-workers-binding-matrix.md §9 (traffic and cost)
  • crates/thrust-worker/wrangler.toml (no [assets] block today)

Finding: FR-13

Activity

  1. added this to the M6 Identity and P1 milestone on Oct 20, 2026
  2. added
    area:infra
    type:security
    review:fable-2026-10-19
    on Oct 20, 2026
  3. aRustyDev commented on Nov 20, 2026

    @aRustyDev
    OwnerAuthor

    Note from #42 (the deep health check). The deep probe is live on status.woven: GET https://thrust.sow.foo/healthz?deep=1 every 60 s (ApiraTech/infrastructure#1040; the record is #344). At the Access phase it needs the same treatment as /api, /auth and /live:

    1. /healthz joins the Access bypass list. The prober is a non_identity WARP session and cannot pass Access, so a gated /healthz turns the line red for good. The probe's condition is a 200 whose body is exactly ok, so an Access login page can never read as healthy: it fails loudly, not silently. Check that the bypass also matches the URL with its query string (?deep=1).
    2. /healthz joins the case-variant reject list. Access matches bypass paths case-insensitively and run_worker_first is case-sensitive (the problem above), so with /healthz bypassed, /HealthZ would skip Access, miss the Worker and get the SPA shell (a 200 text/html). The reject rule in the proposal should list healthz beside api, auth and live, and its router tests should cover it.
    3. /healthz is already in run_worker_first (crates/worker/wrangler.deploy.toml, with /_info, /internal/* and /_test/*), so that part needs no change. If the run_worker_first = ["/*", "!/assets/*"] form replaces the list, /healthz is covered by it.

    One thing to decide, not a blocker: a bypassed /healthz?deep=1 needs no credentials and costs one Hyperdrive round trip a request. That is already true at P0, where the hostname is public. If it matters at the Access phase, a rate-limit rule on /healthz is the lever.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:infraprio:p1review:fable-2026-10-19type:security

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions