Difference between revisions of "Top 10 2010-A10-Unvalidated Redirects and Forwards"

From OWASP
Jump to: navigation, search
(Created page with '{{Top_10_2010:TopTemplate|usenext=NextLink|next=-Broken Authentication and Session Management|useprev=PrevLink|prev=-Cross Site Request Forgery|usemain=MainLink|main=}} <center…')
 
 
(12 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{Top_10_2010:TopTemplate|usenext=NextLink|next=-Broken Authentication and Session Management|useprev=PrevLink|prev=-Cross Site Request Forgery|usemain=MainLink|main=}}  
+
{{Top_10_2010:TopTemplate|useprev=2010PrevLink|usenext=2010NextLink|prev=A9-Insufficient Transport Layer Protection|next=What's Next For Developers}}
  
<center>
+
{{Top_10_2010:SummaryTableHeaderBeginTemplate}}
{| style="align:center; text-align:center; border:2px solid #4F81BD; background-color:#F2F2F2;"
+
{{Top_10_2010:SummaryTableValue-2-Template|Exploitability|AVERAGE}}
|- style="background-color: #4F81Bd; color: #000000;"
+
{{Top_10_2010:SummaryTableValue-3-Template|Prevalence|UNCOMMON}}
! Threat Agents !! Attack Vectors !! Security Weakness !! Weakness Detectability !! Technical Impact !! Business Impacts
+
{{Top_10_2010:SummaryTableValue-1-Template|Detectability|EASY}}
|-
+
{{Top_10_2010:SummaryTableValue-2-Template|Impact|MODERATE}}
| style="background-color: #D9D9D9; color: #000000;" | ______
+
{{Top_10_2010:SummaryTableHeaderEndTemplate}}
| style="background-color: #FF0000; color: #000000;" | Exploitability<br>EASY
+
    <td {{Template:Top 10 2010:SummaryTableRowStyleTemplate}}>Consider anyone who can trick your users into submitting a request to your website. Any website or other HTML feed that your users use could do this.</td>
| style="background-color: #FFB200; color: #000000;" | Prevalence<br>COMMON
+
    <td {{Template:Top 10 2010:SummaryTableRowStyleTemplate}}>Attacker links to unvalidated redirect and tricks victims into clicking it. Victims are more likely to click on it, since the link is to a valid site. Attacker targets unsafe forward to bypass security checks.</td>
| style="background-color: #FFB200; color: #000000;" | Detectability<br>AVERAGE
+
    <td colspan=2  {{Template:Top 10 2010:SummaryTableRowStyleTemplate}}>Applications frequently redirect users to other pages, or use internal forwards in a similar manner. Sometimes the target page is specified in an unvalidated parameter, allowing attackers to choose the destination page.</td>
| style="background-color: #FF0000; color: #000000;" | Impact<br>SIMPLE
+
    <td {{Template:Top 10 2010:SummaryTableRowStyleTemplate}}>Such redirects may attempt to install malware or trick victims into disclosing passwords or other sensitive information. Unsafe forwards may allow access control bypass.</td>
| style="background-color: #D9D9D9; color: #000000;" | ______
+
    <td {{Template:Top 10 2010:SummaryTableRowStyleTemplate}}>Consider the business value of retaining your users’ trust.<br/><br/>What if they get owned by malware?<br/><br/>What if attackers can access internal only functions?</td>
|-
+
{{Top_10_2010:SummaryTableEndTemplate}}
|
+
|
+
|
+
|
+
|
+
|
+
|}
+
</center>
+
  
{{Top_10_2010:SubsectionVulnerableTemplate|Injection|
+
{{Top_10_2010:SubsectionAdvancedTemplate|type={{Top_10_2010:StyleTemplate}}|number=1|risk=10}}
{{Top_10_2010:SubsectionPreventionTemplate|Injection|
+
The best way to find out if an application has any unvalidated redirects or forwards is to:
{{Top_10_2010:SubsectionExampleTemplate|Injection|
+
# Review the code for all uses of redirect or forward (called a transfer in .NET). For each use, identify if the target URL is included in any parameter values. If so, verify the parameter(s) are validated to contain only an allowed destination, or element of a destination.
{{Top_10_2010:SubsectionReferencesTemplate|Injection|
+
# Also, spider the site to see if it generates any redirects (HTTP response codes 300-307, typically 302). Look at the parameters supplied prior to the redirect to see if they appear to be a target URL or a piece of such a URL. If so, change the URL target and observe whether the site redirects to the new target.
 +
# If code is unavailable, check all parameters to see if they look like part of a redirect or forward URL destination and test those that do.
 +
{{Top_10_2010:SubsectionAdvancedTemplate|type={{Top_10_2010:StyleTemplate}}|number=2|risk=10}}
 +
Safe use of redirects and forwards can be done in a number of ways:
 +
# Simply avoid using redirects and forwards.
 +
# If used, don’t involve user parameters in calculating the destination. This can usually be done.
 +
# If destination parameters can’t be avoided, ensure that the supplied '''value''' is valid, and '''authorized''' for the user.
  
 +
It is recommended that any such destination parameters be a mapping value, rather than the actual URL or portion of the URL, and that server side code translate this mapping to the target URL.
  
{{Top_10_2010:BottomTemplate|usenext=NextLink|next=-Broken Authentication and Session Management|useprev=PrevLink|prev=-Cross Site Request Forgery|usemain=MainLink|main=}}
+
Applications can use ESAPI to override the [http://owasp-esapi-java.googlecode.com/svn/trunk_doc/latest/org/owasp/esapi/filters/SecurityWrapperResponse.html#sendRedirect(java.lang.String) sendRedirect()] method to make sure all redirect destinations are safe.
 +
 
 +
Avoiding such flaws is extremely important as they are a favorite target of phishers trying to gain the user’s trust.
 +
{{Top_10_2010:SubsectionAdvancedTemplate|type={{Top_10_2010:StyleTemplate}}|number=3|risk=10}}
 +
Scenario #1: The application has a page called “redirect.jsp” which takes a single parameter named “url”. The attacker crafts a malicious URL that redirects users to a malicious site that performs phishing and installs malware.
 +
 
 +
{{Top_10_2010:ExampleBeginTemplate}}<nowiki>http://www.example.com/redirect.jsp?url=evil.com</nowiki>{{Top_10_2010:ExampleEndTemplate}}
 +
 
 +
Scenario #2:The application uses forward to route requests between different parts of the site. To facilitate this, some pages use a parameter to indicate where the user should be sent if a transaction is successful. In this case, the attacker crafts a URL that will pass the application’s access control check and then forward the attacker to an administrative function that she would not normally be able to access.
 +
 
 +
{{Top_10_2010:ExampleBeginTemplate}}<nowiki>http://www.example.com/boring.jsp?fwd=admin.jsp</nowiki>{{Top_10_2010:ExampleEndTemplate}}
 +
{{Top_10_2010:SubsectionAdvancedTemplate|type={{Top_10_2010:StyleTemplate}}|number=4|risk=10}}
 +
{{Top_10_2010:SubSubsectionOWASPReferencesTemplate}}
 +
* [[Open_redirect | OWASP Article on Open Redirects]]
 +
* [http://owasp-esapi-java.googlecode.com/svn/trunk_doc/latest/org/owasp/esapi/filters/SecurityWrapperResponse.html#sendRedirect(java.lang.String) ESAPI SecurityWrapperResponse.sendRedirect() method]
 +
{{Top_10_2010:SubSubsectionExternalReferencesTemplate}}
 +
*[http://cwe.mitre.org/data/definitions/601.html CWE Entry 601 on Open Redirects]
 +
*[http://projects.webappsec.org/URL-Redirector-Abuse WASC Article on URL Redirector Abuse]
 +
*[http://googlewebmastercentral.blogspot.com/2009/01/open-redirect-urls-is-your-site-being.html Google blog article on the dangers of open redirects]
 +
{{Top_10_2010:BottomAdvancedTemplate|type={{Top_10_2010:StyleTemplate}}|useprev=2010PrevLink|usenext=2010NextLink|prev=A9-Insufficient Transport Layer Protection|next=What's Next For Developers}}
 +
 
 +
[[Category:OWASP Top Ten Project]]

Latest revision as of 11:17, 24 October 2011

← A9-Insufficient Transport Layer Protection
Top 10 Introduction
Top 10 Risks
What's Next For Developers →
Threat Agents Attack Vectors Security Weakness Technical Impacts Business Impacts
Application Specific Exploitability
AVERAGE
Prevalence
UNCOMMON
Detectability
EASY
Impact
MODERATE
Application / Business Specific
Consider anyone who can trick your users into submitting a request to your website. Any website or other HTML feed that your users use could do this. Attacker links to unvalidated redirect and tricks victims into clicking it. Victims are more likely to click on it, since the link is to a valid site. Attacker targets unsafe forward to bypass security checks. Applications frequently redirect users to other pages, or use internal forwards in a similar manner. Sometimes the target page is specified in an unvalidated parameter, allowing attackers to choose the destination page. Such redirects may attempt to install malware or trick victims into disclosing passwords or other sensitive information. Unsafe forwards may allow access control bypass. Consider the business value of retaining your users’ trust.

What if they get owned by malware?

What if attackers can access internal only functions?
Am I Vulnerable To 'Unvalidated Redirects and Forwards'?

The best way to find out if an application has any unvalidated redirects or forwards is to:

  1. Review the code for all uses of redirect or forward (called a transfer in .NET). For each use, identify if the target URL is included in any parameter values. If so, verify the parameter(s) are validated to contain only an allowed destination, or element of a destination.
  2. Also, spider the site to see if it generates any redirects (HTTP response codes 300-307, typically 302). Look at the parameters supplied prior to the redirect to see if they appear to be a target URL or a piece of such a URL. If so, change the URL target and observe whether the site redirects to the new target.
  3. If code is unavailable, check all parameters to see if they look like part of a redirect or forward URL destination and test those that do.
How Do I Prevent 'Unvalidated Redirects and Forwards'?

Safe use of redirects and forwards can be done in a number of ways:

  1. Simply avoid using redirects and forwards.
  2. If used, don’t involve user parameters in calculating the destination. This can usually be done.
  3. If destination parameters can’t be avoided, ensure that the supplied value is valid, and authorized for the user.

It is recommended that any such destination parameters be a mapping value, rather than the actual URL or portion of the URL, and that server side code translate this mapping to the target URL.

Applications can use ESAPI to override the sendRedirect() method to make sure all redirect destinations are safe.

Avoiding such flaws is extremely important as they are a favorite target of phishers trying to gain the user’s trust.

Example Attack Scenarios

Scenario #1: The application has a page called “redirect.jsp” which takes a single parameter named “url”. The attacker crafts a malicious URL that redirects users to a malicious site that performs phishing and installs malware.

http://www.example.com/redirect.jsp?url=evil.com

Scenario #2:The application uses forward to route requests between different parts of the site. To facilitate this, some pages use a parameter to indicate where the user should be sent if a transaction is successful. In this case, the attacker crafts a URL that will pass the application’s access control check and then forward the attacker to an administrative function that she would not normally be able to access.

http://www.example.com/boring.jsp?fwd=admin.jsp
References

OWASP

External

← A9-Insufficient Transport Layer Protection
Top 10 Introduction
Top 10 Risks
What's Next For Developers →

© 2002-2010 OWASP Foundation This document is licensed under the Creative Commons Attribution-ShareAlike 3.0 license. Some rights reserved. CC-by-sa-3 0-88x31.png