When you visit any website, it may store or retrieve information on your browser, mostly in the form of cookies. This information might be about you, your preferences or your device and is mostly used to make the site work as you expect it to. The information does not usually directly identify you, but it can give you a more personalized web experience. Because we respect your right to privacy, you can choose not to allow some types of cookies. Click on the different category headings to find out more and change our default settings. However, blocking some types of cookies may impact your experience of the site and the services we are able to offer.
More information
Hi @SChandan516395 (Community Member),
Veracode Static Analysis reports CWE 601 ('Open Redirect') when it can see that you take potentially user-controlled data (e.g. from the URL) and redirect to it. The concern being an attacker might be able to craft a URL that goes to your page first and then redirects to a phishing page.
In your example, it seems to me that you are checking if the last character of the URL is '#'. If that is the case, you redirect to the same URL minus the '#'. I don't see how this can lead to an Open Redirect and recommend that you propose a mitigation by design for this and discuss it with your organization's Security Team. For more information on how to propose a mitigation, please refer to our Help Center: https://docs.veracode.com/r/improve_mitigation
Thank you,
Florian Walter
Thanks Florian for the feedback.
Is it possible that URL can have an evil javascript method ?
Yes, this is actually little known, but besides e.g. HTTP, HTTPS, FTP, etc., another valid URL is `javascript:`. This means that e.g. `javascript:alert(5)` is a valid URL that would execute the JavaScript (in this case, simply create an alert box as a proof of concept).
As a matter of fact, frameworks like React are actively trying to deprecate this functionality ("A future version of React will block javascript: URLs as a security precaution") as it is not really needed anymore but is the reason for many security issues.