Coders Conquer Security: Share & Learn Series - Unvalidated Redirects and Forwards
Coding a website or application with the ability to process unvalidated redirects and forwards can be extremely dangerous for both your users and your organization. This common mistake is often exploited by hackers looking to perpetrate phishing scams, or to gain access to pages and information that would normally be restricted.
Whenever a web application is designed to forward users to new pages, there is the danger that those requests can be manipulated or hijacked. This can happen if there is no validation process in place to prevent forwarding parameters from pointing at unintended destinations.
The good news is that unvalidated redirects and forwards are one of the easier vulnerabilities to eliminate from your environment. Once removed, you can take a few simple steps to ensure that they are never generated in the future.
In this episode, we will learn:
- How hackers exploit unvalidated redirect and forward vulnerabilities
- Why allowing unvalidated redirects and forwards can be dangerous
- Policies and techniques that can be employed to find and fix this problem.
How do Attackers Exploit Unvalidated Redirects and Forwards?
Attackers must first find a web application that is set to forward users to a specific page or pages. If the destination page is defined in the code, there is no vulnerability. For example, in Java, this would be a safe, pre-defined way of sending a user to a new location without requiring them to perform any actions, such as clicking on a hyperlink.
response.sendRedirect("http://www.knownsafesite.com");
The vulnerability occurs if the site is programmed to instead accept user input for the redirect, or if the parameter is left open, perhaps to obtain the information from another source. For example, a developer could use the "url'GET parameter.
response.sendRedirect(request.getParameter("url"));
While this gives more flexibility, it also creates the unvalidated redirects and forwards vulnerability. Hackers can add information after the forward slashes to trigger a redirect to whatever site they choose, perhaps as part of a phishing e-mail. Users see the trusted domain in the first part of a link and don't realize that the website may forward them to the hacker's site.
Why are Unvalidated Redirects and Forwards so Dangerous?
The danger posed by allowing unvalidated redirects and forwards can be significant. For users, the biggest danger is that they can become victims of phishing attacks. Because they see the top-level URL, they are more likely to trust a phishing e-mail or other communication and click on a link. And if the page they are redirected to looks like the real page, the deception can be quite effective. They might share their user name, passwords or other credentials and never suspect that they are being manipulated.
Removing the Threat Posed by Unvalidated Redirects and Forwards
Unvalidated redirects and forwards begin life while an application is being developed. They can be eliminated after the fact, but the easiest way to eliminate them is simply not allowing user parameters or open strings as part of any redirect or forward function in the first place. Instead, tightly define the URLs where users will be forwarded, eliminating variables and denying attackers room to maneuver. Better yet, consider not using redirects and forwards at all.
If there is absolutely no way to avoid having variables as part of a redirect or forward process, then there must be a validation process put in place to ensure that the redirect is going to one of a set of valid destinations. Finally, use mapping values instead of actual URLs. Hackers will instead try to use URL information, and likely wont be able to guess at the mapping scheme even if they suspect one is in use.
More Information about Unvalidated Redirects and Forwards
For further reading, you can take a look at the OWASP reference pages on unvalidated redirects and forwards. You can also put your newfound defensive knowledge to the test with the free demo of the Secure Code Warrior platform, which trains cybersecurity teams to become the ultimate cyber warriors. To learn more about defeating this vulnerability, and a rogues'gallery of other threats, visit the Secure Code Warrior blog.
Take care of unvalidated redirects and forwards once and for all. Apply your new knowledge and test your skills on our gamified training platform: [Start Here]


Coding a website or application with the ability to process unvalidated redirects and forwards can be extremely dangerous for both your users and your organization.
Jaap Karan Singh is a Secure Coding Evangelist, Chief Singh and co-founder of Secure Code Warrior.

Secure Code Warrior is here for your organization to help you secure code across the entire software development lifecycle and create a culture in which cybersecurity is top of mind. Whether you’re an AppSec Manager, Developer, CISO, or anyone involved in security, we can help your organization reduce risks associated with insecure code.
Book a demoJaap Karan Singh is a Secure Coding Evangelist, Chief Singh and co-founder of Secure Code Warrior.


