Repository navigation
fix: cloud workers work with trusted-proxy browser auth - #121671
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
b87c697 to
9cc2e3f
Compare
9cc2e3f to
b3784c3
Compare
|
Codex review: needs changes before merge. Reviewed August 10, 2026, 8:58 PM ET / August 11, 2026, 00:58 UTC. ClawSweeper reviewWhat this changesThe PR makes Control UI Cloud-worker recovery use an opaque Gateway-issued scope for trusted-proxy browser authentication and migrates eligible older credential-scoped recovery records. Merge readiness⛔ Blocked by patch quality or review findings - 8 items remain Keep open: the compatibility migration can move a pending Cloud-worker task from a cached device credential into a different trusted-proxy user’s recovery namespace. Priority: P1 Review scores
Verification
How this fits togetherThe Gateway authenticates Control UI browsers and returns a recovery scope in its hello response. The New Session Cloud-worker flow uses that scope to isolate and resume pending dispatches stored in browser session storage. flowchart LR
A[Control UI browser] --> B[Gateway authentication]
B --> C[Hello recovery scope]
C --> D[Recovery record migration]
D --> E[Session storage]
E --> F[Cloud worker resume]
Before merge
Findings
Agent review detailsSecurityNeeds attention: The migration can associate pending task content with the wrong authenticated principal. PR surfaceSource +14, Tests +301, Generated 0. Total +315 across 20 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Copy recommended automerge instructionTechnical reviewBest possible solution: Keep Gateway-issued recovery ownership, but require Gateway-attested source ownership before promotion or skip legacy promotion when the destination is a trusted-proxy principal scope. Do we have a high-confidence way to reproduce the issue? Yes. Source shows trusted-proxy auth bypasses device-token verification while the browser derives and promotes recovery from its cached device token. Is this the best way to solve the issue? No. Gateway-owned recovery scope is the correct boundary, but the compatibility migration needs proof that the source credential belongs to the current authenticated principal. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 32894a3ba508. LabelsLabel justifications:
EvidenceSecurity concerns:
Acceptance criteria:
What I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (6 earlier review cycles)
|
1ae9a19 to
4cc584d
Compare
efd4f10 to
9b96646
Compare
|
@clawsweeper re-review Both prior P1 findings are addressed on
Added regressions cover old-v4 fallback, seeded pre-upgrade recovery resumption, collision/write failure preservation, stale handshake rejection, and canonical human-principal isolation. Final production LOC is net −2. Focused tests, browser E2Es, build, protocol/SDK checks, test types, changed gates, and final autoreview are green. |
|
🦞👀 Command router queued. I will update this comment with the next step. |
9b96646 to
221dd72
Compare
|
@clawsweeper re-review Final upgrade-compatible head: |
3a62ba7 to
841ac53
Compare
|
@clawsweeper re-review The prior cross-principal migration finding is addressed on the new head: the Gateway now authorizes legacy migration only for device-token-owned recovery scopes, and a shared-browser principal-switch regression proves an authenticated user cannot inherit a stale credential owner's pending task. |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
8006826 to
61be24d
Compare
|
Land-ready at exact head
|
61be24d to
b1c2226
Compare
|
Land-ready proof for final head
Merged as |
Allow trusted-proxy and other authorized browser sessions to use cloud workers without deriving recovery ownership from client-visible credentials or Web Crypto. The Gateway now emits an opaque principal-bound recovery scope.
Keep the shipped credential-derived scope for older v4 Gateways and migrate credential-proven pending recovery rows to the Gateway-owned namespace before publishing readiness.
b1c2226 to
1799802
Compare
|
Merged via squash.
|
) * fix(ui): make cloud recovery scope gateway-owned Allow trusted-proxy and other authorized browser sessions to use cloud workers without deriving recovery ownership from client-visible credentials or Web Crypto. The Gateway now emits an opaque principal-bound recovery scope. * test(gateway): type recovery scope fixture * fix(ui): preserve cloud recovery across upgrades Keep the shipped credential-derived scope for older v4 Gateways and migrate credential-proven pending recovery rows to the Gateway-owned namespace before publishing readiness. * perf(ui): lazy-load recovery migration * fix(ui): preserve canonical recovery promotion * test(ui): use deterministic provider navigation * fix(ui): authorize recovery scope migration * build(plugin-sdk): refresh recovery compatibility baseline * test(gateway): expect recovery migration authorization
What Problem This Solves
Fixes an issue where users opening the Control UI through trusted-proxy authentication, including a fresh Safari session behind Cloudflare Access, could see “Cloud workers need a secure browser context” and lose the Cloud destination even though the page was served over HTTPS and the browser supported Web Crypto.
The affected surface is New session → Where → Cloud worker. A fully authorized trusted-proxy browser can authenticate without exposing a device or shared token to page JavaScript, so the previous client-derived recovery scope was empty and the UI misdiagnosed the connection as insecure.
Why This Change Was Made
The Gateway now records the authoritative recovery namespace in
hello-okas an opaqueauth.recoveryScope. Verified canonical human identity owns the scope when available; device/shared-auth identity provides the non-human fallback.Legacy migration is separately authorized by the Gateway.
auth.recoveryMigrationAllowedappears only when the destination scope is device-token-owned, so a shared browser cannot move one person's pending task into another trusted-proxy principal's namespace. Principal-owned sessions preserve unproven legacy rows untouched. Older compatible v4 Gateways that omit the new scope retain the exact shipped credential-derived fallback.The browser consumes those Gateway facts instead of inferring ownership. Authorized migration loads through a tiny deferred runtime boundary so normal Gateway startup remains lean and cycle-free. The old generic tracker module remains deleted, and the unsupported-connection message describes recovery availability rather than blaming HTTPS or Safari.
Production LOC: +92/−92 (net 0) | Tests/test support: +421/−37 | Generated contract: +19/−19 (hash-only)
User Impact
Cloud workers appear normally in authorized Safari and other trusted-proxy browser sessions without requiring browser settings, a client-visible token, or a previously paired browser profile. Recovery remains isolated by canonical user identity, current clients retain cloud recovery against older v4 Gateways, and credential-owned pending tasks migrate only when the Gateway proves the destination has the same owner.
Evidence
Sanitized real trusted-proxy browser result (fixture data only; the original Safari screenshot was not uploaded because it contains real session context):
server.auth.trusted-proxy-device-autoapprove.test.tsfailed exactly at the missingauth.recoveryScopeassertion (1 failed, 11 passed). Restoring the fix passed all 12 tests.recoveryScoperetains the exact shipped SHA-256-hex credential scope; an authorized device-token migration moves a seeded pre-upgrade pending row and resumes it through the existing cloud-startup consumer.config-safe-writeshard timeout was stress-tested 20/20 clean and classified as an isolated CI flake; no timeout or assertion was weakened.pnpm protocol:check: protocol registry, generated schema, Swift/Kotlin parity, and protocol-since guard passed.node scripts/check-changed.mjs -- <touched paths>: format, API baseline, boundaries, dead exports, i18n, typecheck, lint, schema guards, and import-cycle checks passed. Remote providers were unavailable, so the repository-approved trusted-source local fallback ran.HelloOk.authfields.git diff --check: passed.Exact PR merge-tree CI on the pushed head is the remaining gate and will be recorded before landing.
Provenance: the client-side recovery derivation shipped with cloud workers in #107670 on 2026-07-14. This change replaces that inference with Gateway-owned facts rather than adding a Safari-specific workaround.