
Hi @Nozipho Ngcobo (IT Department) ,
Per my research, using location.href
can be understood to include two things:
Using the value of location.href
by passing it around in your code, manipulating it and using it to guide the logic in your code.
Assigning someting to location.href
, causing the browser to navigate to different URLs.
The first one, using the value, can be considered safe. The value of location.href
is nothing more than a string. Of course it's part of user input, so you don't want to pass it to an eval statement, but that's true for all other forms of user input as well. In fact, the value of location.hre
f is always a valid URL, so certain assumptions can be made of its content. In that sense you could argue it's more safe than most forms of user input. As long as you don't make any wrong assumptions.
The second one is something you should be careful with. Assigning unvalidated values to it can lead to open redirects that can be used for phishing and what's more, XSS issues arising from the use of javascript and vbscript URIs.
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.