Seeker Advisory: Insecure Redirect in .NET Form Authentication - Redirect From Login Mechanism (ReturnURL Parameter)



Seeker Research Center Security Advisory
By Irene Abezgauz

===========
I. Overview
===========

An Insecure Redirect vulnerability has been identified in the .NET Form
Authentication - in the Redirect From Login mechanism. This
vulnerability allows an attacker to craft links that contain redirects
to malicious sites in the ReturnURL parameter.

The exploitation technique detailed in this document bypasses the
CrossAppRedirects restriction and was successfully performed on
applications that do not have EnableCrossAppRedirects in the web.config
(false by default), or have the EnableCrossAppRedirects attribute
explicitly set to false in web.config.

A friendly formatted version of this advisory is available at:
http://www.seekersec.com/advisories/AdvMS20120216.html

============
II. Details
============

The .NET Forms Authentication Redirect From Login mechanism is
vulnerable to insecure redirect attacks.

http://<myApplication>/Login.aspx?ReturnURL=
By sending specially crafted input containing a backslash ("\") at the
end of the URL as the value of the ReturnURL parameter it is possible to
bypass the CrossAppRedirects restrictions and embed links that lead to
sites outside the current application.

Once a victim follows the specially crafted link he indeed arrives at
the login screen of the vulnerable application. Once he submits his
username and password and performs a successful login instead of being
redirected to the URL in the DefaultURL property he will be redirected
to the URL in the value of the ReturnURL parameter.

To reproduce a simple Login page can be created, for example Login.aspx,
and the following in web.config:

<authentication mode="Forms">
<forms name=".ASPXFORMSDEMO" loginUrl="Login.aspx"
protection="All" path="/" timeout="30" />
</authentication>

===========
IV. Exploit
===========

An attacker can embed any link that terminates with the "\" (backslash)
character, for example:
http://<myApplication>/Login.aspx?ReturnURL=http://www.seekersec.com\

==================
V. Vendor Response
==================

Microsoft has released a fix for this vulnerability, see
http://technet.microsoft.com/en-us/security/bulletin/MS11-100 for
further information

=====================
VII. Affected Systems
=====================

.NET frameworks 2.0, 3.5 and 4.0 were tested and found vulnerable to
this flaw in simple login that has Form Authentication web.config
configuration with default parameters.

============
VIII. Credit
============
The vulnerability was discovered by Irene Abezgauz, Seeker Security

--------------------
Irene Abezgauz
Product Manager
Seeker Security
www.seekersec.com
E-Mail: irene@xxxxxxxxxxxxx



Relevant Pages

  • Re: Default.aspx - newbie Q`
    ... check and redirect to the ReturnURL or Selected.aspx depending on the case. ... > and replace it with something that takes then straight to the login page. ... >> Curt Christianson ... >>> authentication ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Default.aspx - newbie Q`
    ... check and redirect to the ReturnURL or Selected.aspx depending on the case. ... > and replace it with something that takes then straight to the login page. ... >> Curt Christianson ... >>> authentication ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: ASP 2.0 Membership API
    ... After successful authentication, you want to redirect back to the original application, but the returnURL parameter contains only /App1 as the URL. ... The solution to that problem is adding a local login page to the application that does a manual redirect to the central authentication application. ... if not you have to use cookieless auth ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • Re: Detecting Failed Authorization
    ... after every authentication request and before the user ... is redirected to any login page. ... > "Ken Dopierala Jr." ... >> 'Redirect where you want the user to go. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Response.Redirect with IE
    ... login page to another one after a successful login - Am I right? ... In that case, set the Authentication mode to "Forms" in Web.Config, set the ... You don't have to manually redirect, Forms Authentication will do it for you ... > From: Ken Dopierala Jr. ...
    (microsoft.public.dotnet.framework.aspnet)