SCW Icons
hero bg no divider
Blog

程序员征服安全:分享与学习系列-未经验证的重定向和转发

Jaap Karan Singh
Published May 23, 2019
Last updated on Mar 10, 2026

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]

查看资源
查看资源

对能够处理未经验证的重定向和转发的网站或应用程序进行编码对您的用户和组织来说都极其危险。

对更多感兴趣?

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

learn more

Secure Code Warrior可以帮助您的组织在整个软件开发生命周期中保护代码,并营造一种将网络安全放在首位的文化。无论您是 AppSec 经理、开发人员、首席信息安全官还是任何与安全相关的人,我们都可以帮助您的组织降低与不安全代码相关的风险。

预订演示
分享到:
linkedin brandsSocialx logo
作者
Jaap Karan Singh
Published May 23, 2019

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

分享到:
linkedin brandsSocialx logo

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]

查看资源
查看资源

填写下面的表格下载报告

我们希望获得您的许可,以便向您发送有关我们的产品和/或相关安全编码主题的信息。我们将始终非常谨慎地对待您的个人信息,绝不会出于营销目的将其出售给其他公司。

提交
scw success icon
scw error icon
要提交表单,请启用 “分析” Cookie。完成后,可以随意再次禁用它们。

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]

观看网络研讨会
开始吧
learn more

点击下面的链接并下载此资源的PDF。

Secure Code Warrior可以帮助您的组织在整个软件开发生命周期中保护代码,并营造一种将网络安全放在首位的文化。无论您是 AppSec 经理、开发人员、首席信息安全官还是任何与安全相关的人,我们都可以帮助您的组织降低与不安全代码相关的风险。

查看报告预订演示
查看资源
分享到:
linkedin brandsSocialx logo
对更多感兴趣?

分享到:
linkedin brandsSocialx logo
作者
Jaap Karan Singh
Published May 23, 2019

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

分享到:
linkedin brandsSocialx logo

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]

目录

下载PDF
查看资源
对更多感兴趣?

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

learn more

Secure Code Warrior可以帮助您的组织在整个软件开发生命周期中保护代码,并营造一种将网络安全放在首位的文化。无论您是 AppSec 经理、开发人员、首席信息安全官还是任何与安全相关的人,我们都可以帮助您的组织降低与不安全代码相关的风险。

预订演示下载
分享到:
linkedin brandsSocialx logo
资源中心

帮助您入门的资源

更多帖子
资源中心

帮助您入门的资源

更多帖子