Summary
Coder's CLI command coder open app previously substituted a real user session token into unvalidated external app URLs before passing them to the operating system to open.
If a user ran the command against a workspace whose external app URL was controlled by a malicious template author, their session token could be exfiltrated to an attacker-controlled destination.
Affected context
This vulnerability affects Coder deployments where users rely on the coder open app CLI command to launch workspace applications defined by templates.
The risk arises when:
- Workspace templates define "external app" URLs, and
- Those URLs are authored or influenced by untrusted parties, and
- The URL contains the
$SESSION_TOKENplaceholder that the CLI replaces with the user's actual session token.
The issue is limited to environments where untrusted or partially trusted template authors can define external app URLs for workspaces opened by other users.
Exploit preconditions
- Attack surface: Coder CLI users who invoke
coder open appon workspaces with externally defined app URLs. - Required access: Ability for an attacker to define or modify the workspace's external app URL via a malicious template or template update.
- Trigger point: A victim runs
coder open appfor the malicious workspace, causing the CLI to substitute$SESSION_TOKENinto the attacker-controlled URL. - Why exploitation is possible: The CLI both trusted and interpolated the placeholder into the URL without enforcing a safe set of URL schemes or validating the destination host, enabling redirection or capture of the session token by an attacker-controlled endpoint.
Why this happens
The core issue stems from treating a sensitive authentication token as simple string data and embedding it into an unvalidated, attacker-controlled URL.
This maps to CWE-522: Insufficiently Protected Credentials, as session tokens are handled without strict destination controls or confidentiality guarantees, and to CWE-601: Open Redirect, because arbitrary external URLs are launched without scheme or host validation.
Abstractly, the vulnerable pattern is: a client-side helper substitutes secrets into locations influenced by untrusted configuration, then hands control to a generic URL handler, assuming the environment will be safe.
Potential impact
- Session token disclosure to an attacker-controlled server via crafted external app URLs
- Unauthorized use of the stolen session token to impersonate the affected user
- Access to the victim's workspaces, configurations, and potentially private source code
- Lateral movement within the Coder environment using compromised accounts
- Persistent compromise if tokens grant long-lived or refreshable access
General mitigation guidance
Effective mitigation focuses on restricting where sensitive tokens can flow and constraining URL handling behavior:
- Apply strict allowlists for URL schemes (for example, only https/http where appropriate) before launching external links from CLI tools or user interfaces.
- Limit token interpolation to a small set of known, trusted destinations (such as the official web frontend) and avoid including secrets in arbitrary URLs.
- Treat template-defined URLs as untrusted input and enforce validation rules (scheme, host, and path patterns) before use.
- Reduce the lifetime and scope of session tokens so that accidental exposure has less impact.
- Encourage separation of configuration roles so that only trusted parties can author templates that influence token-bearing operations.
How teams detect issues like this
High-level detection combines configuration review with analysis of how secrets are handled in client utilities:
- Use static analysis or code scanning rules to flag patterns where authentication tokens, session identifiers, or API keys are concatenated into URLs or other outbound parameters influenced by user or template input.
- During code review, pay special attention to helper commands that "convenience-open" URLs or apps, ensuring they validate schemes/hosts and never inject secrets into untrusted destinations.
- Implement policy checks on templates that define external app URLs, enforcing allowed hostnames and protocols before they are made available to other users.
- Monitor access logs for unusual patterns, such as session tokens appearing in query strings of external domains, as this can indicate past or ongoing abuse.

