Blog

Coders Conquer Security: Share & Learn Series - Unvalidated Redirects and Forwards

Jaap Karan Singh
Published May 23, 2019

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]

View Resource
View Resource

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.

Interested in more?

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 demo
Share on:
Author
Jaap Karan Singh
Published May 23, 2019

Jaap Karan Singh is a Secure Coding Evangelist, Chief Singh and co-founder of Secure Code Warrior.

Share on:

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]

View Resource
View Resource

Fill out the form below to download the report

We would like your permission to send you information on our products and/or related secure coding topics. We’ll always treat your personal details with the utmost care and will never sell them to other companies for marketing purposes.

Submit
To submit the form, please enable 'Analytics' cookies. Feel free to disable them again once you're done.

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]

Get Started

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 demo
View Resource
Share on:
Interested in more?

Share on:
Author
Jaap Karan Singh
Published May 23, 2019

Jaap Karan Singh is a Secure Coding Evangelist, Chief Singh and co-founder of Secure Code Warrior.

Share on:

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

Download PDF
View Resource
Interested in more?

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 demoDownload
Share on:
Resource hub

Resources to get you started

More posts
Resource hub

Resources to get you started

More posts