The vulnerability stems from improper input validation of the HTTP Host header (and its alternatives X-Forwarded-Host and :authority) within the request.host getter in Koa's lib/request.js. The getter did not sanitize the header value, allowing strings containing userinfo (e.g., user@host) to be processed.
The primary vulnerable function is request.hostname, which consumed the output of request.host. It naively split the host string at the first colon, causing an attacker-controlled value to be interpreted as the hostname. For example, a Host header of evil.com:fake@legitimate.com would cause request.hostname to return evil.com.
This flaw allows for various attacks, including password reset poisoning, cache poisoning, and SSRF, where applications use ctx.hostname to generate URLs. The request.origin getter was also affected as it used the unvalidated host value to construct the origin URL.
The patch addresses the root cause in the request.host getter by detecting the presence of an @ symbol and using the URL API to correctly parse the host, effectively stripping any malicious userinfo before the value is used by request.hostname or request.origin.