How serious is this new ASP.NET security vulnerability and how can I workaround it?

I’ve just read on the net about a newly discovered security vulnerability in ASP.NET. You can read the details here.

The problem lies in the way that
ASP.NET implements the AES encryption
algorithm to protect the integrity of
the cookies these applications
generate to store information during
user sessions.

This is a bit vague, but here is a more frightening part:

The first stage of the attack takes a
few thousand requests, but once it
succeeds and the attacker gets the
secret keys, it’s totally stealthy.The
cryptographic knowledge required is
very basic.

All in all, I’m not familiar enough with the security/cryptograpy subject to know if this is really that serious.

So, should all ASP.NET developers fear this technique that can own any ASP.NET website in seconds or what?

How does this issue affect the average ASP.NET developer? Does it affect us at all?
In real life, what are the consequences of this vulnerability? And, finally: is there some workaround that prevents this vulnerability?

Thanks for your answers!


EDIT: Let me summarize the responses I got

So, this is basically a “padding oracle” type of attack. @Sri provided a great explanation about what does this type of attack mean. Here is a shocking video about the issue!

About the seriousness of this vulnerability: Yes, it is indeed serious. It lets the attacker to get to know the machine key of an application. Thus, he can do some very unwanted things.

  • In posession of the app’s machine key, the attacker can decrypt authentication cookies.
  • Even worse than that, he can generate authentication cookies with the name of any user. Thus, he can appear as anyone on the site. The application is unable to differentiate between you or the hacker who generated an authentication cookie with your name for himself.
  • It also lets him to decrypt (and also generate) session cookies, although this is not as dangerous as the previous one.
  • Not so serious: He can decrypt the encrypted ViewState of pages. (If you use ViewState to store confidental data, you shouldn’t do this anyways!)
  • Quite unexpected: With the knowledge of the machine key, the attacker can download any arbitrary file from your web application, even those that normally can’t be downloaded! (Including Web.Config, etc.)

Here is a bunch of good practices I got that don’t solve the issue but help improve the general security of a web application.

  • You can encrypt sensitive data with Protected Configuration
  • Use HTTP Only cookies
  • Prevent DoS attacks

Now, let’s focus on this issue.

  • Scott Guthrie published an entry about it on his blog
  • ScottGu’s FAQ blog post about the vulnerability
  • ScottGu’s update on the vulnerability
  • Microsoft has a security advisory about it
  • Understanding the vulnerability
  • Additional information about the vulnerability

The solution

  • Enable customErrors and make a single error page to which all errors are redirected. Yes, even 404s. (ScottGu said that differentiating between 404s and 500s are essential for this attack.) Also, into your Application_Error or Error.aspx put some code that makes a random delay. (Generate a random number, and use Thread.Sleep to sleep for that long.) This will make it impossible for the attacker to decide what exactly happened on your server.
  • Some people recommended switching back to 3DES. In theory, if you don’t use AES, you don’t encounter the security weakness in the AES implementation. As it turns out, this is not recommended at all.

Some other thoughts

  • Seems that not everyone thinks the workaround is good enough.

Thanks to everyone who answered my question. I learned a lot about not only this issue, but web security in general. I marked @Mikael’s answer as accepted, but the other answers are also very useful.

10 Answers
10

Leave a Comment