Files
coder/coderd/workspaceapps/apptest
dylanhuff-at-coderandClaude Opus 5.5 8efd1fc86e fix(coderd/workspaceapps)!: strip session tokens before proxying to apps (#31633)
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](https://linear.app/codercom/issue/CORE-817/strip-authorization-and-access-token-from-app-proxy-requests-when).

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.

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-04 09:59:50 -08:00
..