Skip to content

feat: sign previews in from the dashboard with a host-bound token - #32522

Open
DanielleMaywood wants to merge 1 commit into
open-preview/routingfrom
open-preview/sign-in
Open

DanielleMaywood wants to merge 1 commit into
open-preview/routingfrom
open-preview/sign-in

Conversation

@DanielleMaywood

@DanielleMaywood DanielleMaywood commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

Main's app sign-in (/api/v2/applications/auth-redirect) sets one cookie on the whole wildcard domain, which every subdomain app receives. A preview page must not share that cookie, so each preview gets a host-only cookie and a sign-in token bound to its exact host.

Sign-in reuses main's minting, scopes and app encryption key, so workspace proxies need no new keys or RPCs. The dashboard calls it from the chat only when the preview host reports no session, and the separate address endpoint mints nothing, so reopening a signed-in preview creates no API key.

Implementation details

Adds two endpoints. POST /api/experimental/previews/address returns a preview's URL, origin and sandbox without minting anything, so the dashboard can load a preview with an existing session. POST /api/experimental/previews/sign-in signs the workspace owner in to one preview host, and the dashboard calls it only when the preview host reports that it has no session. Coderd checks the experiment and that the caller owns the workspace, mints an application_connect key, and returns the preview URL with a sign-in token encrypted under the existing workspace apps key. The token's audience is coder_preview and it names the exact preview host. It is valid for one minute, plus up to one minute of clock leeway between coderd and the server that checks it.

The preview host checks the token's host, sets a host-only session cookie (__Host-coder_preview_session_token with Secure on HTTPS, whatever --secure-auth-cookie says, and coder_preview_session_token on plain HTTP), and redirects to its own origin with Referrer-Policy: no-referrer, keeping the path's escaping, such as %2F. Workspace proxies decrypt the token with the key they already fetch, so they need no new keys or RPCs. This relies on #32439, where preview hosts refuse the app sign-in parameter, so a preview cannot replace the user's app sign-in for their other apps, and answer a preview without a session with a 401 page.

Sign-in refuses a region whose preview hosts are not on the dashboard's site, the primary's wildcard access URL or a workspace proxy's, because browsers would not send the preview's SameSite=Lax session cookie from the dashboard's frame. A region that cannot serve previews gets a 400, and a failed region lookup a 500. url_path must pass previewhost.CheckURLPath, which the tool shares, so its path cannot carry bad percent-encoding, and it cannot carry a query parameter the preview host reads itself. Both endpoints run the same checks. With the experiment off they return 404, and without --host-prefix-cookie they return 400 "Previews require --host-prefix-cookie. An administrator can enable it." and mint nothing.

Stack (review bottom-up). Replaces the closed #31282 stack. Security review: coder/security-assessments#437.

  1. feat: serve published HTML previews from the workspace agent #32438 Agent file previews
  2. feat: serve agent previews on strict preview hosts #32439 Strict preview hosting and experiment
  3. feat: sign previews in from the dashboard with a host-bound token #32522 Preview sign-in, this PR
  4. feat(coderd): add the open_preview chat tool #32440 open_preview chat tool
  5. feat(site/src): open open_preview results in the right panel #32441 Agents UI
  6. docs: document open_preview previews #32442 Docs

🤖 Generated with Claude Code

@DanielleMaywood

Copy link
Copy Markdown
Collaborator Author

/coder-agents-review

@coder-agents-review

coder-agents-review Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Chat: Spend limit reached | View chat
Requested: 2026-11-26 15:32 UTC by @DanielleMaywood
Spend: $107.08 / $100.00 (limit reached)

Review history
  • R1 (2026-11-25): 13 reviewers, 5 Nit, 2 P2, 14 P3, 12 P4, COMMENT. Review
  • R2 (2026-11-25), 5 Nit, 2 P2, 14 P3, 12 P4, COMMENT. Review
  • R3 (2026-11-25): 15 reviewers, 7 Nit, 2 P2, 16 P3, 20 P4, COMMENT. Review
  • R4 (2026-11-26): 11 reviewers, 9 Nit, 2 P2, 18 P3, 25 P4, COMMENT. Review
  • R5 (2026-11-26): 9 reviewers, 10 Nit, 2 P2, 18 P3, 27 P4, COMMENT. Review
  • R6 (2026-11-26): 6 reviewers, 11 Nit, 2 P2, 18 P3, 27 P4, COMMENT. Review
  • R7 (2026-11-26): 6 reviewers, 11 Nit, 2 P2, 18 P3, 27 P4, APPROVE. Review
  • R8 (2026-11-26): 6 reviewers, 13 Nit, 2 P2, 18 P3, 28 P4, COMMENT. Review
  • R9 (2026-11-26): 8 reviewers, 13 Nit, 2 P2, 19 P3, 29 P4, COMMENT. Review
  • R10 (2026-11-26): 6 reviewers, 14 Nit, 2 P2, 19 P3, 29 P4, COMMENT. Review

deep-review v0.13.1 | Round 10 | 327e5ed..aa2ba14

Last posted: Round 10, 64 findings (2 P2, 19 P3, 29 P4, 14 Nit), COMMENT. Review

Finding inventory

Finding inventory: PR #32522

Findings