Coding a website or application with the ability to process unvalidated redirects and forwards can be extremely dangerous for both your users and your organization. This common mistake is often exploited by hackers looking to perpetrate phishing scams, or to gain access to pages and information that would normally be restricted.
Whenever a web application is designed to forward users to new pages, there is the danger that those requests can be manipulated or hijacked. This can happen if there is no validation process in place to prevent forwarding parameters from pointing at unintended destinations.
The good news is that unvalidated redirects and forwards are one of the easier vulnerabilities to eliminate from your environment. Once removed, you can take a few simple steps to ensure that they are never generated in the future.
In this episode, we will learn:
- How hackers exploit unvalidated redirect and forward vulnerabilities
- Why allowing unvalidated redirects and forwards can be dangerous
- Policies and techniques that can be employed to find and fix this problem.
How do Attackers Exploit Unvalidated Redirects and Forwards?
Attackers must first find a web application that is set to forward users to a specific page or pages. If the destination page is defined in the code, there is no vulnerability. For example, in Java, this would be a safe, pre-defined way of sending a user to a new location without requiring them to perform any actions, such as clicking on a hyperlink.
response.sendRedirect("http://www.knownsafesite.com");
The vulnerability occurs if the site is programmed to instead accept user input for the redirect, or if the parameter is left open, perhaps to obtain the information from another source. For example, a developer could use the "url'GET parameter.
response.sendRedirect(request.getParameter("url"));
While this gives more flexibility, it also creates the unvalidated redirects and forwards vulnerability. Hackers can add information after the forward slashes to trigger a redirect to whatever site they choose, perhaps as part of a phishing e-mail. Users see the trusted domain in the first part of a link and don't realize that the website may forward them to the hacker's site.
Why are Unvalidated Redirects and Forwards so Dangerous?
The danger posed by allowing unvalidated redirects and forwards can be significant. For users, the biggest danger is that they can become victims of phishing attacks. Because they see the top-level URL, they are more likely to trust a phishing e-mail or other communication and click on a link. And if the page they are redirected to looks like the real page, the deception can be quite effective. They might share their user name, passwords or other credentials and never suspect that they are being manipulated.
Removing the Threat Posed by Unvalidated Redirects and Forwards
Unvalidated redirects and forwards begin life while an application is being developed. They can be eliminated after the fact, but the easiest way to eliminate them is simply not allowing user parameters or open strings as part of any redirect or forward function in the first place. Instead, tightly define the URLs where users will be forwarded, eliminating variables and denying attackers room to maneuver. Better yet, consider not using redirects and forwards at all.
If there is absolutely no way to avoid having variables as part of a redirect or forward process, then there must be a validation process put in place to ensure that the redirect is going to one of a set of valid destinations. Finally, use mapping values instead of actual URLs. Hackers will instead try to use URL information, and likely wont be able to guess at the mapping scheme even if they suspect one is in use.
More Information about Unvalidated Redirects and Forwards
For further reading, you can take a look at the OWASP reference pages on unvalidated redirects and forwards. You can also put your newfound defensive knowledge to the test with the free demo of the Secure Code Warrior platform, which trains cybersecurity teams to become the ultimate cyber warriors. To learn more about defeating this vulnerability, and a rogues'gallery of other threats, visit the Secure Code Warrior blog.
Take care of unvalidated redirects and forwards once and for all. Apply your new knowledge and test your skills on our gamified training platform: [Start Here]

