The vulnerability exists in the setReturnUrl function within the craft\web\User class, located in src/web/User.php. The function was responsible for setting a return URL, but it used an inadequate sanitization method, strip_tags(). This function only removes HTML tags, leaving other dangerous URL schemes like javascript: and data: untouched. An attacker could craft a URL with a malicious returnUrl parameter, which would be processed by setReturnUrl and stored. When this URL was later used in a link on the page, clicking it would execute the embedded JavaScript, leading to a reflected XSS attack. The provided patch addresses this by adding a check to validate the URL scheme, ensuring that only http and https are allowed, thus neutralizing the XSS vector.