# Sev Status Location Summary Round Reviewer Posted
CRF-1 P3 Author fixed (3cbebe3) coderd/previews.go:94 previewHostingFor database errors answered as 400 with raw error in Detail R1 Netero Yes
CRF-2 P3 Author fixed (3cbebe3) coderd/workspaceapps/preview.go:61 Comment refers to a direct-open redirect that does not exist R1 Netero Yes
CRF-3 P3 Author fixed (69ee6a9, in #32439) coderd/httpapi/cookie.go:32 Comment reason made false: preview cookie prefix now follows scheme, not deployment setting R1 Netero Yes
CRF-4 P4 Author fixed (3cbebe3) coderd/previews.go:153 previewHostingFor refusal branches (no wildcard, deleted proxy) untested R1 Netero Yes
CRF-5 P4 Verified fixed (aa2ba14) codersdk/previews.go:23 omitempty on uuid.UUID RegionID has no effect R1 Netero Yes
CRF-6 Nit Author contested; panel closed R3 (1/1 accept) coderd/workspaceapps/previewhost/previewhost.go:78 "__Host-" literal duplicates codersdk cookieHostPrefix R1 Netero Yes
CRF-7 Note Note (body) coderd/previews.go:126 payload.Subject is set but never read R1 Netero No
CRF-8 P2 Author fixed (3cbebe3) coderd/previews.go:101 Unvalidated AgentName plus HostnamesMatch port stripping lets a token minted by one user sign in another user's preview host R1 Kurapika P2, Netero Note Yes
CRF-9 P2 Author fixed (5421940), verified R4 coderd/workspaceapps/previewhost/previewhost.go:87 Preview session cookie uses deployment SameSite (Lax), dropped in cross-site dashboard iframe R1 Razor, Ryosuke, Melody, Pariston, Mafuuu, Bisky, Meruem P2; Hisoka P3 Yes
CRF-10 P3 Author fixed (3cbebe3) coderd/previews.go:113 Each preview open mints a session-length whole-user application_connect key; replaced keys stay valid R1 Pariston P3, Kurapika P4, Ryosuke Note, Mafuuu Note Yes
CRF-11 P3 Author fixed (3cbebe3) coderd/previews.go:64 Preview access rules duplicated from Issue with a different agent lookup R1 Ryosuke P3, Meruem P3, Pariston Note Yes
CRF-12 P3 Author fixed (3cbebe3) coderd/workspaceapps/preview.go:116 Post-sign-in redirect decodes escaped path segments R1 Mafuuu P3, Hisoka P4, Razor P4 Yes
CRF-13 P3 Author contested; panel closed R3 (1/1 accept) coderd/workspaceapps/preview.go:63 Expired sign-in param shows error even when host already has a valid session cookie R1 Mafuuu Yes
CRF-14 P4 Author fixed (3cbebe3) coderd/previews.go:140 URLPath containing reserved query params yields a URL that never opens R1 Meruem, Mafuuu, Melody Yes
CRF-15 P3 Author fixed (3cbebe3) coderd/previews.go:85 Unknown agent reported as "does not allow port forwarding" R1 Leorio Yes
CRF-16 P3 Author fixed (3cbebe3) codersdk/previews.go:28 "one-minute" token is accepted up to two minutes after minting R1 Gon P3 (+P2 at token.go:90), Leorio P4 Yes
CRF-17 Nit Author contested; panel closed R3 (1/1 accept) coderd/workspaceapps/token.go:98 Validate doc comment restates the body R1 Gon P2 Yes
CRF-18 P3 Author contested; panel closed R3 (1/1 accept) coderd/workspaceapps/previewhost/previewhost.go:74 SessionCookieName comment says __Host- makes the cookie Secure and host-only R1 Gon P2 Yes
CRF-19 P4 Author fixed (5421940), verified R4 coderd/workspaceapps.go:138 createAppConnectKey comment omits the DefaultDuration cap and the return value R1 Gon P3 Yes
CRF-20 P4 Author fixed (3cbebe3) codersdk/previews.go:30 Origin doc uses undefined "wrapper" and does not say which check uses it R1 Gon P3 Yes
CRF-21 P4 Author contested; panel closed R3 (1/1 accept) coderd/workspaceapps/token.go:94 Sign-in lifetime is an inline time.Minute repeated in comments R1 Gon Yes
CRF-22 P4 Author contested; panel closed R3 (1/1 accept) coderd/workspaceapps/token.go:100 Expiry nil check duplicates RegisteredClaims.Validate R1 Gon Yes
CRF-23 Nit Author contested; panel closed R3 (1/1 accept) coderd/workspaceapps/provider.go:42 PreviewSessionCookie field holds a name; call it PreviewSessionCookieName R1 Gon Yes
CRF-24 Nit Author fixed (3cbebe3) coderd/workspaceapps/token.go:77 "dashboard mints" names the frontend; coderd mints the payload R1 Gon Yes
CRF-25 P4 Author contested; panel closed R3 (1/1 accept) coderd/workspaceapps/provider.go:42 Other ResolveRequest callers rely on r.Cookie("") failing; cookie name threads through generic options R1 Meruem Yes
CRF-26 P3 Author fixed (3cbebe3) coderd/workspaceapps/preview_test.go:79 Tests use a zero cookie config, so Secure-follows-config and cookiesToPrefix removal are untested R1 Bisky Yes
CRF-27 P3 Author fixed (3cbebe3) coderd/previews.go:152 RegionID equal to DeploymentID branch untested R1 Bisky Yes
CRF-28 P3 Author fixed (3cbebe3) coderd/previews.go:114 No scoped-token test for the new key-minting endpoint R1 Bisky Yes
CRF-29 P4 Author fixed (3cbebe3) coderd/workspaceapps/preview_test.go:174 No test sends a sign-in token on a top-level page load R1 Bisky Yes
CRF-30 P4 Author contested; panel closed R3 (1/1 accept) coderd/workspaceapps/preview_test.go:340 Fake http.Response to parse Set-Cookie; use http.ParseSetCookie R1 Ging-Go Yes
CRF-31 P4 Author contested; panel closed R3 (1/1 accept) coderd/previews_test.go:103 Fake http.Response to parse Set-Cookie; use http.ParseSetCookie R1 Ging-Go Yes
CRF-32 P3 Author fixed (3cbebe3) coderd/workspaceapps/provider.go:64 PR description and commit message credit #32439 protections to this PR and cite unresolvable references R1 Mafu-san P3, Leorio P3/P4 Yes
CRF-33 P4 Author contested; panel closed R3 (1/1 accept) coderd/previews.go:72 Invalid slug message does not state the valid format R1 Leorio Yes
CRF-34 P4 Author contested; panel closed R3 (1/1 accept) coderd/previews.go:107 "Invalid preview address." blames the request when the hostname label is too long R1 Leorio Yes
CRF-35 OOS Out of scope (body) coderd/workspaceapps/provider.go:95 Signed app token cookie also uses deployment SameSite on preview hosts R1 Mafuuu No
CRF-36 OOS Out of scope (body) coderd/workspaceapps/proxy.go:326 handleAPIKeySmuggling redirect also decodes escaped paths R1 Mafuuu, Hisoka No
CRF-37 OOS Out of scope (body) coderd/workspaceapps/token.go:58 EncryptedAPIKeyPayload also accepted for two minutes, undocumented R1 Gon No
CRF-38 OOS Out of scope (body) coderd/workspaceapps/previewhost/previewhost.go:191 Preview scripts can set Domain cookies on the app wildcard via document.cookie R1 Razor No
CRF-39 OOS Out of scope (body) coderd/workspaceapps.go:140 createAppConnectKey uses time.Until and dbtime.Now instead of api.Clock R1 Meruem No
CRF-40 P3 Author contested; panel closed R4 (1/1 accept) codersdk/previews.go:12 Sign-in request/response types reused by the address endpoint, which does not sign in R3 Netero Yes
CRF-41 P4 Author contested; panel closed R4 (1/1 accept) coderd/workspaceapps/previewhost/previewhost.go:192 Unreachable url.Parse error branch in Hosting.URL R3 Netero Yes
CRF-42 P4 Author contested; panel closed R4 (1/1 accept) coderd/workspaceapps/preview.go:139 signInPreview copies originLocalURL trimming instead of fixing originLocalURL R3 Netero Yes
CRF-43 P4 Author contested; panel closed R4 (1/1 accept) coderd/previews_test.go:305 Inline application_connect key counts instead of appConnectKeys helper R3 Netero Yes
CRF-44 Nit Author fixed (5421940), verified R4 coderd/workspaceapps/token.go:76 "The coderd mints it" extra article R3 Netero Yes
CRF-45 P3 Author accepted R5 (operator decision for the experimental release, no issue) coderd/previews.go:74 Preview sign-in key has the whole-user allow list; restrict it to the preview's workspace R3 Knov P3, Kurapika P3 Yes
CRF-46 P4 Author accepted R5 (operator decision for the experimental release, no issue) coderd/workspaceapps/preview.go:126 Exact host compare includes the port, so a reverse proxy that drops a non-default port fails every sign-in R3 Hisoka Yes
CRF-47 P4 Author fixed (5421940), verified R4 coderd/previews_test.go:303 NotContains "connection reset" on Message cannot fail; the error is in Detail R3 Bisky Yes
CRF-48 P4 Dropped by orchestrator (row guards the CRF-8 regression of a port-only agent check) coderd/previews_test.go:165 UnknownAgentForFile row runs the same path as UnknownAgent R3 Bisky No
CRF-49 P4 Author fixed (5421940), verified R4 coderd/previews.go:244 registrableDomain SplitHostPort branch untested R3 Bisky Yes
CRF-50 P4 Author contested; panel closed R4 (1/1 accept) coderd/previews.go:109 Address endpoint requires api_key:create; neither endpoint checks application_connect on the workspace R3 Kite Yes
CRF-51 P4 Author fixed (5421940), verified R4 coderd/previews_test.go:294 Region refusal test asserts only 400, not the refusal reason R3 Kite Yes
CRF-52 P2 Dropped by orchestrator (moved, accurate comment; verbosity only) coderd/workspaceapps/appurl/appurl.go:15 Moved SubdomainProxyAPIKeyParam comment is wordy R3 Gon No
CRF-53 Nit Author contested; panel closed R4 (1/1 accept) codersdk/previews.go:49 previewFrame names both the SDK request helper and the coderd response builder R3 Gon Yes
CRF-54 Note Note (body) coderd/previews.go:241 Same-site check ignores scheme (schemeful same-site); unverified in a browser R3 Gon No
CRF-55 P4 Dropped by orchestrator (squash commits use the PR body, verified by Mafu-san) commit 3cbebe3 Commit body still says one-minute token and credits #32439 refusals R3 Leorio No
CRF-56 P3 Author contested; panel closed R5 (3/3 accept) coderd/previews.go:224 Same-site rule lives in the handler: two copies, a second refusal error type, sentinel doc now wrong, no startup diagnostic R4 Netero P4, Ryosuke P4, Gon P4 Yes
CRF-57 Nit Author contested; panel closed R5 (1/1 accept) coderd/previews.go:209 crossSiteError doc calls the Message field "response title" R4 Gon Yes
CRF-58 P4 Author fixed (99d01d9, doc only), verified R5 coderd/workspaceapps/previewhost/previewhost.go:54 CheckURLPath accepts bad query escapes and ";" pairs that hide reserved keys R4 Ging-Go Yes
CRF-59 Nit Author fixed (99d01d9), verified R5 coderd/previews.go:162 errors.As with a var; GO.md prefers errors.AsType R4 Ging-Go Yes
CRF-60 P4 Author fixed (7cf249d), verified R7 coderd/previews.go:224 Same-site refusal ignores --samesite-auth-cookie=none, and its comment cites only the default Lax R4 Melody P4, Leorio P4 Yes
CRF-61 P4 Author contested; panel closed R5 (1/1 accept) coderd/previews_test.go:441 Primary CrossSite row passes with a same-site app hostname because the dashboard is 127.0.0.1 R4 Bisky Yes
CRF-62 P4 Author contested; panel closed R5 (1/1 accept) enterprise/wsproxy/preview_test.go:78 Proxy-region refusal asserts only status 400 R4 Bisky Yes
CRF-63 P3 Author fixed (PR description), verified R5 coderd/previews.go:224 PR description says only proxies are refused for being cross-site; the primary is now refused too R4 Leorio P3, Razor P4 Yes
CRF-64 P4 Author contested; panel closed R5 (1/1 accept) coderd/previews.go:163 Cross-site refusal has no Detail naming the compared domains, and the proxy case dropped "choose another region" R4 Leorio Yes
CRF-65 Nit Author fixed (588ce57), verified R6 coderd/previews.go:205 "Its text" now reads as crossSiteError's text after the new sentence R5 Gon Yes
CRF-66 P4 Author contested; panel closed R6 (1/1 accept) coderd/workspaceapps/proxy.go:43 SubdomainProxyAPIKeyParam has two names (appurl constant and workspaceapps alias), both used in this PR's tests R5 Zoro Yes
CRF-67 P4 Author contested; panel closed R6 (1/1 accept) coderd/previews.go:221 "no wildcard app hostname" text duplicated instead of wrapping api.previewsUnavailable R5 Zoro Yes
CRF-68 OOS Out of scope (body) coderd/x/chatd/chattool/openpreview.go:150 #32440 OpenPreview treats any previewsUnavailable as unavailable in every region, blocking same-site proxies R5 Ryosuke No
CRF-69 Nit Author fixed (7cf249d), verified R7 coderd/workspaceapps/previewhost/previewhost.go:84 Hosting.host doc says "with the serving port" but Strict drops the default port R6 Meruem Yes
CRF-70 Nit Author contested; panel closed R9 (1/1 accept) coderd/previews_test.go:196 Moved comment "The address endpoint refuses what sign-in refuses." now restates the loop below it R8 Gon P2 Yes
CRF-71 P2 Dropped by orchestrator (Leorio showed each clause names a table row to update; accurate test doc) coderd/previews_test.go:252 TestPreviewRegions doc restates the table's assertions R8 Gon No
CRF-72 P4 Author contested; panel closed R9 (1/1 accept) coderd/previews_test.go:262 Constant hostPrefixOff (message) shares its name with the bool field hostPrefixOff in the same rows R8 Gon Yes
CRF-73 Nit Verified fixed (aa2ba14) coderd/previews_test.go:312 "The port checks that same-site comparisons ignore it." is ambiguous and omits that Primary also relies on the port R8 Leorio Nit, Gon Note Yes
CRF-74 P3 Verified fixed (aa2ba14) coderd/previews.go:233 Caller-context proxy read refuses every scoped token for every proxy region with a false "no workspace proxy has ID" Detail; the scope is internal and cannot be requested R9 Razor P3, Gon P4, Leorio P4, Ryosuke P4, Bisky P4, Chopper P4 Yes
CRF-75 Nit Author fixed (aa2ba14); re-raised R10 by Gon (new comment says no public scope grants workspace_proxy:read, false for coder:all; allow list still omitted) coderd/previews_test.go:429 Scoped-token proxy case comment credits the scope alone; the allow list also blocks the read R9 Bisky Yes
CRF-76 OOS Out of scope (body) enterprise/coderd/workspaceproxy.go:64 fetchRegions comment says users cannot usually access proxies, but memberRole grants read R9 Ryosuke No
CRF-77 Nit Open coderd/previews.go:231 Comment says a scoped token can never hold workspace_proxy:read; the public coder:all scope grants it R10 Gon P3 (downgraded) Yes

Contested and acknowledged

CRF-70 (Nit, previews_test.go:196) and CRF-72 (P4, previews_test.go:262)

  • Finding: Restating comment; constant and bool field share the name hostPrefixOff.
  • Author defense: The comment states the rule the test exists for; each row that sets the flag expects that message and the constant is three lines above.
  • Panel closure (R9, 1/1 each): Gon, the agent that raised them: accurate comment with no behavior effect; a wrong pairing fails the test.

CRF-66 (P4, proxy.go:43) and CRF-67 (P4, previews.go:221)

  • Finding: Two names for SubdomainProxyAPIKeyParam; duplicated "no wildcard app hostname" text.
  • Author defense: The alias keeps main's references untouched and names where the constant lives; the duplicated text is only Detail under "choose another region".
  • Panel closure (R6, 1/1 each): Zoro, the agent that raised them: git blame shows the workspaceapps-name test use comes from base 6747c02, only the appurl use is new; a drifted Detail breaks nothing.

CRF-45 (P3, previews.go:74) - whole-user key scope

  • Author accepted (R5): "Accepted for the experimental release (operator decision, no issue filed)": the key matches main's subdomain sign-in key, sign-in runs only when a preview host has no session, and the sign-in URL is host-bound and short-lived. Recorded as a human decision by the PR author's account.

CRF-46 (P4, preview.go:126) - port in exact host compare

  • Author accepted (R5): "Accepted for the experimental release (operator decision, no issue filed)": a reverse proxy on a non-default port must forward Host with its port.

CRF-56 (P3, previews.go:224) - same-site rule in handler

  • Finding: Two copies, second refusal type, false sentinel doc, no startup warning; move into previewhost.Strict.
  • Author defense: Sentinel doc fixed; rule kept in previewHostingFor so the chat tool still offers previews and the tab shows the reason.
  • Panel closure (R5, 3/3): Netero, Ryosuke and Gon, the agents that raised the parts. Ryosuke found that feat(coderd): add the open_preview chat tool #32440's OpenPreview refuses every region when previewsUnavailable is set, so the proposed startup recording would block same-site proxies; the user-facing message names the cause.

CRF-57 (Nit, previews.go:209) - "response title"

  • Author defense: The message is the alert title the preview tab shows.
  • Panel closure (R5, 1/1): Gon: the word describes what the user reads and cannot lead a caller to the wrong field.

CRF-60 (P4, previews.go:224) - refusal under SameSite=None

  • Finding: The refusal ignores --samesite-auth-cookie=none and the comment cites only default Lax.
  • Author defense: Refusing under none is intended because Safari and Firefox block or partition third-party cookies.
  • Panel re-raise (R5, comment only): Melody accepted the behavior; Leorio accepted the behavior but re-raised the comment, which still gives only the default Lax reason, so a maintainer could add a none exemption and bring back the Safari sign-in loop. Melody noted the same comment gap.

CRF-61, CRF-62 (P4, tests) - CrossSite row and proxy refusal assertion

  • Panel closure (R5, 1/1 each): Bisky withdrew both: the two tests together cover both outcomes of the comparison, and the proxy message is asserted exactly in TestPreviewSignInRegions.

CRF-64 (P4, previews.go:163) - cross-site refusal Detail

CRF-40 (P3, codersdk/previews.go:12) - sign-in types reused by address endpoint

  • Finding: Rename PreviewSignInRequest/PreviewSignInResponse since the address endpoint does not sign in.
  • Author defense: Same request and frame for both; the type comment says so; renaming across stacked PRs is churn.
  • Panel closure (R4, 1/1): Netero, the agent that raised it: the type comments state both uses and the API is experimental with one in-stack consumer, so a later rename has no compatibility cost.

CRF-41 (P4, previewhost.go:192) - unreachable url.Parse branch

  • Finding: Share one parse or drop the branch.
  • Author defense: The error must still be handled; a helper would add code to remove three lines.
  • Panel closure (R4, 1/1): Netero, the agent that raised it: no runtime effect.

CRF-42 (P4, preview.go:139) - originLocalURL copy

  • Finding: Fix originLocalURL to keep RawPath instead of copying its trimming.
  • Author defense: Changing it alters main's app redirects, out of scope for the stack.
  • Panel closure (R4, 1/1): Netero, the agent that raised it: the comment names originLocalURL, so the copies point at each other.

CRF-43 (P4, previews_test.go:305) - inline key counts

  • Finding: Use appConnectKeys.
  • Author defense: Both tests use password sessions, so the inline count sees every key.
  • Panel closure (R4, 1/1): Netero, the agent that raised it, verified both tests sign in with password sessions.

CRF-45 (P3, previews.go:74) - whole-user key scope

  • Finding: Each preview sign-in key has the *:* allow list; restrict it to the preview's workspace.
  • Author defense: Same key as main's subdomain sign-in; minting frequency was reduced; the allow list was left out of this release. No ticket.
  • Panel re-raise (R4): Knov and Kurapika, the agents that raised it: main's key serves every app via the wildcard cookie, while this key sits in a host-only cookie for one workspace; minting less often does not narrow what one key reaches. Fix verified in R3. No ticket, so this needs a fix or a human decision.

CRF-46 (P4, preview.go:126) - port in exact host compare

  • Finding: A reverse proxy that drops a non-default port from Host fails every sign-in.
  • Author accepted: Keeps the exact compare to protect the SignInForHostEndingInOtherHost case; documented reverse proxy setup listens on 443. No ticket; a human must accept or file it.

CRF-50 (P4, previews.go:109) - ActionCreate on address endpoint

  • Finding: Address endpoint requires api_key:create; neither checks ActionApplicationConnect.
  • Author defense: Shared checks keep the address endpoint from returning addresses sign-in would refuse; no reachable case where an owner passes and Issue refuses.
  • Panel closure (R4, 1/1): Kite, the agent that raised it: owners hold application_connect; scoped tokens hit ErrExceedsCaller; a dormant workspace has no agent and is refused before minting (inferred).

CRF-53 (Nit, codersdk/previews.go:49) - previewFrame name collision

  • Finding: Rename the SDK request helper.
  • Author defense: Unexported in different packages; both return the frame.
  • Panel closure (R4, 1/1): Gon, the agent that raised it: each returns a PreviewSignInResponse.

CRF-5 (Nit, codersdk/previews.go:23) - omitempty on uuid.UUID RegionID

  • Finding: omitempty on a uuid.UUID has no effect in encoding/json; drop it or use *uuid.UUID.
  • Author defense: The tag makes the generated TypeScript field optional, as for other codersdk uuid.UUID fields.
  • Panel closure (R3, 1/1): Netero, the agent that raised it, confirmed readonly region_id?: string in typesGenerated.ts and 63 other uuid.UUID fields with omitempty in codersdk; the server treats the nil UUID as the primary.

CRF-6 (Nit, previewhost.go:136) - "__Host-" literal duplication

  • Finding: Export codersdk.cookieHostPrefix and reuse it instead of the literal.
  • Author defense: Exporting widens the SDK API for one literal.
  • Panel closure (R3, 1/1): Netero, the agent that raised it, verified a typo in the previewhost copy fails TestServePreviewPolicy, which asserts the full cookie name.

CRF-13 (P3, preview.go:71) - expired sign-in param ignores valid cookie

  • Finding: A request with an expired coder_preview_sign_in shows the error page even when the host has a valid session cookie.
  • Author defense: PreviewFrame loads the untokenized address on every mount and reload and uses a minted URL only right after a fresh sign-in, whose 303 drops the token.
  • Panel closure (R3, 1/1): Mafuuu, the agent that raised it, verified postPreviewAddress returns an untokenized URL for every load, removing the cached-response trigger.

CRF-17 (Nit, token.go:100) - Validate doc restates body

  • Finding: Delete the restating doc comment.
  • Author defense: Exported symbols need doc comments.
  • Panel closure (R3, 1/1): Gon, the agent that raised it, confirmed .golangci.yaml:135 enables revive's exported rule.

CRF-18 (P3, previewhost.go:132) - __Host- comment mechanism

  • Finding: The comment says the prefix makes browsers keep the cookie Secure and host-only.
  • Author defense: Wording nit; SessionCookie sets Secure itself.
  • Panel closure (R3, 1/1): Gon, the agent that raised it, verified removing the Secure assignment fails the https row of TestServePreviewSessionCookie, so the misleading text cannot cause a silent break.

CRF-19 (P4, workspaceapps.go:138) - createAppConnectKey doc lifetime

  • Finding: The doc says "same lifetime as the current session" but the key is capped at Sessions.DefaultDuration, and it does not say it returns the secret.
  • Author defense: Out of scope; the text and cap come from main and were only moved.
  • Panel re-raise (R3): Gon, the agent that raised it, showed main had an inline remark inside workspaceApplicationAuth; this PR turns it into the doc comment of a new function that the new sign-in endpoint calls, so it is added text in scope.

CRF-21 (P4, token.go:96) - inline time.Minute

  • Finding: Name the sign-in lifetime constant.
  • Author defense: One use; the Fill doc states it.
  • Panel closure (R3, 1/1): Gon, the agent that raised it: the codersdk doc cannot reference a workspaceapps constant, so a constant would not remove the second copy.

CRF-22 (P4, token.go:102) - redundant Expiry nil check

  • Finding: Keep only NotBefore == nil.
  • Author defense: Harmless and keeps the rule visible.
  • Panel closure (R3, 1/1): Gon, the agent that raised it: the clause changes no result.

CRF-23 (Nit, provider.go:42) - PreviewSessionCookie field name

  • Finding: Rename to PreviewSessionCookieName.
  • Author defense: Naming preference; the field doc says it is a name.
  • Panel closure (R3, 1/1): Gon, the agent that raised it: the field is passed to r.Cookie, which takes a name, so a caller cannot misuse it.

CRF-25 (P4, provider.go:42) - empty cookie name in other callers

  • Finding: Other ResolveRequest callers fail closed only because r.Cookie("") errors.
  • Author defense: The empty lookup yields no session and Issue refuses; no access is gained.
  • Panel closure (R3, 1/1): Meruem, the agent that raised it, agreed no caller gains access.

CRF-30 (P4, preview_test.go:473) and CRF-31 (P4, previews_test.go:108) - fake http.Response

  • Finding: Use http.ParseSetCookie.
  • Author defense: Established idiom; malformed cookies still fail the test.
  • Panel closure (R3, 1/1 each): Ging-Go, the agent that raised them, found the "established idiom" claim false (only these two uses in the repo) but verified the preceding assertions fail on a missing or malformed cookie.

CRF-33 (P4, previews.go:143) and CRF-34 (P4, previews.go:180) - error message wording

  • Finding: State the slug format; do not blame the request for a too-long label.
  • Author defense: Slugs come from the tool; the tool refuses long labels and Detail names the cause.
  • Panel closure (R3, 1/1 each): Leorio, the agent that raised them: the field doc gives the format, only code-built requests reach these branches, and Detail names the cause.

Law analysis

R1: not run. Effective additions 805, below the 1000 threshold.
R3: effective additions 1560 at head 3cbebe3. Verdict: Don't split. Enforcement: Advisory. One dependency chain (refactors, URL validation, host sign-in, endpoints, proxy regions); the only vertical cut (proxy regions, about 45 production LOC) was judged not worth taking.

Round log

Round 1

Netero first pass: 4 P3/P4, 2 Nit, 2 Note. No P0; panel proceeded.

Round type: round 1, full panel. Multi-domain (security-sensitive token and cookie code): target 9-12.
Specialists: ging-go (.go files), Kurapika (tokens, cookies, host matching), Ryosuke (Go API and package boundaries), Melody (token crosses coderd to preview host and wsproxy). ging-ts and ging-react not spawned: the only .ts change is generated site/src/api/typesGenerated.ts.
Core: Pariston, Mafuuu. Pool: Bisky, Hisoka, Gon, Leorio, Razor, Mafu-san. Wildcard (random from distilled set): Meruem.

Cross-check:

  • CRF-8 upgraded from Netero Note to P2: Kurapika reproduced a token for one user's preview host passing the host check on another user's preview host (AgentName with a colon, HostnamesMatch strips the port). Orchestrator confirmed HostnamesMatch uses net.SplitHostPort on both sides (appurl.go:228) and hosting.URL does not validate AgentName.
  • CRF-9 convergent across 8 reviewers; Razor reproduced with Playwright Chromium (cookie sent for same-site frame, not for cross-site frame).
  • CRF-10 merges Pariston P3, Kurapika P4, Ryosuke Note, Mafuuu Note; higher severity P3.
  • CRF-12 merges Mafuuu P3, Hisoka P4, Razor P4; higher severity P3.
  • CRF-16 merges Gon P3 (codersdk/previews.go:28), Gon P2 (token.go:90, restatement plus wrong lifetime), Leorio P4.
  • CRF-17 downgraded Gon P2 to Nit. Keep argument: comments that restate code break the repository comment rule. Downgrade reason: the comment is accurate, so the consequence is a convention violation only.
  • CRF-18 downgraded Gon P2 to P3. Keep argument: a maintainer could drop the Secure line believing the prefix supplies it. Downgrade reason: the https row of TestServePreviewSessionCookie asserts the cookie string, so that removal fails a test.
  • CRF-19 downgraded Gon P3 to P4. Keep argument: the doc misstates the key lifetime. Downgrade reason: the real lifetime is shorter than documented, so a caller relying on the doc is not given a longer-lived key than expected; the text moved unchanged from workspaceApplicationAuth.
  • CRF-20 downgraded Gon P3 to P4. Keep argument: an exported field with an unclear contract can be checked wrongly by the client. Downgrade reason: experimental API whose only consumer is feat(site/src): open open_preview results in the right panel #32441 in the same stack; no wrong behavior in this PR.
  • CRF-32 merges Mafu-san P3 and Leorio P3 plus Leorio P4 (unresolvable references), all about PR text accuracy.
  • Positive confirmation notes (Melody, Razor, Bisky, Leorio, Mafu-san) record cleared concerns and are not inventoried.
    Totals posted: 2 P2, 14 P3, 12 P4, 5 Nit. 1 Note (body). 5 out of scope. Reviewed against f0bc2f2..24b45ed.

Round 2 update

BLOCKED. Churn guard: 19 addressed (claimed, unverified by panel), 14 silent (CRF-5, CRF-6, CRF-13, CRF-17, CRF-18, CRF-19, CRF-21, CRF-22, CRF-23, CRF-25, CRF-30, CRF-31, CRF-33, CRF-34). No author replies. No review. Reviewed against 69ee6a9..3cbebe3. Effective additions grew 805 to 1560; Law and a full restructure panel are due on the next unblocked round.

Round 3

Panel (restructure: new address endpoint, effective additions 805 to 1560). Churn guard PROCEED: 14 findings contested by author replies.
Netero (reused R1 agent) and Law ran; Law: Don't split, advisory.
Panel: ging-go, mafuuu, gon, leorio, meruem (reused R1 agents for dispute check-in; not counted toward size), kurapika, ryosuke, melody, pariston, bisky, hisoka, razor, mafu-san, knov (pool), kite (wildcard, random from chopper/kite/zoro).
Dispute check-in: 13 closed (CRF-5, 6, 13, 17, 18, 21, 22, 23, 25, 30, 31, 33, 34), 1 re-raised (CRF-19, Gon, new evidence that the text is a new doc comment).
Fix verification: CRF-9 re-raised at P2 by 10 reviewers (Hisoka P3): same-site check covers proxies only; Melody, Pariston, Bisky, Kite reproduced a 200 sign-in for a cross-site primary wildcard. CRF-10 per-open minting verified fixed (Pariston, Ryosuke); Kurapika's scope part split into CRF-45 with Knov's verified allow-list fix. Other fixes verified by Netero, Kurapika, Mafuuu, Gon, Meruem, Bisky, Razor, Leorio.
Drops: CRF-48 keep argument: duplicate rows cost maintenance; drop reason: the row is the only guard against re-adding a port-only agent check (the CRF-8 bug). CRF-52 keep argument: comment is on a new declaration; drop reason: moved unchanged, accurate, verbosity has no consequence, P2 not supported. CRF-55 keep argument: git log on the branch shows stale text; drop reason: Mafu-san verified squash commits use the PR body (f2b6084 from #31600), and the PR body is correct.
CI: Flake Check was cancelled for a newer run (Mafu-san), not a test failure.
Totals: 1 P2 re-raise, 1 P4 re-raise, new 2 P3, 8 P4, 2 Nit; 1 Note (body); 3 dropped. Reviewed against 69ee6a9..3cbebe3.

Round 4

Fix round (no added files or new goal; effective additions 1560 to 1581). Churn guard PROCEED: 6 addressed, 1 acknowledged (CRF-46), 7 contested.
Netero (reused) closed CRF-40 to CRF-43 (1/1 each) and raised CRF-56.
Panel: kurapika, knov, kite, gon, hisoka (reused agents), ging-go, ryosuke, melody, bisky, leorio (new agents; specialists for changed .go files, raisers of touched findings, Gon/Leorio for doc comment changes), razor (wildcard, random from mafuuu/meruem/chopper/zoro/razor).
Dispute check-in: CRF-50 and CRF-53 closed; CRF-45 re-raised by both raisers. CRF-46 acknowledged without ticket: needs human decision.
Fix verification: CRF-9 primary check verified (Kurapika, Knov, Kite, Ryosuke, Melody, Razor, Netero; Ryosuke and Melody ran Playwright probes of registrableDomain against Chromium/Firefox). CRF-19, 44, 47, 49, 51 verified.
Cross-check: CRF-56 raised to P3 as the convergence of Netero (duplicate check, two error types), Gon (sentinel doc now false), and Ryosuke (no startup diagnostic); one fix (same-site rule in previewhost.Strict wrapping the sentinel, primary recorded in previewsUnavailable at startup) resolves all three. CRF-60 merges Melody (refusal ignores SameSite=None, reproduced) and Leorio (comment cites only default Lax). CRF-63 merges Leorio P3 and Razor P4.
Totals: 1 P3 re-raise; new 2 P3, 5 P4, 2 Nit. Reviewed against e919721..5421940.

Round 5

Fix round (doc and errors.AsType changes only). Churn guard PROCEED: CRF-45 and CRF-46 accepted by the author as an operator decision; 5 contested; 4 addressed.
Netero (reused): no findings; closed its CRF-56 part. Panel (reused agents): gon, ryosuke, melody, leorio, bisky, ging-go, razor, kurapika; zoro (wildcard, random from mafuuu/meruem/chopper/kite/zoro/knov, new agent).
Dispute check-in: CRF-56 closed 3/3, CRF-57, CRF-61, CRF-62, CRF-64 closed; CRF-60 re-raised by Leorio for the comment only.
Verified: CRF-58 (doc; Ging-Go and Kurapika showed the ";" pair is harmless because every reader uses the same query parsing), CRF-59, CRF-63.
New: 2 P4, 1 Nit; 1 out of scope (#32440). Reviewed against 6747c02..99d01d9.

Round 6

Fix round (comment-only commit 588ce57). Churn guard PROCEED: 2 addressed, 2 contested.
Netero (reused): no findings. Panel: zoro, gon, leorio, melody, ging-go (reused agents), meruem (wildcard, random from mafuuu/meruem/chopper/kite/knov/razor, new agent).
Dispute check-in: CRF-66 and CRF-67 closed by Zoro.
Fix verification: CRF-65 verified. CRF-60 re-raised by Melody and Leorio (its raisers), with Gon converging: the new comment says browsers block or partition the cookie even with SameSite=None, but the R4 Playwright probe showed Chromium and Firefox send it, and Firefox partitioning keeps it in the reading frame; only blocking (Safari default, Chrome with third-party cookies off) breaks the flow. Meruem read the comment as correct; the raisers' empirical evidence outweighs it.
New: 1 Nit. Reviewed against 6747c02..588ce57.

Round 7

Fix round (comment-only commit 7cf249d). Churn guard PROCEED: 2 addressed, nothing contested.
Netero (reused): no findings. Panel: melody, leorio, gon, meruem, ging-go (reused agents; raisers of CRF-60 and CRF-69, Gon/Leorio for touched comments, Go specialist), kite (wildcard, random from mafuuu/chopper/kite/zoro/knov/razor, new agent).
Verified: CRF-60 and CRF-69. No new findings. No open findings remain; CRF-45 and CRF-46 stand as the author's operator decisions for the experimental release. Reviewed against 6747c02..7cf249d.

Round 8

Fix round (rebase onto 4cae110; only coderd/previews_test.go changed: refusal rows call both endpoints, three tests merged into TestPreviewRegions). Churn guard PROCEED with no open findings.
Netero (reused): no findings; verified every removed case survives and cancelled CI. Panel (new agents): bisky, ging-go, komugi (test changes), gon, leorio (comments changed), mafuuu (wildcard, random from mafuuu/meruem/chopper/kite/zoro/knov/razor).
Cross-check: CRF-70 downgraded Gon P2 to Nit. Keep argument: the moved comment now restates the code, against the repository comment rule. Downgrade reason: accurate test comment, no behavior consequence, consistent with CRF-17. CRF-71 dropped. Keep argument: four clauses restate the table. Drop reason: Leorio showed each clause maps to a row or assertion a maintainer must update when changing a refusal, so the doc carries navigation the table alone does not. CRF-73 merges Leorio's Nit and Gon's Note on the same comment.
Bisky, Mafuuu: tests genuine; only registrableDomain fallback (line 264) lost coverage and does not need a test. Komugi: map iteration order cannot change results; -race -count=5 passed.
New: 1 P4, 2 Nit. Reviewed against 4cae110..9aae1d9.

Round 9

Fix round (rebase onto 327e5ed; previewHostingFor reads the proxy with the caller's context instead of AsSystemRestricted; tests run as a member and add a scoped-token proxy case; CRF-73 comment). Churn guard PROCEED: 1 addressed, 2 contested.
Netero (reused): no findings; mutation-verified the scoped proxy case fails if AsSystemRestricted returns. Panel: gon, leorio (reused), kurapika, razor, ryosuke, ging-go, bisky (new; authz and test specialists for the changed code), chopper (wildcard, random from mafuuu/meruem/chopper/kite/zoro/knov).
Dispute check-in: CRF-70, CRF-72 closed by Gon.
Cross-check: CRF-74 convergent across six reviewers; severity P3 from Razor, supported by Bisky's verification that workspace_proxy:read is internal and cannot be requested by a token, so every scoped token is refused for every proxy region and the only remedy a message could name is not available. Razor and Ryosuke: fetchRegions and workspaceApplicationAuth read proxies under AsSystemRestricted, so the caller-context read protects no data. Kurapika rated the caller-context read correct (Note); the higher severity with stronger evidence wins. Leorio's proposed message (add workspace_proxy:read) is contradicted by Bisky's evidence and is not used.
CRF-73: Leorio verified, Gon re-raised (Primary row also compares the ported access URL); Gon's evidence is specific, re-raised as Nit.
CRF-5: re-raised by Ging-Go (new persona) with new evidence defeating the R3 defense: guts treats omitzero as optional too, and codersdk already uses uuid.UUID with omitzero.
New: 1 P3, 1 Nit; 2 re-raises (P4, Nit); 1 out of scope. Reviewed against 327e5ed..4f68cc0.

Round 10

Fix round (previewHostingFor back to AsSystemRestricted with sql.ErrNoRows; scoped-token proxy case expects success; CRF-73 and CRF-75 comments; RegionID omitzero). Churn guard PROCEED: 4 addressed.
Netero (reused): no findings; regenerated TS types, region_id?: string unchanged. Panel: razor, bisky, gon, ging-go, kurapika (reused, raisers of CRF-74/75/73/5 and authz), zoro (wildcard, random from mafuuu/meruem/chopper/kite/zoro/knov).
Verified: CRF-74 (Netero, Bisky, Gon, Kurapika, Zoro), CRF-73 (Netero, Bisky, Gon), CRF-5 (Netero, Bisky, Ging-Go, Zoro, Gon).
Cross-check: Gon showed coder:all is public (IsExternalScope, rbac/scopes_catalog.go) and grants wildcard (rbac/scopes.go:81-82), so "can never hold" (previews.go:231) and "No public scope grants" (previews_test.go:429) are false; orchestrator confirmed both in source. R9 Bisky evidence (coder:all with this allow list still 400) shows the allow list still matters, so CRF-75 is re-raised. Gon rated both P3; downgraded to Nit because the code is correct and only the comments overclaim.
New: 1 Nit; 1 re-raise (Nit). Reviewed against 4f68cc0..aa2ba14.

About deep-review

CRF = Coder Review Finding (P0-P4, Nit, Note)

Reviewer Focus
Bisky tests
Chopper ops/errors
Churn-guard change verification
Ging language modernization
Gon naming
Hisoka edge cases
Killua perf
Kite change integrity
Knov contracts
Knuckle SQL
Komugi flake/determinism
Kurapika security
Law decomposition
Leorio docs
Luffy product
Mafu-san process
Mafuuu contracts
Melody dispatch/pairing
Meruem structural
Nami frontend
Netero mechanical checks
Pariston premise testing
Pen-botter product gaps
Razor verification
Robin duplication
Ryosuke Go arch
Takumi concurrency
Zoro shape

🤖 Managed by Coder Agents.

@coder-agents-review coder-agents-review Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR adds a dashboard sign-in endpoint that mints a host-bound, encrypted preview sign-in token, and a preview-host handler that trades it for a host-only session cookie. Findings: 2 P2, 14 P3, 12 P4, 5 Nit.

The two P2 findings are the host binding, which another user's token can pass, and the cookie's SameSite value, which breaks sign-in when the preview host is a different site from the dashboard.

Out of scope (needs a ticket or explicit acceptance by a human):

  • coderd/workspaceapps/provider.go:95: the signed app token cookie set on preview hosts also takes the deployment SameSite value, so a cross-site preview host would miss it on every request and re-issue a token each time.
  • coderd/workspaceapps/proxy.go:326: handleAPIKeySmuggling also redirects through originLocalURL(r.URL.Path), so subdomain apps opened at a path with %2F load a different path after app sign-in.
  • coderd/workspaceapps/token.go:58: EncryptedAPIKeyPayload is accepted for up to two minutes after minting (one-minute expiry plus jwt.DefaultLeeway), and nothing documents that window.
  • coderd/workspaceapps/previewhost/previewhost.go:191: applyPolicy drops Set-Cookie headers with a Domain, but preview scripts run with allow-same-origin and can set document.cookie with domain= the app wildcard parent, including a coder_subdomain_app_session_token_* cookie on the user's other apps.
  • coderd/workspaceapps.go:140: createAppConnectKey computes expiry with time.Until and dbtime.Now, not api.Clock, so mock-clock tests cannot control the key lifetime.

Notes:

  • coderd/previews.go:126: payload.Subject is set, but signInPreview and PreviewSignInPayload.Validate never read it, while the APIKey field doc says the key belongs to "the user in Subject".

coderd/httpapi/cookie.go:32

P3 [CRF-3] This PR makes the comment's reason false: the preview cookie's __Host- prefix now follows the hosting scheme, not the deployment host-prefix setting. (Netero)

With PreviewSessionTokenCookie removed from cookiesToPrefix, EnableHostPrefix has no effect on it. Stripping both names is still correct because both can exist after the access URL scheme changes; say that in the comment.

🤖

🤖 This review was automatically generated with Coder Agents.

Comment thread coderd/previews.go
}
previewURL, err := hosting.URL(appurl.ApplicationURL{
AppSlugOrPort: req.PreviewSlug,
AgentName: req.AgentName,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 [CRF-8] A token minted by one user passes the host check on another user's preview host. (Kurapika, Netero)

req.AgentName reaches hosting.URL unvalidated for file slugs, so AgentName = "dev--site--testuser.a.co:1" builds payload.Host = "preview--0123abcd--dev--site--testuser.a.co:1--w--atk.a.co", and appurl.HostnamesMatch runs net.SplitHostPort and drops everything after the last colon. Reproduced with a scratch test: user atk minted a token for workspace w, sent it to testuser's preview host, and got 303 with Set-Cookie: coder_preview_session_token=<atk's key>. Issue still refuses atk's key there, but a page that frames the victim's preview host with this token replaces the victim's preview cookie, and the preview returns errors until reopened. Check AgentName against the workspace's agents for every slug (or require hosting.Parse(previewURL.Host) to return the same ApplicationURL), and compare payload.Host to the request host exactly in signInPreview.

🤖

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified fixed in 3cbebe3321.

🤖

// of h with apiKey. It has no Domain, so it stays on that host. Over plain
// HTTP, where browsers reject Secure from most hosts, Secure follows cfg.
func (h *Hosting) SessionCookie(apiKey string, cfg codersdk.HTTPCookieConfig) *http.Cookie {
cookie := cfg.Apply(&http.Cookie{

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 [CRF-9] The preview session cookie takes SameSite from --samesite-auth-cookie (default lax), so browsers neither store nor send it when the preview host is a different site from the dashboard. (Razor, Ryosuke, Melody, Pariston, Mafuuu, Bisky, Meruem, Hisoka)

The sign-in and every later preview request run inside the dashboard iframe (servePreview refuses Sec-Fetch-Dest: document), and previewHostingFor accepts a primary wildcard or a proxy WildcardHostname on another registrable domain. Reproduced with Playwright Chromium: a page on coder.a.test framing a host that sets a SameSite=Lax cookie and 303s gets the cookie back on p.apps.a.test and not on p.apps-b.test, so on such a deployment every preview ends at the 401 "Reopen this preview" page. The tests use Go HTTP clients and a zero cookie config, so they cannot catch this. Either refuse non-same-site regions in previewHostingFor with an error that names the requirement, or set SameSite=None; Secure; Partitioned on HTTPS and document that browsers blocking third-party cookies still fail.

🤖

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same-site check covers workspace proxies only. The primary branch of previewHostingFor (coderd/previews.go:208) returns api.previewHosting without the registrableDomain comparison, and coderd.go:748 builds it with no site check. A scratch test with access URL https://dashboard.test.coder.com and AppHostname: *.apps.example.net got 200 from PreviewSignIn and minted a key; in the browser the cookie is dropped, the 401 page asks the dashboard to sign in again, and each retry mints another key. Run the comparison in previewhost.Strict (all three callers pass dashboardURL) so the primary records it in previewsUnavailable, and add a primary cross-site test row. (Ryosuke, Melody, Pariston, Bisky, Razor, Mafu-san, Knov, Kite, Mafuuu, Meruem, Hisoka)

🤖

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 5421940: sign-in now refuses a primary region whose wildcard access URL is on another site with 400 "Previews need a wildcard access URL on the same site as the dashboard." from both endpoints and mints no key, and a cross-site proxy gets its own 400 "Previews need a workspace proxy on the same site as the dashboard."; TestPreviewSignInUnavailable/CrossSite and TestPreviewSignInRegions cover both.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified fixed in 5421940ac8.

🤖

Comment thread coderd/previews.go Outdated
return
}

key, err := api.createAppConnectKey(ctx, apiKey)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3 [CRF-10] Every sign-in mints a new application_connect key with whole-user scope and up to Sessions.DefaultDuration lifetime, and the key it replaces in the preview cookie stays valid. (Pariston, Kurapika, Ryosuke, Mafuuu)

The dashboard cannot read the preview host's HttpOnly cookie, so it must call this endpoint each time it frames a preview, and preview hosts are per preview ID; workspaceApplicationAuth mints a key only when an app host has no session. Each open therefore adds an api_keys row that lives up to 24h by default and opens every app the owner can reach, and the one-minute token can be replayed within its window to obtain it. Give this key a lifetime bounded to preview use, or skip minting when the host already holds a valid key for the same user.

🤖

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified fixed in 3cbebe3321.

🤖

Comment thread coderd/previews.go
}
// A preview runs agent-written code as whoever opens it, so only the
// workspace owner may, even when the workspace is shared.
if workspace.OwnerID != apiKey.UserID {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3 [CRF-11] The owner-only and port forwarding checks here copy the rules Issue enforces at coderd/workspaceapps/db.go:189-195, using a different agent lookup. (Ryosuke, Meruem, Pariston)

This handler matches req.AgentName exactly against GetWorkspaceAgentsInLatestBuildByWorkspaceID and only for port slugs, while Issue resolves the agent through Request.getDatabase; the two already disagree for an unknown agent on a file slug. When a rule changes in one copy, the endpoint mints keys for previews that Issue refuses, or refuses previews Issue would serve, and no test compares them. Move the rules into one workspaceapps function and call it from both places.

🤖

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified fixed in 3cbebe3321.

🤖

Comment thread coderd/workspaceapps/preview.go Outdated

http.SetCookie(rw, s.Previews.SessionCookie(payload.APIKey, s.CookiesConfig))

redirectURL := originLocalURL(r.URL.Path)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3 [CRF-12] The post-sign-in redirect is built from the decoded r.URL.Path, so /files/a%2Fb.html reloads as /files/a/b.html. (Mafuuu, Hisoka, Razor)

Hosting.URL keeps RawPath in the URL it signs, but originLocalURL(r.URL.Path) drops it; verified that originLocalURL on /files/a%2Fb.html returns /files/a/b.html. A preview server that routes on escaped segments serves a different resource than the one requested. Build the redirect from r.URL.EscapedPath() with the same leading-slash trimming.

🤖

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified fixed in 3cbebe3321.

🤖

Comment thread coderd/previews.go
hosting, err := api.previewHostingFor(ctx, req.RegionID)
if err != nil {
httpapi.Write(ctx, rw, http.StatusBadRequest, codersdk.Response{
Message: "This region does not serve previews.",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3 [CRF-1] Every previewHostingFor error becomes 400 "This region does not serve previews.", including database failures. (Netero)

A lost connection or canceled context from GetWorkspaceProxyByID answers 400 with the raw database error in Detail, while the rest of this handler answers such errors with httpapi.InternalServerError. Return 400 for sql.ErrNoRows, a deleted proxy, and a missing wildcard hostname, and 500 for every other error.

🤖

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified fixed in 3cbebe3321.

🤖

Comment thread coderd/workspaceapps/preview.go Outdated
return
}

// The direct-open redirect above already answered page loads, so a

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3 [CRF-2] The comment refers to "the direct-open redirect above", but the code above refuses page loads with a 403 error page. (Netero)

Say "The page-load refusal above".

🤖

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified fixed in 3cbebe3321.

🤖

Comment thread coderd/previews.go Outdated
// Workspace proxies always host previews in strict mode.
func (api *API) previewHostingFor(ctx context.Context, regionID uuid.UUID) (*previewhost.Hosting, error) {
if regionID == uuid.Nil || regionID.String() == api.DeploymentID {
if api.previewHosting == nil {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P4 [CRF-4] The primary-without-wildcard branch and the deleted or no-wildcard proxy branch of previewHostingFor have no test. (Netero)

Verified with -coverprofile: blocks at previews.go:153 and :164 have count 0. If the proxy.Deleted check is removed, a deleted proxy's hostname gets a sign-in token and no test fails.

🤖

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified fixed in 3cbebe3321.

🤖

Comment thread codersdk/previews.go Outdated
URLPath string `json:"url_path,omitempty"`
// RegionID picks the primary or a workspace proxy. Empty picks the
// primary.
RegionID uuid.UUID `json:"region_id,omitempty" format:"uuid"`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit [CRF-5] omitempty on RegionID uuid.UUID has no effect: uuid.UUID is a [16]byte array, so it is always sent as the zero UUID. (Netero)

Drop omitempty, or use *uuid.UUID if the field should be omitted.

🤖

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a bug: the tag makes the generated TypeScript field optional (readonly region_id?: string), as it does for the other uuid.UUID fields with omitempty in codersdk.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Defense accepted.

🤖

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New evidence against the round 3 defense: guts also marks omitzero fields optional (convert.go:816 in v1.7.0 checks omitempty || omitzero), and codersdk already uses uuid.UUID with omitzero (codersdk/agentsdk/agentsdk.go:896, codersdk/chats.go:735). json.Marshal(codersdk.PreviewSignInRequest{}) still produces "region_id":"00000000-0000-0000-0000-000000000000". Use json:"region_id,omitzero" (Go 1.24+), which keeps readonly region_id?: string and actually omits the field. (Ging-Go)

🤖

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in aa2ba14: thanks for the new evidence. region_id now uses omitzero, so a zero region is omitted; the generated TypeScript stays region_id?: string.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified fixed in aa2ba145ea.

🤖

// parent domain, such as by another preview.
func (h *Hosting) SessionCookieName() string {
if h.scheme == "https" {
return "__Host-" + codersdk.PreviewSessionTokenCookie

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit [CRF-6] The literal "__Host-" duplicates codersdk.cookieHostPrefix, and coderd/httpapi/cookie.go:34 has a third copy. (Netero)

Export the codersdk constant and use it in both places.

🤖

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Declined: exporting codersdk.cookieHostPrefix widens the SDK API for one string literal; cheap to revisit.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Defense accepted.

🤖

@DanielleMaywood
DanielleMaywood force-pushed the open-preview/sign-in branch 2 times, most recently from b5aeb4e to 8ef1834 Compare November 25, 2026 16:09
@DanielleMaywood
DanielleMaywood force-pushed the open-preview/sign-in branch 2 times, most recently from 7e0d8c7 to c9d354e Compare November 25, 2026 22:02
@DanielleMaywood

Copy link
Copy Markdown
Collaborator Author

/coder-agents-review

@coder-agents-review coder-agents-review Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This rebase changes only coderd/previews_test.go: refusal cases now call both endpoints, and three region tests are merged into TestPreviewRegions. Findings this round: 1 P4, 2 Nit, all in test comments and names.

The merged test keeps every case from the three tests it replaces, and the primary cross-site row is now cross-site by construction. No production code changed since round 7. CI for 9aae1d9d33 has no completed result: the failed jobs that were checked (changes, Flake Check, lint, fmt) are cancelled runs with no failed step.

🤖 This review was automatically generated with Coder Agents.

Comment thread coderd/previews_test.go
if tc.client != nil {
c = tc.client
}
// The address endpoint refuses what sign-in refuses.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit [CRF-70] "The address endpoint refuses what sign-in refuses." now restates the loop below it. (Gon)

In the old TestPreviewAddress it explained a single PreviewAddress call; here both endpoints are called with the same req and checked against the same tc.wantStatus, so the code says it. Delete the comment.

🤖

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Declined: the loop calls both endpoints, but the comment states the rule the test exists for (the address endpoint refuses what sign-in refuses), which a reader would otherwise have to infer from the shared req.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Defense accepted.

🤖

Comment thread coderd/previews_test.go

const apps = "*.apps.test.coder.com"
const regionRefused = "This region does not serve previews."
const hostPrefixOff = "Previews require --host-prefix-cookie. An administrator can enable it."

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P4 [CRF-72] The constant hostPrefixOff holds an error message, and the table field hostPrefixOff is a bool, so rows read hostPrefixOff: true, ..., wantMessage: hostPrefixOff. (Gon)

A reader has to work out that the key is the field and the value is the constant. Rename the constants to hostPrefixRequiredMessage and regionRefusedMessage.

🤖

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Declined: the table field and the constant share a name because each row that sets the flag also expects that message, and the constant is declared three lines above the table, so a reader finds which is which immediately.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Defense accepted.

🤖

Comment thread coderd/previews_test.go Outdated
dv := coderdtest.DeploymentValues(t)
dv.Experiments = []string{string(codersdk.ExperimentOpenPreview)}
dv.HTTPCookies.EnableHostPrefix = !tc.hostPrefixOff
// The port checks that same-site comparisons ignore it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit [CRF-73] "The port checks that same-site comparisons ignore it." reads as the noun phrase "the port checks", and it omits that the Primary row's wantOrigin also relies on :8443. (Leorio, Gon)

Someone simplifying the setup could drop the port and break Primary without knowing why. Say what each row needs, for example: "The dashboard's :8443 port makes the Proxy row fail if the same-site check compares ports, and the Primary row expects the port in its origin."

🤖

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 4f68cc0: the comment now says the :8443 port makes the Proxy row fail if the same-site check compares ports, and that the Primary row expects the port in its origin.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Primary row also depends on the port being ignored: previewHostingFor compares registrableDomain of *.apps.test.coder.com with the :8443 access URL, so a port-comparing check fails both successful rows, not only Proxy. Say "makes the Primary and Proxy rows fail if the same-site check compares ports, and the Primary row expects the port in its origin." (Gon)

🤖

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in aa2ba14: the comment now says the :8443 port makes the Primary and Proxy rows fail if the same-site check compares ports.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified fixed in aa2ba145ea.

🤖

@DanielleMaywood

Copy link
Copy Markdown
Collaborator Author

/coder-agents-review

@coder-agents-review coder-agents-review Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This rebase changes previewHostingFor to read the workspace proxy with the caller's context instead of AsSystemRestricted, runs the region tests as a member, and adds a scoped-token proxy case. Findings this round: 1 P3, 1 Nit new; 1 P4 and 1 Nit re-raised.

The caller-context read blocks every scoped token from every proxy region with a message that says the proxy is missing, while the regions endpoint and app sign-in read proxies as the system. The omitempty on RegionID is re-raised because omitzero keeps the TypeScript field optional and also omits it. Two contested findings are closed.

Out of scope (needs a ticket or explicit acceptance by a human):

  • enterprise/coderd/workspaceproxy.go:64: the fetchRegions comment says users cannot usually access workspace proxies, but memberRole grants every member read on them, so a reader would wrongly expect the new caller-context read to refuse members.

CI: the failed jobs that were checked (changes, fmt, test-go-pg) are cancelled runs, so 4f68cc01bd has no completed CI result yet.

🤖 This review was automatically generated with Coder Agents.

Comment thread coderd/previews.go Outdated
// such as through a token scope without workspace_proxy:read, counts as
// unknown.
proxy, err := api.Database.GetWorkspaceProxyByID(ctx, regionID)
if httpapi.Is404Error(err) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3 [CRF-74] Reading the proxy with the caller's context refuses every scoped token for every proxy region, and the response says the proxy does not exist. (Razor, Gon, Leorio, Ryosuke, Bisky, Chopper)

httpapi.Is404Error matches dbauthz denials, so a token without workspace_proxy:read gets 400 "This region does not serve previews." with Detail "no workspace proxy has ID ...: choose another region" (reproduced in the new TestPreviewSignInScopedToken case), and CreateToken rejects workspace_proxy:read as internal, so no narrower-than-all token can ever pass. The read protects no data: fetchRegions (enterprise/coderd/workspaceproxy.go:67) lists every proxy's URL and wildcard under AsSystemRestricted, and workspaceApplicationAuth looks proxies up the same way, so the same token can open ordinary apps on that proxy but not previews. Either read the proxy as fetchRegions does and expect success in the scoped case, or keep the caller read and return a distinct refusal that does not claim the proxy is missing, and assert its exact message at previews_test.go:433.

🤖

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in aa2ba14: you are right that no public scope can carry workspace_proxy:read and that the read protects no data. The proxy lookup reads as the system again, like the regions endpoint and app sign-in, and TestPreviewSignInScopedToken now expects a coder:workspaces.access token to sign in to a proxy region (it fails if the lookup uses the caller context).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified fixed in aa2ba145ea.

🤖

Comment thread coderd/previews_test.go Outdated
require.NoError(t, signIn(uuid.Nil, codersdk.APIKeyScopeCoderWorkspacesAccess, codersdk.APIKeyScopeApiKeyCreate))
require.Equal(t, 1, appConnectKeys(ctx, t, api.Database, first.UserID))

// The scope cannot read workspace proxies, so a proxy region is refused.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit [CRF-75] "The scope cannot read workspace proxies" credits the scope alone, but the token's allow list also blocks the read, and either one produces the 400. (Bisky)

Verified by temporary edits: APIKeyScopeAll with this allow still gets 400, and so does the workspaces-access scope with a proxy allow target; only both together get 200. Say "Neither the scope nor the allow list grants workspace_proxy:read".

🤖

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in aa2ba14: that refusal is gone, and the comment above the new proxy-region success now says no public scope grants workspace_proxy:read.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new comment says "No public scope grants workspace_proxy:read", which is false for coder:all (see CRF-77), and it still leaves out the allow list: in round 9, APIKeyScopeAll with this token's allow also got 400. Say "No public low-level scope grants workspace_proxy:read, and the allow list has no proxy entry, so the token signs in to a proxy region only because the lookup needs neither." (Gon)

🤖

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in cb551b7: the test comment now says no public low-level scope grants workspace_proxy:read and the allow list has no proxy entry, so the token signs in to a proxy region only because the lookup needs neither.

@DanielleMaywood

Copy link
Copy Markdown
Collaborator Author

/coder-agents-review

@coder-agents-review coder-agents-review Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The proxy lookup reads as the system again, and the CRF-74, CRF-73 and CRF-5 fixes are verified: go test ./coderd -run TestPreview passes, the scoped-token proxy case fails if the caller-context read returns (it got 400 in round 9), and regenerating the TypeScript types keeps region_id?: string. Findings this round: 1 Nit new, 1 Nit re-raised. Both are comments that say no public scope grants workspace_proxy:read, which is false for coder:all.

CI at aa2ba145ea: 15 passed, 12 skipped, 5 still running, none failed.

🤖 This review was automatically generated with Coder Agents.

Comment thread coderd/previews.go Outdated
return api.previewHosting, nil
}

// The regions endpoint and app sign-in read proxies the same way, so a

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit [CRF-77] "a scoped token, which can never hold workspace_proxy:read" is false: the public coder:all scope grants it. (Gon)

IsExternalScope accepts ScopeAll (coderd/rbac/scopes_catalog.go), and its role grants ResourceWildcard.Type: {policy.WildcardSymbol} (coderd/rbac/scopes.go:81-82). The claim the code relies on is narrower: no public low-level scope grants workspace_proxy:read. Say "No public low-level scope grants workspace_proxy:read, so reading with the caller's context would refuse every proxy region to a token limited to those scopes."

🤖

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in cb551b7: the comment now says no public low-level scope grants workspace_proxy:read (the all scope does), so reading as the caller would refuse scoped tokens that ordinary apps accept.

@DanielleMaywood

Copy link
Copy Markdown
Collaborator Author

/coder-agents-review

@coder-agents-review

Copy link
Copy Markdown
Contributor

@DanielleMaywood ⛔ This review has reached its per-chat spend limit ($107.08 / $100.00). Further review rounds are paused.

To raise the limit and continue, comment:

/coder-agents-review set-spend-limit:150

This is a per-chat budget, separate from any account-level usage limit.

🤖 Managed by Coder Agents.

@DanielleMaywood
DanielleMaywood marked this pull request as ready for review November 26, 2026 22:04
@DanielleMaywood DanielleMaywood removed the experimental Changes that might not necessarily be merged, until its approved to proceed with. label Nov 26, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-26T22:09:40.905181Z cb551b7 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cb551b7f0c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +140 to +141
Path: "/" + strings.TrimLeft(r.URL.Path, `/\`),
RawPath: "/" + strings.TrimLeft(r.URL.EscapedPath(), `/\`),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve an encoded leading slash during sign-in

When url_path begins with an encoded slash, such as /%2Fadmin, net/http exposes r.URL.Path as //admin while EscapedPath() remains /%2Fadmin. Trimming the decoded path changes it to /admin, so the supplied RawPath no longer encodes Path; url.URL.String() consequently discards RawPath and redirects to /admin. Since CheckURLPath accepts this input, sign-in silently opens a different application route. Preserve matching decoded and escaped paths, or reject an encoded leading slash.

Useful? React with 👍 / 👎.

Comment thread coderd/previews.go
Comment on lines +244 to +245
if registrableDomain(strings.Replace(proxy.WildcardHostname, "*", "preview", 1)) != registrableDomain(api.AccessURL.Host) {
return nil, crossSiteError("Previews need a workspace proxy on the same site as the dashboard.")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Include the scheme when validating a proxy's site

When the dashboard and workspace proxy share a registrable domain but use different schemes, this check accepts the region even though browsers treat them as different schemeful sites. An HTTPS dashboard cannot frame an HTTP proxy because the iframe is active mixed content; in the inverse configuration, the default SameSite=Lax preview cookie is not sent in the cross-site iframe. The endpoint therefore returns a successful but unusable preview URL, so the proxy scheme should also match the dashboard scheme.

Useful? React with 👍 / 👎.

@mafredri
mafredri self-requested a review December 1, 2026 09:55
@DanielleMaywood
DanielleMaywood force-pushed the open-preview/sign-in branch 6 times, most recently from db90c9e to 162a9ad Compare December 2, 2026 15:56
Adds POST /api/experimental/previews/sign-in, which returns the preview
URL with a one-minute token bound to the exact preview host. The preview
host exchanges it for a host-only session cookie and never accepts the
wildcard app cookie, so a preview cannot replace the user's app sign-in.
POST /api/experimental/previews/address returns the same preview
address without minting a token, so the dashboard can load the preview
with an existing preview session first.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant