The vulnerability is an open redirect caused by the improper handling of URLs starting with // in the redirect function. The browser interprets these as protocol-relative URLs, causing a redirect to an external domain. The provided patch addresses this by normalizing double slashes in redirect paths.
The analysis of the commits associated with the fix shows that the core change is in the normalizeRedirectLocation function in packages/react-router/lib/router/router.ts. The patch modifies this function to use a new removeDoubleSlashes utility. This utility replaces any occurrence of // with / in the path.
Before the patch, normalizeRedirectLocation would return a path starting with // without modification. This is the root cause of the vulnerability. By adding the call to removeDoubleSlashes, the malicious URL is sanitized, and the open redirect is prevented. Therefore, normalizeRedirectLocation is identified as the vulnerable function where the improperly handled input leads to the security flaw.