feat(worker): reject non-canonical-case `/api`, `/auth`, `/live` paths and run the Worker first at the Access phase
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 48/100
- Issue 类型
- 功能
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- react, rust
- 领域
- backend, infrastructure, testing
调研方向
Start with crates/thrust-worker/wrangler.toml and the Worker router; read ADR-0011 and ADR-0050 for the asset and Access behavior. Add router-level tests for the listed case variants, valid routes, and asset fallback, then verify the Access-phase config and hashed asset serving under wrangler dev. Done includes answering Q-0050.7 and, after deployment, rerunning the real-edge probes.
由索引模型根据 Issue 内容生成。
描述
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/callbackand/LIVE/echoskipped 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:78item 1). - Access matches whole path segments: the lookalikes
/apix,/api-v2and/apiary/xstayed 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 theASSETSbinding. - Reject case variants. Before routing, and before any asset fetch, percent-decode the first path segment. If its lower-case form is
api,authorlivebut 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-appskill):/Api/x,/API,/aPi/,/AUTH/callback,/Live/xand/%41pi/xanswer 404 with a body that is not the shell;/api/...,/auth/...and/livereach their handlers;/apiary/xand/Api-team/xreach 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 underwrangler deva 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; #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
- 主要语言
- Rust
- 星标
- 0
- 派生
- 0
- 平均合并
- 1 小时 35 分钟
- 30 天内合并 PR
- 67
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
aRustyDev/thrust 的其他 Issue
-
area:process prio:p1 type:security
难度 4/5 3-5 天 新手友好度 48/100
维护者通常 1 天内回复
-
area:process bug prio:p1
难度 4/5 3-5 天 新手友好度 38/100
维护者通常 1 天内回复
-
area:process prio:p1
难度 4/5 3-5 天 新手友好度 55/100
维护者通常 1 天内回复
-
area:process prio:p1
难度 4/5 1-2 天 新手友好度 55/100
维护者通常 1 天内回复
-
area:process prio:p1
难度 4/5 3-5 天 新手友好度 56/100
维护者通常 1 天内回复
相似的 Issue
-
yara-x fails to build with rsa 0.10.0: unresolved import rsa::Pkcs1v15Sign可能已有人在做 @CfirTsabari 今天认领。 未关闭
难度 1/5 1 小时以内 新手友好度 87/100
VirusTotal/yara-x#865 ·
维护者通常 1 天内回复
-
good first issue help wanted program
难度 2/5 1-3 小时 新手友好度 83/100
hffgzktbcc-blip/ounce-core#297 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
nautechsystems/nautilus_trader#5631 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 69/100
bytecodealliance/rustix#1736 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
longbridge/gpui-kit#3871 ·
维护者通常 1 天内回复