Coding a website or application with the ability to process unvalidated redirects and forwards can be extremely dangerous for both your users and your organization. This common mistake is often exploited by hackers looking to perpetrate phishing scams, or to gain access to pages and information that would normally be restricted.
Whenever a web application is designed to forward users to new pages, there is the danger that those requests can be manipulated or hijacked. This can happen if there is no validation process in place to prevent forwarding parameters from pointing at unintended destinations.
The good news is that unvalidated redirects and forwards are one of the easier vulnerabilities to eliminate from your environment. Once removed, you can take a few simple steps to ensure that they are never generated in the future.
In this episode, we will learn:
- How hackers exploit unvalidated redirect and forward vulnerabilities
- Why allowing unvalidated redirects and forwards can be dangerous
- Policies and techniques that can be employed to find and fix this problem.
How do Attackers Exploit Unvalidated Redirects and Forwards?
Attackers must first find a web application that is set to forward users to a specific page or pages. If the destination page is defined in the code, there is no vulnerability. For example, in Java, this would be a safe, pre-defined way of sending a user to a new location without requiring them to perform any actions, such as clicking on a hyperlink.
response.sendRedirect("http://www.knownsafesite.com");
The vulnerability occurs if the site is programmed to instead accept user input for the redirect, or if the parameter is left open, perhaps to obtain the information from another source. For example, a developer could use the "url'GET parameter.
response.sendRedirect(request.getParameter("url"));
While this gives more flexibility, it also creates the unvalidated redirects and forwards vulnerability. Hackers can add information after the forward slashes to trigger a redirect to whatever site they choose, perhaps as part of a phishing e-mail. Users see the trusted domain in the first part of a link and don't realize that the website may forward them to the hacker's site.
Why are Unvalidated Redirects and Forwards so Dangerous?
The danger posed by allowing unvalidated redirects and forwards can be significant. For users, the biggest danger is that they can become victims of phishing attacks. Because they see the top-level URL, they are more likely to trust a phishing e-mail or other communication and click on a link. And if the page they are redirected to looks like the real page, the deception can be quite effective. They might share their user name, passwords or other credentials and never suspect that they are being manipulated.
Removing the Threat Posed by Unvalidated Redirects and Forwards
Unvalidated redirects and forwards begin life while an application is being developed. They can be eliminated after the fact, but the easiest way to eliminate them is simply not allowing user parameters or open strings as part of any redirect or forward function in the first place. Instead, tightly define the URLs where users will be forwarded, eliminating variables and denying attackers room to maneuver. Better yet, consider not using redirects and forwards at all.
If there is absolutely no way to avoid having variables as part of a redirect or forward process, then there must be a validation process put in place to ensure that the redirect is going to one of a set of valid destinations. Finally, use mapping values instead of actual URLs. Hackers will instead try to use URL information, and likely wont be able to guess at the mapping scheme even if they suspect one is in use.
More Information about Unvalidated Redirects and Forwards
For further reading, you can take a look at the OWASP reference pages on unvalidated redirects and forwards. You can also put your newfound defensive knowledge to the test with the free demo of the Secure Code Warrior platform, which trains cybersecurity teams to become the ultimate cyber warriors. To learn more about defeating this vulnerability, and a rogues'gallery of other threats, visit the Secure Code Warrior blog.
Take care of unvalidated redirects and forwards once and for all. Apply your new knowledge and test your skills on our gamified training platform: [Start Here]

Click on the link below and download the PDF of this resource.
Secure Code Warrior is here for your organization to help you secure code across the entire software development lifecycle and create a culture in which cybersecurity is top of mind. Whether you’re an AppSec Manager, Developer, CISO, or anyone involved in security, we can help your organization reduce risks associated with insecure code.
View reportBook a demoJaap Karan Singh is a Secure Coding Evangelist, Chief Singh and co-founder of Secure Code Warrior.
Coding a website or application with the ability to process unvalidated redirects and forwards can be extremely dangerous for both your users and your organization. This common mistake is often exploited by hackers looking to perpetrate phishing scams, or to gain access to pages and information that would normally be restricted.
Whenever a web application is designed to forward users to new pages, there is the danger that those requests can be manipulated or hijacked. This can happen if there is no validation process in place to prevent forwarding parameters from pointing at unintended destinations.
The good news is that unvalidated redirects and forwards are one of the easier vulnerabilities to eliminate from your environment. Once removed, you can take a few simple steps to ensure that they are never generated in the future.
In this episode, we will learn:
- How hackers exploit unvalidated redirect and forward vulnerabilities
- Why allowing unvalidated redirects and forwards can be dangerous
- Policies and techniques that can be employed to find and fix this problem.
How do Attackers Exploit Unvalidated Redirects and Forwards?
Attackers must first find a web application that is set to forward users to a specific page or pages. If the destination page is defined in the code, there is no vulnerability. For example, in Java, this would be a safe, pre-defined way of sending a user to a new location without requiring them to perform any actions, such as clicking on a hyperlink.
response.sendRedirect("http://www.knownsafesite.com");
The vulnerability occurs if the site is programmed to instead accept user input for the redirect, or if the parameter is left open, perhaps to obtain the information from another source. For example, a developer could use the "url'GET parameter.
response.sendRedirect(request.getParameter("url"));
While this gives more flexibility, it also creates the unvalidated redirects and forwards vulnerability. Hackers can add information after the forward slashes to trigger a redirect to whatever site they choose, perhaps as part of a phishing e-mail. Users see the trusted domain in the first part of a link and don't realize that the website may forward them to the hacker's site.
Why are Unvalidated Redirects and Forwards so Dangerous?
The danger posed by allowing unvalidated redirects and forwards can be significant. For users, the biggest danger is that they can become victims of phishing attacks. Because they see the top-level URL, they are more likely to trust a phishing e-mail or other communication and click on a link. And if the page they are redirected to looks like the real page, the deception can be quite effective. They might share their user name, passwords or other credentials and never suspect that they are being manipulated.
Removing the Threat Posed by Unvalidated Redirects and Forwards
Unvalidated redirects and forwards begin life while an application is being developed. They can be eliminated after the fact, but the easiest way to eliminate them is simply not allowing user parameters or open strings as part of any redirect or forward function in the first place. Instead, tightly define the URLs where users will be forwarded, eliminating variables and denying attackers room to maneuver. Better yet, consider not using redirects and forwards at all.
If there is absolutely no way to avoid having variables as part of a redirect or forward process, then there must be a validation process put in place to ensure that the redirect is going to one of a set of valid destinations. Finally, use mapping values instead of actual URLs. Hackers will instead try to use URL information, and likely wont be able to guess at the mapping scheme even if they suspect one is in use.
More Information about Unvalidated Redirects and Forwards
For further reading, you can take a look at the OWASP reference pages on unvalidated redirects and forwards. You can also put your newfound defensive knowledge to the test with the free demo of the Secure Code Warrior platform, which trains cybersecurity teams to become the ultimate cyber warriors. To learn more about defeating this vulnerability, and a rogues'gallery of other threats, visit the Secure Code Warrior blog.
Take care of unvalidated redirects and forwards once and for all. Apply your new knowledge and test your skills on our gamified training platform: [Start Here]
Table of contents
Jaap Karan Singh is a Secure Coding Evangelist, Chief Singh and co-founder of Secure Code Warrior.

