Skip to main content

Microsoft .NET MVC ReDoS (Denial of Service) Vulnerability - CVE-2015-2526 (MS15-101)

Microsoft released a security bulletin (MS15-101) describing a .NET MVC Denial of Service vulnerability (CVE-2015-2526) that I reported back in April. This blog post analyses the vulnerability in details, starting from the theory and then providing a PoC exploit against a MVC web application developed with Visual Studio 2013.
For those of you who want to see the bug, you can directly skip to the last part of this post or watch the video directly... ;-)

A bit of theory

The .NET framework (4.5 tested version) uses backtracking regular expression matcher when performing a match against an expression. Backtracking is based on the NFA (non-deterministic finite automata) algorithm engine which is designed to validate all input states. By providing an “evil” regex expression – an expression for which the engine can be forced to calculate an exponential number of states - it is possible to force the engine to calculate an exponential number of states, leading to a condition defined such as “catastrophic backtracking” aka ReDoS.

The vulnerability

In .NET Framework (4.5), “evil” regular expressions are used by default in three classes (EmailAddressAttribute, PhoneAttribute, UrlAttribute) which are part of System.CompontentModel.DataAnnotations .NET library.

These classes provide the default validation mechanism for email address, phone number and URL input types in web forms. Furthermore, these three classes do not enforce a regex match timeout.

The following screen shots show the evil regex and the lack of match timeout:

EmailAddressAttribute Source code 

PhoneAttribute Source Code

UrlAttribute Source Code

As a consequence, an attacker can craft a malicious payload to force the .NET regex engine to perform a large number of computations and cause a Denial of Service against the targeted controller (e.g. login form) which uses default validation mechanism provided by .NET framework.

The Denial of Service condition is only specific to the target class controller (e.g. login form, registration form, contact form, etc.). Users can still potentially navigate the site but they are prevented from using parts of it.

As an example, the .NET email address regex is analyzed. Its regex expression is considered an “evil” regex, due to its complexity, repetition, nesting and recursion. The regex is reported in the screen shot below. The software RegexBuddy was used to analyze it.

The theory of the attack is demonstrated below, with the help of RegexBuddy and its built-in debugger (set for C# - .NET 2.0-4.5) - with payload (in the table below) which will never match the above regex:


An extract of the last 26 operations (stopped by RegexBuddy) can be found below, from the Debugger view:

This shows the “catastrophic backtracking” condition reached by the matcher. In this case, RegexBuddy stops calculations after one million steps, however, the vulnerable class – EmailAddressAttribute - does not enforce a match timeout and therefore the .NET regex engine continues to compute steps, leading the w3wp.exe process (IIS Worker Pool) on the web server to reach a 99% CPU starvation condition for an extended amount of time, which can last various hours to days, depending on the payload used.

The payload can be constructed in different ways, providing the attacker with the capability to bypass IDS/IPS signature based controls. The attacker can set scripts to automatically attack vulnerable forms on a regular time basis.

The exploit

The exploitation consists in sending a crafted HTTP POST request against a web form using a vulnerable class (e.g. EmailAddressAttribute). As an example, the attack is demonstrated against a .NET MVC web application developed with the Visual Studio 2013. The application provides a login form which uses the default email address validation mechanism in .NET framework. The screen shot below shows the login page:

An attacker can bypass client-side validation in .NET by sending the request via script or proxy and manipulating the request, as shown below:

POST /Account/Login HTTP/1.1
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:36.0) Gecko/20100101 Firefox/36.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Cookie: __RequestVerificationToken=FkLGrc6-XD2IBVU9g1nPycs0GTu3jWiK2QEyvR8IsowXAJU3C5fHlHvQvwGgB0VcN1FTa_hB9KZ6Pi8SeI5EKpvz_EeOqD7y_FnipWJWqOU1
Connection: keep-alive
Content-Type: application/x-www-form-urlencoded
Content-Length: 239


Below, an extract of the source code used for the validation of the EmailAddress field:

AccountModelView.cs - use of [EmailAddress] default class in .NET

   public class LoginViewModel
        [Display(Name = "Email")]
        public string Email { get; set; }

AccountController.cs – ModelState is validated when  the POST request occurs

// POST: /Account/Login
        public async Task<ActionResult> Login(LoginViewModel model, string returnUrl)
            if (!ModelState.IsValid)
                return View(model);

            // This doesn't count login failures towards account lockout
            // To enable password failures to trigger account lockout, change to shouldLockout: true
            var result = await SignInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, shouldLockout: false);
            switch (result)

The table below shows the DoS condition on the web server, after the request has been issued.

Following the request, the Denial of Service occurs against the /Account/Login controller class. At this stage, no other users can use /Account/Login form controller class, while the w3wp.exe process is at 99% CPU starvation.

The w3wp.exe process needs to be terminated in order to recover the application from the attack. After few manual recoveries, the application becomes unusable, and the server needs to be restarted.

Below a video that demonstrates the attack in action:

The table below includes valid and tested attack patterns which result in a successful ReDoS attack against .NET applications:

Malicious Payload



  1. "Backtracking is based on the NFA non-finite-algorithm".
    Did you mean "Non-deterministic Finite Automaton"?

  2. Yes, thx for the comment, rectified in the article.

  3. Dinis Cruz's blog on the same topic...


Post a Comment

Popular posts from this blog

Pwning a thin client in less than two minutes

Have you ever encountered a zero client or a thin client? It looks something like this...

If yes, keep reading below, if not, then if you encounter one, you know what you can do if you read below...

The model above is a T520, produced by HP - this model and other similar models are typically employed to support a medium/large VDI (Virtual Desktop Infrastructure) enterprise.

These clients run a Linux-based HP ThinPro OS by default and I had a chance to play with image version T6X44017 in particular, which is fun to play with it, since you can get a root shell in a very short time without knowing any password...

Normally, HP ThinPro OS interface is configured in a kiosk mode, as the concept of a thin/zero client is based on using a thick client to connect to another resource. For this purpose, a standard user does not need to authenticate to the thin client per se and would just need to perform a connection - e.g. VMware Horizon View. The user will eventually authenticate through the c…

UXSS in McAfee Endpoint Security, and some extra goodies...

During the HITB2017AMS talk given in Amsterdam with @Steventseeley, I promised that I would have disclosed vulnerabilities affecting a security vendor product other than Trend Micro.

For those who have come to my blog for the first time and are looking at "insecurities" of security vendors, you might be interested as well on how we found 200+ remote code execution vulnerabilities in Trend Micro software...

But this blog post is dedicated to two McAfee products instead: McAfee Endpoint Security and SiteAdvisor Enterprise (now part of McAfee Endpoint Security). For simplicity, I will just refer to McAfee Endpoint Security for the rest of this post.

First let's demonstrate a particular type of XSS, a UXSS, considering that fact that it only affects the McAfee Endpoint Security plugin and does not depend on a particular web site or web application.

There are two different injection points:

-UXSS when user visits a red labelled web site - the payload is rendered in the BlockP…