The vulnerability exists in the redirect handling logic of the @hapi/wreck library. When a request is redirected, the library attempts to strip sensitive headers (like Authorization and Cookie) for cross-origin redirects. However, the check for 'cross-origin' was flawed. It only compared the hostname of the original request and the redirect location. It did not consider the port or the scheme (HTTP/HTTPS).
This means if a request to https://example.com was redirected to http://example.com (scheme change) or https://example.com:8080 (port change), the library would consider it a same-origin redirect and would not strip the sensitive headers. This could lead to credential leakage.
The vulnerable function is Client.send in lib/index.js, which contains the faulty logic. The patch corrects this by comparing the full origin (scheme, hostname, and port) of the URLs, ensuring that sensitive headers are stripped for any cross-origin redirect, including those with a different scheme or port on the same hostname.