The vulnerability is an open redirect in Nitro's route rule handling, caused by improper processing of URL paths with double leading slashes (//). The issue has two main causes:
-
A flaw in the withoutBase function within the ufo dependency. When stripping a base path from a URL like /legacy//evil.com, the function would incorrectly return //evil.com. Browsers interpret this as a protocol-relative URL, leading to a redirect to an external, attacker-controlled domain (e.g., https://evil.com).
-
A logic error in Nitro's redirect and proxy rule handlers for the specific edge case of a /** wildcard rule. In this scenario, the withoutBase function was not used, and the raw path from the request was passed directly to construct the redirect/proxy URL. An attacker could send a request to //evil.com, and Nitro would generate a redirect to that same path, resulting in an open redirect.
The exploitation occurs within the event handlers created by the redirect and proxy functions located in src/runtime/internal/route-rules.ts. These handlers would either call the vulnerable ufo.withoutBase function or use the raw request path. The resulting malicious path would then be used to generate a Location header for a redirect or as the target for a proxy request. Consequently, withoutBase, redirect, and proxy are the key functions involved in this vulnerability. The fix involved patching ufo.withoutBase to correctly normalize leading slashes and adding a specific check in Nitro's runtime to handle the /** edge case.