Skip to content

fix(coderd/workspaceapps)!: strip session tokens before proxying to apps - #31633

Merged
dylanhuff-at-coder merged 3 commits into
mainfrom
dylan/strip-coder-token-app-proxy
Nov 4, 2026
Merged

dylanhuff-at-coder merged 3 commits into
mainfrom
dylan/strip-coder-token-app-proxy

Conversation

@dylanhuff-at-coder

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

Copy link
Copy Markdown
Collaborator

The workspace app proxy stripped Coder cookies before forwarding a request to the app, but not the Coder-Session-Token header or the coder_session_token query parameter. App auth accepts both, so a client that authenticated that way (the CLI and codersdk, or an IDE extension pointed at a path app URL) passed its API key through to whatever runs behind the app. That matters most for shared apps and ports, where the caller's token reached a workspace owned by someone else.

This strips both before proxying. The query parameter is removed from the raw query string, so everything else in the query reaches the app byte-for-byte. Authorization and access_token are still forwarded since apps can use them for their own auth. Stripping those safely needs to know which credential Coder actually used, so that's tracked in CORE-817.

This is marked breaking because an app that relied on the caller's Coder token arriving through that header or query param won't get it anymore. Cookie-authenticated requests were already covered, so this only affects callers that send the token in that header or query param. Nothing in this repo depends on it. Apps that need to call the Coder API as the visitor should use the OAuth2 provider instead.

Covered by the shared app proxy tests, which run against coderd and wsproxy, for both the owner on a path app and another user on a shared subdomain app, plus unit tests for the query filtering.

The app proxy only stripped Coder cookies, so a request authenticated
with the Coder-Session-Token header or the coder_session_token query
parameter forwarded the caller's API key to the workspace app.

Remove both before the request reaches the app. The query parameter is
removed from the raw query, so the rest of the query string is forwarded
unchanged. Authorization and access_token are still forwarded since
apps can use them for their own auth.
…bdomain app

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dylanhuff-at-coder dylanhuff-at-coder changed the title fix(coderd/workspaceapps): strip session tokens before proxying to apps fix(coderd/workspaceapps)!: strip session tokens before proxying to apps Nov 3, 2026
@github-actions github-actions Bot added the release/breaking This label is applied to PRs to detect breaking changes as part of the release process label Nov 3, 2026
… helper

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dylanhuff-at-coder
dylanhuff-at-coder marked this pull request as ready for review November 4, 2026 16:56
@dylanhuff-at-coder
dylanhuff-at-coder requested review from a team and geokat November 4, 2026 17:17
@BobbyHo
BobbyHo self-requested a review November 4, 2026 17:23

@BobbyHo BobbyHo left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Just one small thing regarding the following comment:

Authorization and access_token are still forwarded since apps can use them for their own auth. Stripping those safely needs to know which credential Coder actually used, so that's left for a follow-up.

Would you mind creating a Linear ticket to track this so we can follow up on it later? Thanks!

@dylanhuff-at-coder

Copy link
Copy Markdown
Collaborator Author

Thanks! Opened CORE-817 to track stripping Authorization and access_token when Coder used them to authenticate, and linked it from the description.

@dylanhuff-at-coder
dylanhuff-at-coder merged commit 8efd1fc into main Nov 4, 2026
42 of 43 checks passed
@dylanhuff-at-coder
dylanhuff-at-coder deleted the dylan/strip-coder-token-app-proxy branch November 4, 2026 17:59
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 4, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release/breaking This label is applied to PRs to detect breaking changes as part of the release process

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants