You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
fix: use unique cookies for workspace proxies (#19930)
There is currently an issue with subdomain workspace apps on workspaceproxies, where if you have a workspace proxy wildcard nested beneath theprimary wildcard, cookies from the primary may be sent to the serverbefore cookies from the proxy specifically.Currently:1. Use a subdomain app via the primary proxy `*.coder.corp.com` a. Client sends no cookies a. Server does token smuggling flowa. Server sets a cookie `coder_subdomain_app_session_token` on`*.coder.corp.com` a. Server redirects client to reload the page a. Request should succeed as usual1. Wait until the primary proxy's session token cookie has expired inthe database (or make it invalid yourself)1. Use a subdomain app via a separate proxy `*.sydney.coder.corp.com`a. Client sends `coder_subdomain_app_session_token` cookie from`*.coder.corp.com` a. Server validates supplied cookie, it fails because it's expired a. Server does token smuggling flowa. Server sets a cookie `coder_subdomain_app_session_token` on`*.sydney.coder.corp.com` a. Server redirects client to reload page a. Client sends BOTH cookies.a. The server will only process the first cookie it receives, so if theexpired cookie for the primary proxy is sent first the request will endup in a permanent loop on step b.The fix is to append `_{hash(wildcard_access_url)}` to the subdomaincookies as we cannot control browser behavior further. This avoids theconflict as each proxy will only read it's specific cookie.