The vulnerability existed because the application blindly trusted the X-Forwarded-Host HTTP header to determine the routing for workspace apps. The core of the issue was in the github.com/coder/coder/v2/coderd/httpapi.RequestHost function, which prioritized this header over the actual Host header without any validation of the request's origin.
The function github.com/coder/coder/v2/coderd/workspaceapps.(*Server).HandleSubdomain utilized RequestHost to resolve the target application. This allowed an attacker, who could control a shared workspace app, to serve JavaScript that sends same-site requests with a forged X-Forwarded-Host header pointing to a victim's private app. The server would then incorrectly route the request based on the attacker-controlled header but authorize it using the victim's session cookie, leading to unauthorized data access.
The patch addresses this by removing the RequestHost function entirely and introducing a new function, httpmw.EffectiveHost. This new function only trusts the X-Forwarded-Host header if the request originates from a configured trusted proxy. The HandleSubdomain function was updated to use this new, secure method for host resolution, thus mitigating the vulnerability.