Secure Code Warrior is here for your organization to help you secure code across the entire software development lifecycle and create a culture in which cybersecurity is top of mind. Whether you’re an AppSec Manager, Developer, CISO, or anyone involved in security, we can help your organization reduce risks associated with insecure code.
Book a demoDownloadResources to get you started
Benchmarking Security Skills: Streamlining Secure-by-Design in the Enterprise
Finding meaningful data on the success of Secure-by-Design initiatives is notoriously difficult. CISOs are often challenged when attempting to prove the return on investment (ROI) and business value of security program activities at both the people and company levels. Not to mention, it’s particularly difficult for enterprises to gain insights into how their organizations are benchmarked against current industry standards. The President’s National Cybersecurity Strategy challenged stakeholders to “embrace security and resilience by design.” The key to making Secure-by-Design initiatives work is not only giving developers the skills to ensure secure code, but also assuring the regulators that those skills are in place. In this presentation, we share a myriad of qualitative and quantitative data, derived from multiple primary sources, including internal data points collected from over 250,000 developers, data-driven customer insights, and public studies. Leveraging this aggregation of data points, we aim to communicate a vision of the current state of Secure-by-Design initiatives across multiple verticals. The report details why this space is currently underutilized, the significant impact a successful upskilling program can have on cybersecurity risk mitigation, and the potential to eliminate categories of vulnerabilities from a codebase.
Secure code training topics & content
Our industry-leading content is always evolving to fit the ever changing software development landscape with your role in mind. Topics covering everything from AI to XQuery Injection, offered for a variety of roles from Architects and Engineers to Product Managers and QA. Get a sneak peak of what our content catalog has to offer by topic and role.
Quests: Industry leading learning to keep developers ahead of the game mitigating risk.
Quests is a learning platform that helps developers mitigate software security risks by enhancing their secure coding skills. With curated learning paths, hands-on challenges, and interactive activities, it empowers developers to identify and prevent vulnerabilities.
Resources to get you started
Is Vibe Coding Going to Turn Your Codebase Into a Frat Party?
Vibe coding is like a college frat party, and AI is the centerpiece of all the festivities, the keg. It’s a lot of fun to let loose, get creative, and see where your imagination can take you, but after a few keg stands, drinking (or, using AI) in moderation is undoubtedly the safer long-term solution.
The Decade of the Defenders: Secure Code Warrior Turns Ten
Secure Code Warrior's founding team has stayed together, steering the ship through every lesson, triumph, and setback for an entire decade. We’re scaling up and ready to face our next chapter, SCW 2.0, as the leaders in developer risk management.